ECS/Project/Project/ECS/EntityManager/EntityManager.cpp
//	Return the ID of the newly created entity.
Return the ID of the newly created entity.
Return the ID of the newly created entity .
long int EntityManager::createEntity()
{
	if (destroyedEntities.size() == 0)
	{
		long int currentEntity = lastEntityID;
		mapIDToEntity[currentEntity] = std::make_shared<Entity>(currentEntity);
		lastEntityID++;
		Dispatch the Event to the Queue.
		eventDispatcher->dispatchToEventQueue(EventType::ENTITY_CREATED, ModuleType::ENTITY_MANAGER, ComponentType::NO_COMPONENT, currentEntity);
		Return the associated entity.
		return currentEntity;
	}
	else
	{
		Reuse an available entity
		long int currentEntity = destroyedEntities.back();
		Remove the destroyed entity.
		destroyedEntities.pop_back();
		mapIDToEntity[currentEntity] = std::make_shared<Entity>(currentEntity);
		Dispatch the Event to the Queue.
		eventDispatcher->dispatchToEventQueue(EventType::ENTITY_CREATED, ModuleType::ENTITY_MANAGER, ComponentType::NO_COMPONENT, currentEntity);
		Return the associated entity.
		return currentEntity;
	}
}
long int EntityManager :: createEntity ( ) { if ( destroyedEntities . size ( ) == 0 ) { long int currentEntity = lastEntityID ; mapIDToEntity [ currentEntity ] = std :: make_shared < Entity > ( currentEntity ) ; lastEntityID ++ ; eventDispatcher -> dispatchToEventQueue ( EventType :: ENTITY_CREATED , ModuleType :: ENTITY_MANAGER , ComponentType :: NO_COMPONENT , currentEntity ) ; return currentEntity ; } else { long int currentEntity = destroyedEntities . back ( ) ; destroyedEntities . pop_back ( ) ; mapIDToEntity [ currentEntity ] = std :: make_shared < Entity > ( currentEntity ) ; eventDispatcher -> dispatchToEventQueue ( EventType :: ENTITY_CREATED , ModuleType :: ENTITY_MANAGER , ComponentType :: NO_COMPONENT , currentEntity ) ; return currentEntity ; } }
Return the ID of the newly created entity.
Return the ID of the newly created entity .
//	Check if there are any destroyed entties we can reuse. //	Create a new one if there are no available ones. //	Create an appropriate new entity.	 //	 //	Dispatch the Event to the Queue. //	Return the associated entity. //	Reuse an available entity //	Remove the destroyed entity. //	Create an appropriate new entity.	 //	Dispatch the Event to the Queue. //	Return the associated entity.