Resolve "Toggle Free Look with Hotkey"
[ryzomcore.git] / ryzom / server / src / ai_service / ai_entity_id.h
blobbaad9ab6961644a329420b0fc98e455949d1c31a
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
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.
8 //
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/>.
20 #ifndef RYAI_ENTITY_ID_H
21 #define RYAI_ENTITY_ID_H
23 #include "nel/misc/types_nl.h"
24 #include "nel/misc/common.h"
25 #include "nel/misc/debug.h"
26 #include "nel/misc/entity_id.h"
27 #include "game_share/ryzom_entity_id.h"
29 #include <string>
32 //--------------------------------------------------------------------------
33 // Advanced declaration of some classes with circular refferences
34 //--------------------------------------------------------------------------
36 class AI;
37 class CAIBot;
38 class CAIGrp;
39 class CAIMgr;
40 class CAIEntity;
41 class CAIPlayer;
44 //--------------------------------------------------------------------------
45 // The class itself
46 //--------------------------------------------------------------------------
49 class CAIEntityId
51 public:
52 // default ctor
53 inline CAIEntityId();
55 ///////////////////
56 // Statics Start //
58 // returns the highest numbers allowed for bot, grp and mgr id components
59 inline static uint32 maxBotId();
60 inline static uint32 maxGrpId();
61 inline static uint32 maxMgrId();
63 // building an id from component parts
64 inline static CAIEntityId botId(uint mgr, uint grp, uint bot);
65 inline static CAIEntityId botId(CAIEntityId grp, uint bot);
67 inline static CAIEntityId grpId(uint mgr, uint grp);
68 inline static CAIEntityId grpId(CAIEntityId mgr, uint grp);
70 inline static CAIEntityId mgrId(uint mgr);
72 inline static CAIEntityId plrId(const TDataSetRow& entityIndex);
74 // these methods are not intended to be fast but they should be thorough,
75 // trying every sensible way of interpretting the strings to identify bots
76 // including: CAIEntitId format, CEntityId format, mgr_name.grp_name.bot_name
77 // format, stand alone name and mgr_name:grp_name:bot_name format
78 // Not inlined coz they thake a large amount of code.
79 static CAIEntityId botId(const std::string &name);
80 static CAIEntityId grpId(const std::string &name);
81 static CAIEntityId mgrId(const std::string &name);
82 static CAIEntityId entityId(const std::string &name);
84 // get the ptr of the CAIEntity generated with the parameter String ..
85 inline static CAIBot *botPtr(const std::string &name); // get ptr to Bot (NULL if !isBot() or !getGrp() or bot>=getGrp()->size)
86 inline static CAIGrp *grpPtr(const std::string &name); // get ptr to Grp (NULL if (!isBot()&&!isGrp()) or !getMgr() or bot>=getMgr()->size)
87 inline static CAIMgr *mgrPtr(const std::string &name); // get ptr to Mgr (NULL if isInvalid() or !getMgr())
88 inline static CAIEntity *entityPtr(const std::string &name); // get ptr to Plr, Mgr, Grp or Bot
90 // Statics End //
91 /////////////////
94 // What kind of id is this - is it a bot, grp, mgr, plr or invalid
96 inline bool isBot() const; // syntactically, is this a bot id
97 inline bool isGrp() const; // syntactically, is this a grp id
98 inline bool isMgr() const; // syntactically, is this a mgr id
99 inline bool isPlr() const; // syntactically, is this a player id
100 inline bool isValid() const; // syntactically, is this a valid id ( not invalid, may it be ? ).
101 inline bool isInvalid() const; // syntactically, is this an invalid id
103 // Getting ptr to object of this id ----------------------------------------
104 inline bool exists() const; // traverse entity hierachy to see whether this entity exists
105 inline CAIBot *botPtr() const; // get ptr to Bot (NULL if !isBot() or !getGrp() or bot>=getGrp()->size)
106 inline CAIGrp *grpPtr() const; // get ptr to Grp (NULL if (!isBot()&&!isGrp()) or !getMgr() or bot>=getMgr()->size)
107 inline CAIMgr *mgrPtr() const; // get ptr to Mgr (NULL if isInvalid() or !getMgr())
108 inline CAIPlayer *plrPtr() const; // get ptr to Plr (NULL if isInvalid() or !getMgr())
110 inline CAIEntity *entityPtr() const; // get ptr to Plr, Mgr, Grp or Bot
112 // Routines for iterating through ids
113 inline static CAIEntityId firstMgr(); // get first mgr in the ai singleton
114 inline CAIEntityId firstGrp() const; // get first grp for the mgr part of this CAIEntityId
115 inline CAIEntityId firstBot() const; // get first bot for the grp part of this CAIEntityId
117 inline CAIEntityId nextMgr() const;
118 inline CAIEntityId nextGrp(bool sameMgr=false) const;
119 inline CAIEntityId nextBot(bool sameGrp=false,bool sameMgr=false) const;
121 // Basic accessors
122 inline bool setBotId(uint32 id);
123 inline bool setGrpId(uint32 id);
124 inline bool setMgrId(uint32 id);
127 inline uint32 getBotId() const;
128 inline uint32 getGrpId() const;
129 inline uint32 getMgrId() const;
130 inline uint32 getPlrId() const;
133 // Convertions to and from string, int and CEntityId
134 inline CAIEntityId(const NLMISC::CEntityId &id);
135 inline CAIEntityId(const std::string &str);
136 inline CAIEntityId(uint32 val);
137 inline uint32 toInt32() const;
139 inline NLMISC::CEntityId toEntityId() const;
140 inline std::string toString() const;
142 // Handy basic operators
143 inline bool operator==(const CAIEntityId &other) const;
144 inline bool operator!=(const CAIEntityId &other) const;
145 inline bool operator>=(const CAIEntityId &other) const;
146 inline bool operator<=(const CAIEntityId &other) const;
147 inline bool operator>(const CAIEntityId &other) const;
148 inline bool operator<(const CAIEntityId &other) const;
150 protected:
151 private:
152 uint32 _id;
155 #endif