本文整理汇总了C++中IEntity::GetId方法的典型用法代码示例。如果您正苦于以下问题:C++ IEntity::GetId方法的具体用法?C++ IEntity::GetId怎么用?C++ IEntity::GetId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEntity
的用法示例。
在下文中一共展示了IEntity::GetId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CloneAttachedItem
EntityId CAICorpse::CloneAttachedItem( const CAICorpse::AttachedItem& attachedItem, IAttachment* pAttachment )
{
stack_string clonedItemName;
clonedItemName.Format("%s_%s", GetEntity()->GetName(), attachedItem.pClass->GetName() );
SEntitySpawnParams params;
params.sName = clonedItemName.c_str();
params.pClass = attachedItem.pClass;
// Flag as 'No Save' they will be recreated during serialization if needed
params.nFlags |= (ENTITY_FLAG_NO_SAVE);
IEntity *pClonedItemEntity = gEnv->pEntitySystem->SpawnEntity(params);
assert (pClonedItemEntity != NULL);
IItem* pClonedItem = g_pGame->GetIGameFramework()->GetIItemSystem()->GetItem(pClonedItemEntity->GetId());
assert(pClonedItem != NULL);
pClonedItem->Physicalize(false, false);
pClonedItem->SetOwnerId( GetEntityId() );
// Set properties table to null, since they'll not be used
IScriptTable* pClonedItemEntityScript = pClonedItemEntity->GetScriptTable();
if (pClonedItemEntityScript != NULL)
{
pClonedItemEntity->GetScriptTable()->SetToNull("Properties");
}
// Swap attachments
CEntityAttachment* pEntityAttachement = new CEntityAttachment();
pEntityAttachement->SetEntityId( pClonedItemEntity->GetId() );
pAttachment->AddBinding( pEntityAttachement );
return pClonedItemEntity->GetId();
}
示例2: ProcessEvent
//------------------------------------------------------------------------
void CFlowVehicleBase::ProcessEvent(EFlowEvent flowEvent, SActivationInfo* pActivationInfo)
{
if (flowEvent == eFE_SetEntityId)
{
IEntity* pEntity = pActivationInfo->pEntity;
if (pEntity)
{
IVehicleSystem* pVehicleSystem = CCryAction::GetCryAction()->GetIVehicleSystem();
CRY_ASSERT(pVehicleSystem);
if (pEntity->GetId() != m_vehicleId)
{
if (IVehicle* pVehicle = GetVehicle())
pVehicle->UnregisterVehicleEventListener(this);
m_vehicleId = 0;
}
if (IVehicle* pVehicle = pVehicleSystem->GetVehicle(pEntity->GetId()))
{
pVehicle->RegisterVehicleEventListener(this, "FlowVehicleBase");
m_vehicleId = pEntity->GetId();
}
}
else
{
if (IVehicle* pVehicle = GetVehicle())
pVehicle->UnregisterVehicleEventListener(this);
}
}
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:33,代码来源:FlowVehicleBase.cpp
示例3: Update
//------------------------------------------------------------------------
void CVehicleDamageBehaviorBurn::Update(const float deltaTime)
{
m_timeCounter -= deltaTime;
if(m_timeCounter <= 0.0f)
{
CGameRules *pGameRules = g_pGame->GetGameRules();
if(pGameRules && gEnv->bServer)
{
Vec3 worldPos;
if(m_pHelper)
worldPos = m_pHelper->GetWorldSpaceTranslation();
else
worldPos = m_pVehicle->GetEntity()->GetWorldTM().GetTranslation();
SEntityProximityQuery query;
query.box = AABB(worldPos-Vec3(m_radius), worldPos+Vec3(m_radius));
gEnv->pEntitySystem->QueryProximity(query);
IEntity *pEntity = 0;
for(int i = 0; i < query.nCount; ++i)
{
if((pEntity = query.pEntities[i]) && pEntity->GetPhysics())
{
float damage = (pEntity->GetId() == m_pVehicle->GetEntityId()) ? m_selfDamage : m_damage;
// SNH: need to check vertical distance here as the QueryProximity() call seems to work in 2d only
Vec3 pos = pEntity->GetWorldPos();
if(abs(pos.z - worldPos.z) < m_radius)
{
if(damage > 0.f)
{
HitInfo hitInfo;
hitInfo.damage = damage;
hitInfo.pos = worldPos;
hitInfo.radius = m_radius;
hitInfo.targetId = pEntity->GetId();
hitInfo.shooterId = m_shooterId;
hitInfo.weaponId = m_pVehicle->GetEntityId();
hitInfo.type = pGameRules->GetHitTypeId("fire");
pGameRules->ServerHit(hitInfo);
}
}
}
}
if(gEnv->pAISystem)
gEnv->pAISystem->RegisterDamageRegion(this, Sphere(worldPos, m_radius));
}
m_timeCounter = m_interval;
}
m_pVehicle->NeedsUpdate();
}
示例4: ProcessEvent
void CClaymore::ProcessEvent(SEntityEvent &event)
{
if (m_frozen)
return;
switch(event.event)
{
case ENTITY_EVENT_ENTERAREA:
{
IEntity * pEntity = gEnv->pEntitySystem->GetEntity(event.nParam[0]);
IVehicle* pVehicle = NULL;
IActor* pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(event.nParam[0]); // only detonate for actors...
if(!pActor)
pVehicle = g_pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(event.nParam[0]); // ...or vehicles
// ignore actors in vehicles (we detect the vehicle instead)
if(pActor && pActor->GetLinkedVehicle())
pActor = NULL;
// ignore spectators
if(pActor && static_cast<CActor*>(pActor)->GetSpectatorMode() != CActor::eASM_None)
pActor = NULL;
if(pEntity && (pActor || pVehicle))
{
if(g_pGameCVars->g_debugMines != 0)
CryLog("Claymore detected entity: %d, type %s", pEntity->GetId(), pActor == NULL ? "Vehicle" : "Actor");
m_targetList.push_back(pEntity->GetId());
}
break;
}
case ENTITY_EVENT_LEAVEAREA:
{
IEntity * pEntity = gEnv->pEntitySystem->GetEntity(event.nParam[0]);
if(pEntity)
{
std::list<EntityId>::iterator it = std::find(m_targetList.begin(), m_targetList.end(), pEntity->GetId());
if(it != m_targetList.end())
m_targetList.erase(it);
}
break;
}
default:
break;
}
return CProjectile::ProcessEvent(event);
}
示例5: SaveExternalEntity
bool CCheckpointSystem::SaveExternalEntity(EntityId id)
{
//this function allows external logic (flowgraph) to save specific entities
if(!CHECKPOINT_SAVE_XML_NODE)
{
CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "Tried writing external entity %i while savegame was not open.", (int)id);
return false;
}
//find entity and access external section
IEntity *pEntity = gEnv->pEntitySystem->GetEntity(id);
if(pEntity)
{
XmlNodeRef externalEntities = CHECKPOINT_SAVE_XML_NODE->findChild(EXTERNAL_ENTITIES_SECTION);
if(!externalEntities)
{
externalEntities = GetISystem()->CreateXmlNode(EXTERNAL_ENTITIES_SECTION);
CHECKPOINT_SAVE_XML_NODE->addChild(externalEntities);
}
IActor *pActor = CCryAction::GetCryAction()->GetIActorSystem()->GetActor(pEntity->GetId());
if(pActor)
{
CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "The actor %s is additionally saved as external entity.", pEntity->GetName());
}
//create entity data
char entityId[16];
_snprintf(entityId, sizeof(entityId), "%s%i", "id", id);
XmlNodeRef nextEntity = GetISystem()->CreateXmlNode(entityId);
if(nextEntity)
{
nextEntity->setAttr("id", pEntity->GetId());
nextEntity->setAttr("name", pEntity->GetName());
//save active / hidden
nextEntity->setAttr("active", pEntity->IsActive());
nextEntity->setAttr("hidden", pEntity->IsHidden());
//save translation and rotation (complete tm matrix for simplicity)
SerializeWorldTM(pEntity, nextEntity, true);
//add new entity to checkpoint
externalEntities->addChild(nextEntity);
return true;
}
return false;
}
return false;
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:50,代码来源:CheckPointSystem.cpp
示例6: HandleEvent
//------------------------------------------------------------------------
void CRock::HandleEvent(const SGameObjectEvent &event)
{
CProjectile::HandleEvent(event);
if (event.event == eGFE_OnCollision)
{
if (m_destroying)
return;
EventPhysCollision *pCollision = reinterpret_cast<EventPhysCollision *>(event.ptr);
if (!pCollision)
return;
IEntity *pTarget = pCollision->iForeignData[1]==PHYS_FOREIGN_ID_ENTITY ? (IEntity*)pCollision->pForeignData[1]:0;
if (!pTarget || pTarget->GetId()==m_ownerId || pTarget->GetId()==GetEntityId())
return;
Vec3 dir(0, 0, 0);
if (pCollision->vloc[0].GetLengthSquared() > 1e-6f)
dir = pCollision->vloc[0].GetNormalized();
CGameRules *pGameRules = g_pGame->GetGameRules();
HitInfo hitInfo(m_ownerId, pTarget?pTarget->GetId():0, m_weaponId,
m_fmId, 0.0f, pGameRules->GetHitMaterialIdFromSurfaceId(pCollision->idmat[1]), pCollision->partid[1],
pGameRules->GetHitTypeId("melee"), pCollision->pt, dir, pCollision->n);
hitInfo.remote = IsRemote();
hitInfo.projectileId = GetEntityId();
if (!hitInfo.remote)
hitInfo.seq=m_seq;
hitInfo.damage = m_damage;
if (m_weaponId)
{
CWeapon *pWeapon=GetWeapon();
if (pWeapon && pWeapon->GetForcedHitMaterial() != -1)
hitInfo.material=pGameRules->GetHitMaterialIdFromSurfaceId(pWeapon->GetForcedHitMaterial());
}
pGameRules->ClientHit(hitInfo);
if(m_damage>10)
m_damage =(int)(m_damage*0.5f);
}
}
示例7: ProcessEvent
virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
{
ICustomAction* pCustomAction = pActInfo->pGraph->GetCustomAction();
switch ( event )
{
case eFE_Update:
pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false );
if ( pCustomAction && !bAborted )
{
// Abort only once
bAborted = true;
IEntity* pTarget = pCustomAction->GetObjectEntity();
ActivateOutput( pActInfo, 0, pTarget ? pTarget->GetId() : 0 );
}
break;
case eFE_Initialize:
bAborted = false;
pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false );
break;
case eFE_Activate:
if ( !bAborted && pCustomAction && IsPortActive(pActInfo, 0) )
{
pCustomAction->AbortAction();
}
break;
}
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:28,代码来源:FlowCustomActionNodes.cpp
示例8: ProcessHit
//------------------------------------------------------------------------
void CCannonBall::ProcessHit(CGameRules& gameRules, const EventPhysCollision& collision, IEntity& target, float damage, int hitMatId, const Vec3& hitDir)
{
if(damage > 0.f)
{
EntityId targetId = target.GetId();
bool alreadyHit = CheckForPreviousHit(targetId, damage);
if(!alreadyHit)
{
HitInfo hitInfo(m_ownerId ? m_ownerId : m_hostId, targetId, m_weaponId,
damage, 0.0f, hitMatId, collision.partid[1],
m_hitTypeId, collision.pt, hitDir, collision.n);
hitInfo.remote = IsRemote();
hitInfo.projectileId = GetEntityId();
hitInfo.bulletType = m_pAmmoParams->bulletType;
hitInfo.knocksDown = CheckAnyProjectileFlags(ePFlag_knocksTarget) && ( damage > m_minDamageForKnockDown );
hitInfo.knocksDownLeg = m_chanceToKnockDownLeg>0 && damage>m_minDamageForKnockDownLeg && m_chanceToKnockDownLeg>(int)Random(100);
hitInfo.penetrationCount = m_penetrationCount;
hitInfo.hitViaProxy = CheckAnyProjectileFlags(ePFlag_firedViaProxy);
hitInfo.aimed = CheckAnyProjectileFlags(ePFlag_aimedShot);
IPhysicalEntity* pPhysicalEntity = collision.pEntity[1];
if (pPhysicalEntity && pPhysicalEntity->GetType() == PE_ROPE)
{
hitInfo.partId = GetRopeBoneId(collision, target, pPhysicalEntity);
}
gameRules.ClientHit(hitInfo);
ReportHit(targetId);
}
}
}
示例9: HandleEvent
void CTacAlienBullet::HandleEvent(const SGameObjectEvent &event)
{
if (m_destroying)
return;
CProjectile::HandleEvent(event);
if (event.event == eGFE_OnCollision)
{
EventPhysCollision *pCollision = reinterpret_cast<EventPhysCollision *>(event.ptr);
if (!pCollision)
return;
IEntity *pTarget = pCollision->iForeignData[1]==PHYS_FOREIGN_ID_ENTITY ? (IEntity*)pCollision->pForeignData[1]:0;
if (pTarget)
{
EntityId targetId = pTarget->GetId();
CActor* pActor = static_cast<CActor*>(g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(pTarget->GetId()));
if(pActor && pActor->CanSleep())
{
SimpleHitInfo info(m_ownerId, targetId, m_weaponId, 1); // 0=tag,1=tac
info.remote=IsRemote();
g_pGame->GetGameRules()->ClientSimpleHit(info);
}
}
Destroy();
}
}
示例10: CanPickup
int CScriptBind_Boids::CanPickup(IFunctionHandler *pH, SmartScriptTable flockEntity, SmartScriptTable boidEntity)
{
CFlock* flock = GetFlock(flockEntity);
IEntity* pBoidEntity = GetEntity(boidEntity);
if (flock != NULL && pBoidEntity != NULL)
{
CBoidObject* pBoidObject = NULL;
for (int i = 0; i < flock->GetBoidsCount(); ++i)
{
if (flock->GetBoid(i)->GetId() == pBoidEntity->GetId())
{
pBoidObject = flock->GetBoid(i);
break;
}
}
if (pBoidObject != NULL)
{
SBoidContext bc;
flock->GetBoidSettings(bc);
return pH->EndFunction((pBoidObject->IsDead() && bc.bPickableWhenDead) || (!pBoidObject->IsDead() && bc.bPickableWhenAlive));
}
}
return pH->EndFunction(0);
}
示例11: OnPickup
int CScriptBind_Boids::OnPickup(IFunctionHandler *pH, SmartScriptTable flockEntity, SmartScriptTable boidEntity, bool bPickup, float fThrowSpeed)
{
CFlock* flock = GetFlock(flockEntity);
IEntity* pBoidEntity = GetEntity(boidEntity);
if (flock != NULL && pBoidEntity != NULL)
{
CBoidObject* pBoidObject = NULL;
for (int i = 0; i < flock->GetBoidsCount(); ++i)
{
if (flock->GetBoid(i)->GetId() == pBoidEntity->GetId())
{
pBoidObject = flock->GetBoid(i);
break;
}
}
if (pBoidObject != NULL)
{
pBoidObject->OnPickup(bPickup, fThrowSpeed);
}
}
return pH->EndFunction();
}
示例12: AttachToCharacter
bool CStickyProjectile::AttachToCharacter(CProjectile* pProjectile, IEntity& pEntity, ICharacterInstance& pCharacter, const char* boneName)
{
IEntity* pProjectileEntity = pProjectile->GetEntity();
char attachName[16] = "";
sprintf(attachName, "StickyProj_%d", s_attachNameID++);
IAttachment* pCharacterAttachment = pCharacter.GetIAttachmentManager()->CreateAttachment(attachName, CA_BONE, boneName, false);
if(!pCharacterAttachment)
{
CryLogAlways("Could not create attachment for StickyProjectile[%s]. AttachmentName[%s] BoneName[%s]", pProjectileEntity->GetName(), attachName, boneName );
CRY_ASSERT_MESSAGE(pCharacterAttachment, "Could not create attachment for StickyProjectile. This must be fixed.");
return false;
}
m_characterAttachmentCrC = pCharacterAttachment->GetNameCRC();
SetProjectilePhysics(pProjectile, ePT_None);
pCharacterAttachment->SetAttRelativeDefault(QuatT(m_stuckRot, m_stuckPos));
CEntityAttachment *pEntityAttachment = new CEntityAttachment();
pEntityAttachment->SetEntityId(pProjectileEntity->GetId());
pCharacterAttachment->AddBinding(pEntityAttachment);
return true;
}
示例13: CreateLaserEntity
IEntity* CLaserBeam::CreateLaserEntity()
{
IEntity* pLaserEntity = gEnv->pEntitySystem->GetEntity(m_laserEntityId);
if (pLaserEntity)
return pLaserEntity;
IEntity* pOwnerEntity = gEnv->pEntitySystem->GetEntity(m_ownerEntityId);
if (!pOwnerEntity)
return 0;
SEntitySpawnParams spawnParams;
spawnParams.pClass = gEnv->pEntitySystem->GetClassRegistry()->GetDefaultClass();
spawnParams.sName = "LaserBeam";
spawnParams.nFlags = (pOwnerEntity->GetFlags() | ENTITY_FLAG_NO_SAVE) & ~ENTITY_FLAG_CASTSHADOW;
IEntity* pNewEntity = gEnv->pEntitySystem->SpawnEntity(spawnParams);
if(pNewEntity)
{
m_laserEntityId = pNewEntity->GetId();
IEntityRenderProxy *pRenderProxy = (IEntityRenderProxy*)pNewEntity->GetProxy(ENTITY_PROXY_RENDER);
IRenderNode * pRenderNode = pRenderProxy?pRenderProxy->GetRenderNode():NULL;
if(pRenderNode)
pRenderNode->SetRndFlags(ERF_RENDER_ALWAYS,true);
SetLaserEntitySlots(false);
}
return pNewEntity;
}
示例14: OnIterStart
virtual void OnIterStart(SActivationInfo *pActInfo)
{
const int type = GetPortInt(pActInfo, EIP_Type);
IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
if (pEntitySystem)
{
IEntityItPtr iter = pEntitySystem->GetEntityIterator();
if (iter)
{
iter->MoveFirst();
IEntity *pEntity = NULL;
while (!iter->IsEnd())
{
pEntity = iter->Next();
if (pEntity)
{
const EntityId id = pEntity->GetId();
const EEntityType entityType = GetEntityType(id);
if (IsValidType(type, entityType))
{
AddEntity(id);
}
}
}
}
}
}
示例15: HandleEvent
void CTagBullet::HandleEvent(const SGameObjectEvent &event)
{
if (m_destroying)
{
return;
}
CProjectile::HandleEvent(event);
if (event.event == eGFE_OnCollision)
{
EventPhysCollision *pCollision = reinterpret_cast<EventPhysCollision *>(event.ptr);
if (!pCollision)
{
return;
}
IEntity *pTarget = pCollision->iForeignData[1] == PHYS_FOREIGN_ID_ENTITY ? (IEntity *)pCollision->pForeignData[1] : 0;
if (pTarget)
{
EntityId targetId = pTarget->GetId();
SimpleHitInfo info(m_ownerId, targetId, m_weaponId, 0); // 0=tag,1=tac
info.remote = IsRemote();
g_pGame->GetGameRules()->ClientSimpleHit(info);
}
Destroy();
}
}