PageRenderTime 34ms CodeModel.GetById 16ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 1ms

/TGame/TServerMS/Entity/EntityManagerScene.cpp

http://awoe.googlecode.com/
C++ | 75 lines | 57 code | 14 blank | 4 comment | 8 complexity | 8a0d02a05df0ebe16e408d99d6902e87 MD5 | raw file
 1#include "stdafx.h"
 2#include "EntityManagerScene.h"
 3#include "Entity/EntityDefinition.h"
 4#include "Entity/EntityVisitorCombat.h"
 5
 6
 7
 8EntityManagerCombat::EntityManagerCombat()
 9:m_nIDGenerator(0)
10{
11}
12
13EntityManagerCombat::~EntityManagerCombat()
14{
15}
16
17bool
18EntityManagerCombat::addEntity(int nID, IEntity* e)
19{
20	if (e->getType()==Entity::ett_Player)
21	{
22		//
23		//	note that player is not a combat entity
24		//	only its sub roles will be added into entity manager for combat
25		//
26		IEntityManager* pSubRoles = e->getEntityMgr();
27		if (pSubRoles)
28		{
29			EntityVisitorCombatRole visitor(*this);
30			pSubRoles->forEach(visitor);
31		}
32		return true;
33	}
34	else
35	{
36		if (nID == 0)
37		{
38			do 
39			{
40				nID = ++m_nIDGenerator;
41			}
42			while(nID==0 || NULL!=getEntity(nID));
43		}
44
45		return __super::addEntity(nID, e);
46	}
47}
48
49
50
51
52
53EntityManagerCity::EntityManagerCity()
54:m_nIDGenerator(0)
55{
56}
57
58EntityManagerCity::~EntityManagerCity()
59{
60}
61
62bool
63EntityManagerCity::addEntity(int nID, IEntity* e)
64{
65	if (nID == 0)
66	{
67		do 
68		{
69			nID = ++m_nIDGenerator;
70		}
71		while(nID==0 || NULL!=getEntity(nID));
72	}
73
74	return __super::addEntity(nID, e);
75}