本文整理汇总了C++中IEntityItPtr::MoveFirst方法的典型用法代码示例。如果您正苦于以下问题:C++ IEntityItPtr::MoveFirst方法的具体用法?C++ IEntityItPtr::MoveFirst怎么用?C++ IEntityItPtr::MoveFirst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEntityItPtr
的用法示例。
在下文中一共展示了IEntityItPtr::MoveFirst方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
}
}
}
}
示例2: DeleteDynamicEntities
void CCheckpointSystem::DeleteDynamicEntities()
{
IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
IEntityItPtr pIt = pEntitySystem->GetEntityIterator();
//////////////////////////////////////////////////////////////////////////
pIt->MoveFirst();
while (!pIt->IsEnd())
{
IEntity * pEntity = pIt->Next();
uint32 nEntityFlags = pEntity->GetFlags();
// Local player must not be deleted.
if (nEntityFlags & ENTITY_FLAG_LOCAL_PLAYER)
continue;
if (nEntityFlags & ENTITY_FLAG_SPAWNED)
pEntitySystem->RemoveEntity( pEntity->GetId() );
}
// Force deletion of removed entities.
pEntitySystem->DeletePendingEntities();
//////////////////////////////////////////////////////////////////////////
// Reset entity pools
pEntitySystem->GetIEntityPoolManager()->ResetPools(false);
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:25,代码来源:CheckPointSystem.cpp
示例3: OnSysSpecLightChange
// for editor only
static void OnSysSpecLightChange( ICVar *pVar )
{
IEntityItPtr it = GetIEntitySystem()->GetEntityIterator();
it->MoveFirst();
while(IEntity *pEntity = it->Next())
{
IScriptTable *pScriptTable = pEntity->GetScriptTable();
if (pScriptTable && pScriptTable->HaveValue("OnSysSpecLightChanged"))
{
Script::CallMethod( pScriptTable, "OnSysSpecLightChanged" );
}
}
}
示例4: DumpEntityClassesInUse
void CVar::DumpEntityClassesInUse(IConsoleCmdArgs * args)
{
IEntityItPtr it = GetIEntitySystem()->GetEntityIterator();
it->MoveFirst();
std::map<string, int> classes;
while(IEntity *pEntity = it->Next())
{
classes[pEntity->GetClass()->GetName()]++;
}
CryLogAlways("--------------------------------------------------------------------------------");
for (std::map<string, int>::iterator iter = classes.begin(); iter != classes.end(); ++iter)
CryLogAlways("%s: %d instances", iter->first.c_str(), iter->second);
}
示例5: GetEntitiesByClasses
mono::object CScriptbind_Entity::GetEntitiesByClasses(mono::object classes)
{
IMonoArray *pClassArray = *classes;
int numClasses = pClassArray->GetSize();
IEntityClass **pClasses = new IEntityClass *[numClasses];
for(int i = 0; i < numClasses; i++)
pClasses[i] = gEnv->pEntitySystem->GetClassRegistry()->FindClass(ToCryString((mono::string)pClassArray->GetManagedObject()));
IEntityItPtr pIt = gEnv->pEntitySystem->GetEntityIterator();
IMonoClass *pEntityIdClass = GetMonoScriptSystem()->GetCryBraryAssembly()->GetClass("EntityId");
IMonoArray *pEntities = CreateDynamicMonoArray();
pIt->MoveFirst();
while(!pIt->IsEnd())
{
if(IEntity *pEntity = pIt->Next())
{
IEntityClass *pEntityClass = pEntity->GetClass();
for(int i = 0; i < numClasses; i++)
{
if(pEntityClass == pClasses[i])
{
pEntities->InsertMonoObject(pEntityIdClass->BoxObject(&mono::entityId(pEntity->GetId())));
break;
}
}
}
}
auto result = pEntities->GetManagedObject();
pEntities->Release();
return result;
}
示例6: GetEntitiesByClass
mono::object CScriptbind_Entity::GetEntitiesByClass(mono::string _class)
{
IEntityClass *pDesiredClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(ToCryString(_class));
IEntityItPtr pIt = gEnv->pEntitySystem->GetEntityIterator();
IMonoClass *pEntityIdClass = GetMonoScriptSystem()->GetCryBraryAssembly()->GetClass("EntityId");
IMonoArray *pEntities = CreateDynamicMonoArray();
pIt->MoveFirst();
while(!pIt->IsEnd())
{
if(IEntity *pEntity = pIt->Next())
{
if(pEntity->GetClass() == pDesiredClass)
pEntities->InsertMonoObject(pEntityIdClass->BoxObject(&mono::entityId(pEntity->GetId())));
}
}
auto result = pEntities->GetManagedObject();
pEntities->Release();
return result;
}
示例7: OnPromoteToServer
//------------------------------------------------------------------------
bool CGameRules::OnPromoteToServer(SHostMigrationInfo& hostMigrationInfo, uint32& state)
{
if (!g_pGame->GetIGameFramework()->ShouldMigrateNub(hostMigrationInfo.m_session))
{
return true;
}
CryLogAlways("[Host Migration]: CGameRules::OnPromoteToServer() started");
// Server time will change after we migrate (change from old server time to new server time)
m_gameStartedTime.SetValue(m_gameStartedTime.GetValue() - m_cachedServerTime.GetValue());
m_gameStartTime.SetValue(m_gameStartTime.GetValue() - m_cachedServerTime.GetValue());
// If this migration has reset (we're not the original anticipated host, remove any entities from the first attempt
if (!m_hostMigrationCachedEntities.empty())
{
HostMigrationRemoveDuplicateDynamicEntities();
}
// Now we know we're the server, remove the actors for anyone we know isn't going to migrate
CGameLobby *pGameLobby = g_pGame->GetGameLobby();
CRY_ASSERT(pGameLobby);
if (pGameLobby)
{
TPlayers playersToRemove;
IActorSystem *pActorSystem = g_pGame->GetIGameFramework()->GetIActorSystem();
playersToRemove.reserve(pActorSystem->GetActorCount());
IActorIteratorPtr actorIt = pActorSystem->CreateActorIterator();
IActor *pActor;
while (pActor = actorIt->Next())
{
if (pActor->IsPlayer())
{
CRY_ASSERT(pActor->GetChannelId());
SCryMatchMakingConnectionUID conId = pGameLobby->GetConnectionUIDFromChannelID((int) pActor->GetChannelId());
if (pGameLobby->GetSessionNames().Find(conId) == SSessionNames::k_unableToFind)
{
CryLog(" player '%s' has not got a corresponding CGameLobby entry, removing actor", pActor->GetEntity()->GetName());
playersToRemove.push_back(pActor->GetEntityId());
}
}
}
const int numPlayersToRemove = playersToRemove.size();
for (int i = 0; i < numPlayersToRemove; ++ i)
{
FakeDisconnectPlayer(playersToRemove[i]);
}
}
for (uint32 i = 0; i < MAX_PLAYERS; ++ i)
{
m_migratedPlayerChannels[i] = 0;
}
IItemSystem *pItemSystem = g_pGame->GetIGameFramework()->GetIItemSystem();
IEntityItPtr it = gEnv->pEntitySystem->GetEntityIterator();
it->MoveFirst();
for (uint32 i = 0; i < m_hostMigrationItemMaxCount; ++ i)
{
m_pHostMigrationItemInfo[i].Reset();
}
uint32 itemIndex = 0;
IEntity *pEntity = NULL;
while (pEntity = it->Next())
{
IItem *pItem = pItemSystem->GetItem(pEntity->GetId());
if (pItem)
{
if (pItem->GetOwnerId())
{
IEntity *pOwner = gEnv->pEntitySystem->GetEntity(pItem->GetOwnerId());
if (pOwner)
{
EntityId currentItemId = 0;
IActor *pOwnerActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(pOwner->GetId());
if (pOwnerActor)
{
IItem *pCurrentItem = pOwnerActor->GetCurrentItem();
currentItemId = pCurrentItem ? pCurrentItem->GetEntityId() : 0;
}
CryLog("[CG] Item '%s' is owned by '%s'", pEntity->GetName(), pOwner->GetName());
//m_pHostMigrationItemInfo[itemIndex].Set(pEntity->GetId(), pOwner->GetId(), pItem->IsUsed(), (pItem->GetEntityId() == currentItemId));
itemIndex ++;
if (itemIndex >= m_hostMigrationItemMaxCount)
{
CRY_ASSERT(itemIndex < m_hostMigrationItemMaxCount);
break;
}
}
}
//.........这里部分代码省略.........
示例8: OnPromoteToServer
//------------------------------------------------------------------------
bool CGameRules::OnPromoteToServer(SHostMigrationInfo &hostMigrationInfo, uint32 &state)
{
if (!g_pGame->GetIGameFramework()->ShouldMigrateNub(hostMigrationInfo.m_session))
{
return true;
}
CryLogAlways("[Host Migration]: CGameRules::OnPromoteToServer() started");
// Server time will change after we migrate (change from old server time to new server time)
m_gameStartedTime.SetValue(m_gameStartedTime.GetValue() - m_cachedServerTime.GetValue());
m_gameStartTime.SetValue(m_gameStartTime.GetValue() - m_cachedServerTime.GetValue());
// If this migration has reset (we're not the original anticipated host, remove any entities from the first attempt
if (!m_hostMigrationCachedEntities.empty())
{
HostMigrationRemoveDuplicateDynamicEntities();
}
for (uint32 i = 0; i < MAX_PLAYERS; ++ i)
{
m_migratedPlayerChannels[i] = 0;
}
IEntityItPtr it = gEnv->pEntitySystem->GetEntityIterator();
it->MoveFirst();
for (uint32 i = 0; i < m_hostMigrationItemMaxCount; ++ i)
{
m_pHostMigrationItemInfo[i].Reset();
}
uint32 itemIndex = 0;
IEntity *pEntity = NULL;
// Tell entities that we're host migrating
// - Currently only used by ForbiddenArea but may well be needed for other entities later
// - Currently only called on the new server, add to OnDemoteToClient if we need to use this on a client
IScriptTable *pScript = pEntity->GetScriptTable();
if (pScript != NULL && pScript->GetValueType("OnHostMigration") == svtFunction)
{
m_pScriptSystem->BeginCall(pScript, "OnHostMigration");
m_pScriptSystem->PushFuncParam(pScript);
m_pScriptSystem->PushFuncParam(true);
m_pScriptSystem->EndCall();
}
// This needs initialising on the new server otherwise the respawn timer will be counting down
// from uninitialised data. Likewise for the pre-round timer.
ResetReviveCycleTime();
// the server does not listen for entity_event_done, clients do however, when we migrate
// the new server needs to remove any of these events he may be listening for
TEntityTeamIdMap::iterator entityTeamsIt = m_entityteams.begin();
for (; entityTeamsIt != m_entityteams.end(); ++ entityTeamsIt)
{
EntityId entityId = entityTeamsIt->first;
RemoveEntityEventDoneListener(entityId);
#if !defined(_RELEASE)
IEntity *pTeamEntity = gEnv->pEntitySystem->GetEntity(entityId);
CryLog("[GameRules] OnPromoteToServer RemoveEntityEventLister(%d(%s), ENTITY_EVENT_DONE, %p)", entityId,
pTeamEntity ? pTeamEntity->GetName() : "null",
this);
#endif
}
ClearRemoveEntityEventListeners();
const int numRespawnParams = m_respawndata.size();
for (int i = 0; i < numRespawnParams; ++ i)
{
SEntityRespawnData *pData = &m_respawndata[i];
pEntity = gEnv->pEntitySystem->GetEntity(pData->m_currentEntityId);
if (pEntity == NULL)
{
CryLog(" detected respawn entity (id=%u) is not present, scheduling for respawn", pData->m_currentEntityId);
ScheduleEntityRespawn(pData->m_currentEntityId, false, g_pGameCVars->g_defaultItemRespawnTimer);
}
}
CryLog("[Host Migration]: CGameRules::OnPromoteToServer() finished");
CCCPOINT(HostMigration_OnPromoteToServer);
return true;
}