本文整理汇总了C++中IEntitySystem::GetEntity方法的典型用法代码示例。如果您正苦于以下问题:C++ IEntitySystem::GetEntity方法的具体用法?C++ IEntitySystem::GetEntity怎么用?C++ IEntitySystem::GetEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEntitySystem
的用法示例。
在下文中一共展示了IEntitySystem::GetEntity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckObjectViewDist
bool CVisibleObjectsHelper::CheckObjectViewDist(const Agent& agent, const SVisibleObject &visibleObject) const
{
FUNCTION_PROFILER(GetISystem(), PROFILE_GAME);
assert(agent.IsValid());
bool bInViewDist = true;
IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
assert(pEntitySystem);
IEntity *pAIEntity = pEntitySystem->GetEntity(agent.GetEntityID());
IEntity *pObjectEntity = pEntitySystem->GetEntity(visibleObject.entityId);
IComponentRender *pObjectRenderProxy = (pAIEntity != NULL && pObjectEntity ? static_cast<IComponentRender *>(pObjectEntity->GetComponent<IComponentRender>().get()) : NULL);
if (pObjectRenderProxy != NULL)
{
IRenderNode *pObjectRenderNode = pObjectRenderProxy->GetRenderNode();
if (pObjectRenderNode != NULL)
{
const float fDistanceSq = pAIEntity->GetWorldPos().GetSquaredDistance(pObjectEntity->GetWorldPos());
const float fMaxViewDistSq = sqr(pObjectRenderNode->GetMaxViewDist());
bInViewDist = (fDistanceSq <= fMaxViewDistSq);
}
}
return bInViewDist;
}
示例2: FindPrev
//------------------------------------------------------------------------
int CInventory::FindPrev(IEntityClass *pClass, const char *category, int firstSlot, bool wrap) const
{
IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
for (int i = (firstSlot > -1)?firstSlot+1:0; i < m_stats.slots.size(); i++)
{
IEntity *pEntity = pEntitySystem->GetEntity(m_stats.slots[firstSlot-i]);
bool ok=true;
if (pEntity->GetClass() != pClass)
ok=false;
if (ok && category && category[0] && strcmp(m_pGameFrameWork->GetIItemSystem()->GetItemCategory(pEntity->GetClass()->GetName()), category))
ok=false;
if (ok)
return i;
}
if (wrap && firstSlot > 0)
{
int count = GetCount();
for (int i = 0; i < firstSlot; i++)
{
IEntity *pEntity = pEntitySystem->GetEntity(m_stats.slots[count-i+firstSlot]);
bool ok=true;
if (pEntity->GetClass() != pClass)
ok=false;
if (ok && category && category[0] && strcmp(m_pGameFrameWork->GetIItemSystem()->GetItemCategory(pEntity->GetClass()->GetName()), category))
ok=false;
if (ok)
return i;
}
}
return -1;
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:36,代码来源:Inventory.cpp
示例3: OnHit
//CGameRules::IHitInfo
virtual void OnHit(const HitInfo &hitInfo)
{
if(GetPortBool(&m_actInfo, EIP_Enable) == false)
return;
EntityId shooter = GetPortEntityId(&m_actInfo, EIP_ShooterId);
if(shooter != 0 && shooter != hitInfo.shooterId)
return;
EntityId target = GetPortEntityId(&m_actInfo, EIP_TargetId);
if(target != 0 && target != hitInfo.targetId)
return;
IEntitySystem *pEntitySys = gEnv->pEntitySystem;
IEntity *pTempEntity;
// check weapon match
const string &weapon = GetPortString(&m_actInfo, EIP_Weapon);
if(weapon.empty() == false)
{
pTempEntity = pEntitySys->GetEntity(hitInfo.weaponId);
if(pTempEntity == 0 || weapon.compare(pTempEntity->GetClass()->GetName()) != 0)
return;
}
// check ammo match
const string &ammo = GetPortString(&m_actInfo, EIP_Ammo);
if(ammo.empty() == false)
{
pTempEntity = pEntitySys->GetEntity(hitInfo.projectileId);
if(pTempEntity == 0 || ammo.compare(pTempEntity->GetClass()->GetName()) != 0)
return;
}
ActivateOutput(&m_actInfo, EOP_ShooterId, hitInfo.shooterId);
ActivateOutput(&m_actInfo, EOP_TargetId, hitInfo.targetId);
ActivateOutput(&m_actInfo, EOP_WeaponId, hitInfo.weaponId);
ActivateOutput(&m_actInfo, EOP_ProjectileId, hitInfo.projectileId);
ActivateOutput(&m_actInfo, EOP_HitPos, hitInfo.pos);
ActivateOutput(&m_actInfo, EOP_HitDir, hitInfo.dir);
ActivateOutput(&m_actInfo, EOP_HitNormal, hitInfo.normal);
ActivateOutput(&m_actInfo, EOP_Damage, hitInfo.damage);
ISurfaceType *pSurface = g_pGame->GetGameRules()->GetHitMaterial(hitInfo.material);
ActivateOutput(&m_actInfo, EOP_Material, string(pSurface ? pSurface->GetName() : ""));
const char *hitType = "";
if(CGameRules *pGR = g_pGame->GetGameRules())
hitType = pGR->GetHitType(hitInfo.type);
ActivateOutput(&m_actInfo, EOP_HitType, string(hitType));
}
示例4: Validate
//------------------------------------------------------------------------
int CInventory::Validate()
{
TInventoryVector copyOfSlots;
copyOfSlots.reserve(m_stats.slots.size());
std::swap(copyOfSlots, m_stats.slots);
int count = 0;
const int slotCount = copyOfSlots.size();
IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
for (int i = 0; i < slotCount; ++i)
{
EntityId itemId = copyOfSlots[i];
IEntity *pEntity = pEntitySystem->GetEntity(itemId);
if (!pEntity)
{
++count;
}
else
{
m_stats.slots.push_back(itemId);
}
}
return count;
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:27,代码来源:Inventory.cpp
示例5: GetPlayerList
int CScriptBind_Action::GetPlayerList( IFunctionHandler *pH )
{
CGameServerNub * pNub = m_pCryAction->GetGameServerNub();
if (!pNub)
{
GameWarning("No game server nub");
return pH->EndFunction();
}
TServerChannelMap *playerMap = m_pCryAction->GetGameServerNub()->GetServerChannelMap();
if (!playerMap)
return pH->EndFunction();
IEntitySystem *pES = gEnv->pEntitySystem;
int k=1;
SmartScriptTable playerList(m_pSS);
for (TServerChannelMap::iterator it = playerMap->begin(); it != playerMap->end(); it++)
{
EntityId playerId = it->second->GetPlayerId();
if (!playerId)
continue;
IEntity *pPlayer = pES->GetEntity(playerId);
if (!pPlayer)
continue;
if (pPlayer->GetScriptTable())
playerList->SetAt(k++, pPlayer->GetScriptTable());
}
return pH->EndFunction(*playerList);
}
示例6: DetachEntity
//------------------------------------------------------------------------
bool CVehicleActionEntityAttachment::DetachEntity()
{
IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
assert(pEntitySystem);
if(IEntity *pEntity = pEntitySystem->GetEntity(m_entityId))
{
IVehicleSystem *pVehicleSystem = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem();
assert(pVehicleSystem);
// FIXME: remove this workaround, replace by e.g. buddy constraint
if(IVehicle *pVehicle = pVehicleSystem->GetVehicle(m_entityId))
{
int hitType = g_pGame->GetGameRules()->GetHitTypeId("disableCollisions");
pVehicle->OnHit(m_pVehicle->GetEntityId(), m_pVehicle->GetEntityId(), 10.0f, Vec3(0.0f, 0.0f, 0.0f), 0.0f, hitType, false);
}
pEntity->DetachThis();
m_isAttached = false;
m_timer = g_parachuteTimeMax;
m_pVehicle->SetObjectUpdate(this, IVehicle::eVOU_AlwaysUpdate);
return true;
}
return false;
}
示例7: GetCountOfClass
//------------------------------------------------------------------------
int CInventory::GetCountOfClass(const char *className) const
{
int count = 0;
IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
IEntityClass* pClass = (className != NULL) ? pEntitySystem->GetClassRegistry()->FindClass( className ) : NULL;
if (pClass)
{
for (TInventoryCIt it = m_stats.slots.begin(); it != m_stats.slots.end(); ++it)
{
IEntity *pEntity = pEntitySystem->GetEntity(*it);
if ((pEntity != NULL) && (pEntity->GetClass() == pClass))
{
++count;
}
}
TInventoryVectorEx::const_iterator endEx = m_stats.accessorySlots.end();
for (TInventoryVectorEx::const_iterator cit = m_stats.accessorySlots.begin(); cit!=endEx; ++cit)
{
if (*cit == pClass)
{
count++;
}
}
}
return count;
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:30,代码来源:Inventory.cpp
示例8: GetEntityType
EEntityType GetEntityType(EntityId id)
{
int type = eET_Unknown;
IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
if (pEntitySystem)
{
IEntity *pEntity = pEntitySystem->GetEntity(id);
if (pEntity)
{
type = eET_Valid;
IEntityClass *pClass = pEntity->GetClass();
if (pClass)
{
const char* className = pClass->GetName();
// Check AI
if (pEntity->GetAI())
{
type |= eET_AI;
}
// Check actor
IActorSystem *pActorSystem = gEnv->pGame->GetIGameFramework()->GetIActorSystem();
if (pActorSystem)
{
IActor *pActor = pActorSystem->GetActor(id);
if (pActor)
{
type |= eET_Actor;
}
}
// Check vehicle
IVehicleSystem *pVehicleSystem = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem();
if (pVehicleSystem)
{
if (pVehicleSystem->IsVehicleClass(className))
{
type |= eET_Vehicle;
}
}
// Check item
IItemSystem *pItemSystem = gEnv->pGame->GetIGameFramework()->GetIItemSystem();
if (pItemSystem)
{
if (pItemSystem->IsItemClass(className))
{
type |= eET_Item;
}
}
}
}
}
return (EEntityType)type;
}
示例9: ProcessEvent
virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
{
switch (event)
{
case eFE_Initialize:
m_errorLogSent = false;
break;
case eFE_Activate:
if (IsPortActive(pActInfo, 0))
{
IEntitySystem* pESys = gEnv->pEntitySystem;
EntityId id1 = GetPortEntityId(pActInfo, 1);
EntityId id2 = GetPortEntityId(pActInfo, 2);
IEntity* pEnt1 = pESys->GetEntity( id1 );
IEntity* pEnt2 = pESys->GetEntity( id2 );
IEntity* pGraphEntity = pESys->GetEntity( pActInfo->pGraph->GetGraphEntity( 0 ) );
if (pEnt1==NULL || pEnt2==NULL)
{
if (!m_errorLogSent)
{
GameWarning("[flow] Entity::EntitiesInRange - flowgraph entity: %d:'%s' - at least one of the input entities is invalid!. Entity1: %d:'%s' Entity2: %d:'%s'",
pActInfo->pGraph->GetGraphEntity( 0 ), pGraphEntity ? pGraphEntity->GetName() : "<NULL>",
id1, pEnt1 ? pEnt1->GetName() : "<NULL>", id2, pEnt2 ? pEnt2->GetName() : "<NULL>" );
m_errorLogSent = true;
}
}
else
{
const float range = GetPortFloat(pActInfo, 3);
const float distance = pEnt1->GetWorldPos().GetDistance(pEnt2->GetWorldPos()) ;
const bool inRange = (distance <= range);
ActivateOutput(pActInfo, 0, inRange);
ActivateOutput(pActInfo, 1 + (inRange ? 1 : 0), true);
ActivateOutput(pActInfo, 3, distance);
const Vec3 distVector = pEnt2->GetPos() - pEnt1->GetPos();
ActivateOutput(pActInfo, 4, distVector);
m_errorLogSent = false;
}
}
break;
}
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:44,代码来源:EntitiesInRangeNode.cpp
示例10: ExecuteAI
bool CDialogActorContext::ExecuteAI(int& goalPipeID, const char* signalText, IAISignalExtraData* pExtraData, bool bRegisterAsListener)
{
IEntitySystem* pSystem = gEnv->pEntitySystem;
IEntity* pEntity = pSystem->GetEntity(m_entityID);
if (pEntity == 0)
return false;
IAIObject* pAI = pEntity->GetAI();
if (pAI == 0)
return false;
unsigned short nType=pAI->GetAIType();
if ( nType != AIOBJECT_ACTOR )
{
if ( nType == AIOBJECT_PLAYER )
{
goalPipeID = -1;
// not needed for player
// pAI->SetSignal( 10, signalText, pEntity, NULL ); // 10 means this signal must be sent (but sent[!], not set)
// even if the same signal is already present in the queue
return true;
}
// invalid AIObject type
return false;
}
IPipeUser* pPipeUser = pAI->CastToIPipeUser();
if (pPipeUser)
{
if (goalPipeID > 0)
{
pPipeUser->RemoveSubPipe(goalPipeID, true);
pPipeUser->UnRegisterGoalPipeListener( this, goalPipeID );
goalPipeID = 0;
}
}
goalPipeID = gEnv->pAISystem->AllocGoalPipeId();
if (pExtraData == 0)
pExtraData = gEnv->pAISystem->CreateSignalExtraData();
pExtraData->iValue = goalPipeID;
if (pPipeUser && bRegisterAsListener)
{
pPipeUser->RegisterGoalPipeListener( this, goalPipeID, "CDialogActorContext::ExecuteAI");
}
IAIActor* pAIActor = CastToIAIActorSafe(pAI);
if(pAIActor)
pAIActor->SetSignal( 10, signalText, pEntity, pExtraData ); // 10 means this signal must be sent (but sent[!], not set)
// even if the same signal is already present in the queue
return true;
}
示例11: OnExplosion
virtual void OnExplosion(const ExplosionInfo &explosionInfo)
{
if(GetPortBool(&m_actInfo, EIP_Enable) == false)
return;
EntityId shooter = GetPortEntityId(&m_actInfo, EIP_ShooterId);
if(shooter != 0 && shooter != explosionInfo.shooterId)
return;
EntityId impactTarget = GetPortEntityId(&m_actInfo, EIP_ImpactTargetId);
if(impactTarget != 0 && explosionInfo.impact && impactTarget != explosionInfo.impact_targetId)
return;
IEntitySystem *pEntitySys = gEnv->pEntitySystem;
IEntity *pTempEntity = pEntitySys->GetEntity(explosionInfo.weaponId);
// check ammo match
const string &ammo = GetPortString(&m_actInfo, EIP_Ammo);
if(ammo.empty() == false)
{
if(pTempEntity == 0 || ammo.compare(pTempEntity->GetClass()->GetName()) != 0)
return;
}
string ammoClass = pTempEntity ? pTempEntity->GetClass()->GetName() : "";
ActivateOutput(&m_actInfo, EOP_ShooterId, explosionInfo.shooterId);
ActivateOutput(&m_actInfo, EOP_Ammo, ammoClass);
ActivateOutput(&m_actInfo, EOP_Pos, explosionInfo.pos);
ActivateOutput(&m_actInfo, EOP_Dir, explosionInfo.dir);
ActivateOutput(&m_actInfo, EOP_Radius, explosionInfo.radius);
ActivateOutput(&m_actInfo, EOP_Damage, explosionInfo.damage);
ActivateOutput(&m_actInfo, EOP_Pressure, explosionInfo.pressure);
ActivateOutput(&m_actInfo, EOP_HoleSize, explosionInfo.hole_size);
const char *hitType = 0;
if(CGameRules *pGR = g_pGame->GetGameRules())
hitType = pGR->GetHitType(explosionInfo.type);
hitType = hitType ? hitType : "";
ActivateOutput(&m_actInfo, EOP_Type, string(hitType));
if(explosionInfo.impact)
{
ActivateOutput(&m_actInfo, EOP_ImpactTargetId, explosionInfo.impact_targetId);
ActivateOutput(&m_actInfo, EOP_ImpactNormal, explosionInfo.impact_normal);
ActivateOutput(&m_actInfo, EOP_ImpactVelocity, explosionInfo.impact_velocity);
}
}
示例12: GetItemByName
//------------------------------------------------------------------------
IItem* CInventory::GetItemByName(const char* name) const
{
if (!name)
return 0;
IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
TInventoryCIt end = m_stats.slots.end();
for (TInventoryCIt it = m_stats.slots.begin(); it != end; ++it)
{
if (IEntity *pEntity = pEntitySystem->GetEntity(*it))
if (!strcmp(pEntity->GetName(),name))
return gEnv->pGame->GetIGameFramework()->GetIItemSystem()->GetItem(pEntity->GetId());
}
return 0;
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:18,代码来源:Inventory.cpp
示例13: GetItemByClass
//------------------------------------------------------------------------
EntityId CInventory::GetItemByClass(IEntityClass* pClass, IItem *pIgnoreItem) const
{
if (!pClass)
return 0;
IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
TInventoryCIt end = m_stats.slots.end();
for (TInventoryCIt it = m_stats.slots.begin(); it != end; ++it)
{
if (IEntity *pEntity = pEntitySystem->GetEntity(*it))
if (pEntity->GetClass() == pClass)
if(!pIgnoreItem || pIgnoreItem->GetEntity() != pEntity)
return *it;
}
return 0;
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:19,代码来源:Inventory.cpp
示例14: Update
//------------------------------------------------------------------------
void CVehicleActionEntityAttachment::Update(const float deltaTime)
{
if(m_isAttached)
return;
IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
assert(pEntitySystem);
IEntity *pEntity = pEntitySystem->GetEntity(m_entityId);
if(!pEntity)
return;
IPhysicalEntity *pPhysEntity = pEntity->GetPhysics();
if(!pPhysEntity)
return;
pe_simulation_params paramsSim;
float gravity;
if(pPhysEntity->GetParams(¶msSim))
gravity = abs(paramsSim.gravity.z);
else
gravity = 9.82f;
pe_status_dynamics dyn;
if(pPhysEntity->GetStatus(&dyn))
{
pe_action_impulse impulse;
impulse.impulse = Matrix33(pEntity->GetWorldTM()) * Vec3(0.0f, 0.0f, 1.0f) * g_parachuteForce * gravity;
impulse.impulse = impulse.impulse - dyn.v;
impulse.impulse *= dyn.mass * deltaTime;
impulse.iSource = 3;
pPhysEntity->Action(&impulse);
}
m_timer -= deltaTime;
if(m_timer <= 0.0f || dyn.v.z >= 0.0f)
m_pVehicle->SetObjectUpdate(this, IVehicle::eVOU_NoUpdate);
}
示例15: GetEntityAtIndex
/// Utility function for getting the entity at the index
/// outEntity contains the entity if one could be found at the given index, otherwise NULL
/// bPrepareFromPool is used to specify if the entity at the given index should be prepared from the pool if needed
/// NOTE: Index -1 is special case for camera entity.
/// Returns: True if there was an entityId specified at this index. Note you can still have a NULL outEntity even if true, indicating error.
bool CFlowNode_FeatureTest::GetEntityAtIndex(int index, IEntity *&outEntity, bool bPrepareFromPool)
{
IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
CRY_ASSERT(pEntitySystem);
//IEntityPoolManager *pEntityPoolManager = pEntitySystem->GetIEntityPoolManager();
//CRY_ASSERT(pEntityPoolManager);
outEntity = NULL;
bool bHasEntry = false;
if(index >= -1 && index < SEQ_ENTITY_COUNT)
{
EntityId id = GetPortEntityId(&m_actInfo, int(SEQ_ENTITY_FIRST_INPUT_PORT + index));
if(id)
{
bHasEntry = true;
outEntity = pEntitySystem->GetEntity(id);
// Prepare entity from pool if needed
/*if (!outEntity && bPrepareFromPool && pEntityPoolManager->IsEntityBookmarked(id))
{
if (pEntityPoolManager->PrepareFromPool(id, true))
{
outEntity = pEntitySystem->GetEntity(id);
}
if (!outEntity)
{
CryLogAlways("Error: Test \"%s\" failed to prepare entity with id \'%u\' from the pool", Name(), id);
}
}*/
}
}
return bHasEntry;
}