Exemplo n.º 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;
	}
}
Exemplo n.º 2
0
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()));
}
Exemplo n.º 3
0
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;
}