本文整理汇总了C++中Layer::GetEntityCount方法的典型用法代码示例。如果您正苦于以下问题:C++ Layer::GetEntityCount方法的具体用法?C++ Layer::GetEntityCount怎么用?C++ Layer::GetEntityCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Layer
的用法示例。
在下文中一共展示了Layer::GetEntityCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
/// Update all worlds for the current frame.
void WorldManager::Update()
{
// Update the world time.
UpdateTime();
// Perform the entity pre-update.
m_updatePhase = UPDATE_PHASE_PRE;
{
JobContext::Spawner< 1 > entityUpdateSpawner;
JobContext* pContext = entityUpdateSpawner.Allocate();
HELIUM_ASSERT( pContext );
WorldManagerUpdate< EntityPreUpdate >* pJob = pContext->Create< WorldManagerUpdate< EntityPreUpdate > >();
HELIUM_ASSERT( pJob );
WorldManagerUpdate< EntityPreUpdate >::Parameters& rParameters = pJob->GetParameters();
rParameters.pspWorlds = m_worlds.GetData();
rParameters.worldCount = m_worlds.GetSize();
}
// Perform the entity post-update.
m_updatePhase = UPDATE_PHASE_POST;
{
JobContext::Spawner< 1 > entityUpdateSpawner;
JobContext* pContext = entityUpdateSpawner.Allocate();
HELIUM_ASSERT( pContext );
WorldManagerUpdate< EntityPostUpdate >* pJob = pContext->Create< WorldManagerUpdate< EntityPostUpdate > >();
HELIUM_ASSERT( pJob );
WorldManagerUpdate< EntityPostUpdate >::Parameters& rParameters = pJob->GetParameters();
rParameters.pspWorlds = m_worlds.GetData();
rParameters.worldCount = m_worlds.GetSize();
}
// Perform the entity synchronous update.
m_updatePhase = UPDATE_PHASE_SYNCHRONOUS;
size_t worldCount = m_worlds.GetSize();
for( size_t worldIndex = 0; worldIndex < worldCount; ++worldIndex )
{
World* pWorld = m_worlds[ worldIndex ];
HELIUM_ASSERT( pWorld );
size_t layerCount = pWorld->GetLayerCount();
for( size_t layerIndex = 0; layerIndex < layerCount; ++layerIndex )
{
Layer* pLayer = pWorld->GetLayer( layerIndex );
HELIUM_ASSERT( pLayer );
size_t entityCount = pLayer->GetEntityCount();
for( size_t entityIndex = 0; entityIndex < entityCount; ++entityIndex )
{
Entity* pEntity = pLayer->GetEntity( entityIndex );
HELIUM_ASSERT( pEntity );
bool bNeedsSynchronousUpdate = pEntity->NeedsSynchronousUpdate();
uint32_t deferredWorkFlags = pEntity->GetDeferredWorkFlags();
if( !bNeedsSynchronousUpdate && !deferredWorkFlags )
{
continue;
}
if( deferredWorkFlags & Entity::DEFERRED_WORK_FLAG_DESTROY )
{
pLayer->DestroyEntity( pEntity );
--entityIndex;
// Only the current entity should be destroyed; entity destruction should not trigger the
// immediate creation or destruction of other entities.
--entityCount;
HELIUM_ASSERT( pLayer->GetEntityCount() == entityCount );
continue;
}
// Entity::NeedsSynchronousUpdate() also checks the deferred work flags.
if( bNeedsSynchronousUpdate /*deferredWorkFlags & Entity::DEFERRED_WORK_FLAG_UPDATE*/ )
{
pEntity->SynchronousUpdate( m_frameDeltaSeconds );
// Update the entity count in case a new entity was created during the synchronous update.
entityCount = pLayer->GetEntityCount();
HELIUM_ASSERT( entityIndex < entityCount );
// Update the deferred work flags and reassess entity destruction after the synchronous update.
deferredWorkFlags = pEntity->GetDeferredWorkFlags();
if( deferredWorkFlags & Entity::DEFERRED_WORK_FLAG_DESTROY )
{
pLayer->DestroyEntity( pEntity );
--entityIndex;
// Only the current entity should be destroyed; entity destruction should not trigger the
// immediate creation or destruction of other entities.
--entityCount;
HELIUM_ASSERT( pLayer->GetEntityCount() == entityCount );
continue;
}
}
if( deferredWorkFlags & Entity::DEFERRED_WORK_FLAG_REATTACH )
{
pEntity->Detach();
//.........这里部分代码省略.........