コード例 #1
0
void EntityManager::RemoveEntity(Entity* entity)
{
	if(entity == NULL) return;

	int index = -1;

	if(ContainsEntity(entity, index))
	{
		m_entities.erase(m_entities.begin() + index);

		delete entity;
	}
}
コード例 #2
0
ファイル: EntityPool.cpp プロジェクト: joewan/pycmake
void CEntityPool::OnPoolEntityInUse(CEntity* pEntity, EntityId prevId)
{
	FUNCTION_PROFILER(GetISystem(), PROFILE_ENTITY);

	assert(pEntity);

	// Remove the previous id from the inactive sets
	const EntityId poolId = ContainsEntity(prevId) ? GetPoolId(prevId) : prevId;
	assert(poolId);
	stl::find_and_erase(m_InactivePoolIds, prevId);
	stl::find_and_erase(m_ActivePoolIds, prevId);

	// Add new id to the active set
	stl::push_back_unique(m_ActivePoolIds, SEntityIds(poolId, pEntity->GetId()));
}
コード例 #3
0
ファイル: EntityPool.cpp プロジェクト: joewan/pycmake
bool CEntityPool::DestroyPoolEntity(EntityId entityId) const
{
	FUNCTION_PROFILER(GetISystem(), PROFILE_ENTITY);

	assert(!gEnv->IsEditor());

	bool bResult = false;

	// Set the entity as garbage so it can be deleted
	CEntity* pEntity = (CEntity*)gEnv->pEntitySystem->GetEntity(entityId);
	if (pEntity && ContainsEntity(entityId))
	{
		assert(pEntity->IsPoolControlled());

		pEntity->ClearFlags(ENTITY_FLAG_UNREMOVABLE);
		pEntity->SetPoolControl(false);
		gEnv->pEntitySystem->RemoveEntity(entityId, true);

		bResult = true;
	}

	return bResult;
}