/TGame/TServerMS/Entity/EntityManagerScene.cpp
http://awoe.googlecode.com/ · C++ · 75 lines · 57 code · 14 blank · 4 comment · 10 complexity · 8a0d02a05df0ebe16e408d99d6902e87 MD5 · raw file
- #include "stdafx.h"
- #include "EntityManagerScene.h"
- #include "Entity/EntityDefinition.h"
- #include "Entity/EntityVisitorCombat.h"
-
-
-
- EntityManagerCombat::EntityManagerCombat()
- :m_nIDGenerator(0)
- {
- }
-
- EntityManagerCombat::~EntityManagerCombat()
- {
- }
-
- bool
- EntityManagerCombat::addEntity(int nID, IEntity* e)
- {
- if (e->getType()==Entity::ett_Player)
- {
- //
- // note that player is not a combat entity
- // only its sub roles will be added into entity manager for combat
- //
- IEntityManager* pSubRoles = e->getEntityMgr();
- if (pSubRoles)
- {
- EntityVisitorCombatRole visitor(*this);
- pSubRoles->forEach(visitor);
- }
- return true;
- }
- else
- {
- if (nID == 0)
- {
- do
- {
- nID = ++m_nIDGenerator;
- }
- while(nID==0 || NULL!=getEntity(nID));
- }
-
- return __super::addEntity(nID, e);
- }
- }
-
-
-
-
-
- EntityManagerCity::EntityManagerCity()
- :m_nIDGenerator(0)
- {
- }
-
- EntityManagerCity::~EntityManagerCity()
- {
- }
-
- bool
- EntityManagerCity::addEntity(int nID, IEntity* e)
- {
- if (nID == 0)
- {
- do
- {
- nID = ++m_nIDGenerator;
- }
- while(nID==0 || NULL!=getEntity(nID));
- }
-
- return __super::addEntity(nID, e);
- }