1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef RYAI_FX_ENTITY_MANAGER_H
18 #define RYAI_FX_ENTITY_MANAGER_H
24 #include "fx_entity.h"
25 #include "fx_entity_manager.h"
27 /** Manager for fx entities
29 This class is a singleton.
33 class CFxEntityManager
36 /// Returns a pointer to the manager.
37 static CFxEntityManager
* getInstance();
38 /// Destroys the manager.
39 static void destroyInstance();
41 void init(TDataSetIndex baseRowIndex
, TDataSetIndex size
);
44 /// Creates a fx entity or return an existing one with that name.
45 CFxEntityPtr
create(CAIPos
const& pos
, NLMISC::CSheetId
const& sheet
);
46 /// Removes a fx entity from the manager.
47 void destroy(CFxEntityPtr
const& entity
);
48 /// Tells if an entity with the specified id exists in the manager.
49 bool exists(NLMISC::CEntityId
const& id
);
50 /// Select a set of entities depending of a request string.
51 void select(std::string
const& request
, std::vector
<NLMISC::CEntityId
>& entities
);
52 /// Returns a fx entity with that id or 0 (NULL) if it doesn't exist.
53 CFxEntityPtr
get(NLMISC::CEntityId
const& id
);
55 void registerEntity(CFxEntityPtr
const& entity
);
56 void unregisterEntity(CFxEntityPtr
const& entity
);
58 typedef std::set
<CFxEntityPtr
> TFxEntityContainer
;
59 typedef std::map
<NLMISC::CEntityId
, CFxEntityPtr
> TEntityIdContainer
;
60 TFxEntityContainer
const& getEntities() { return _Entities
; }
63 FOREACH(itEntity
, TEntityIdContainer
, _IdIndex
)
65 nldebug("Entity %s %s", itEntity
->first
.toString().c_str(), itEntity
->second
->id().toString().c_str());
70 static CFxEntityManager
* _Instance
;
73 TFxEntityContainer _Entities
;
74 TEntityIdContainer _IdIndex
;