#include "EntityManager.h" //--------------------------- Instance ---------------------------------------- // // this class is a singleton //----------------------------------------------------------------------------- EntityManager* EntityManager::Instance() { static EntityManager instance; return &instance; } //------------------------- GetEntityFromID ----------------------------------- //----------------------------------------------------------------------------- BasicEntity* EntityManager::getEntityFromID(int id) const { // find the entity EntityMap::const_iterator ent = m_EntityMap.find(id); // assert that the entity is a member of the map assert((ent != m_EntityMap.end()) && "<EntityManager::GetEntityFromID>: invalid ID"); return ent->second; } //--------------------------- RemoveEntity ------------------------------------ //----------------------------------------------------------------------------- void EntityManager::removeEntity(BasicEntity* entity) { m_EntityMap.erase(m_EntityMap.find(entity->getID())); } //---------------------------- RegisterEntity --------------------------------- //----------------------------------------------------------------------------- void EntityManager::registerEntity(BasicEntity* newEntity) { m_EntityMap.insert(std::make_pair(newEntity->getID(), newEntity)); }