Added ai command setEquipment
[ryzomcore.git] / ryzom / server / src / ai_service / ai_grp_pet.h
blob7d0f56ed284f1a292f6df4547a9234bfc0d006bf
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/>.
17 #ifndef RYAI_GRP_PET_H
18 #define RYAI_GRP_PET_H
19 #include "ai_mgr_pet.h"
20 #include "ai_grp.h"
21 #include "time_interface.h"
22 #include "path_behaviors.h"
23 #include "service_dependencies.h"
25 class CMgrPet;
26 class CPetOwner;
28 //////////////////////////////////////////////////////////////////////////////
29 // CSpawnGroupPet //
30 //////////////////////////////////////////////////////////////////////////////
32 /// This is the base class for PET groups
33 class CSpawnGroupPet
34 : public CSpawnGroup
36 public:
37 CSpawnGroupPet(CPersistent<CSpawnGroup>& owner)
38 : CSpawnGroup(owner)
39 , _PathCont(NLMISC::safe_cast<CGroup*>(&owner)->getAStarFlag())
41 _LastUpdate = CTimeInterface::gameCycle();
42 _IsPlayerSpawned = true;
45 CGrpPet& getPersistent() const;
47 void spawnBots() { }
48 void spawnBots(const std::string &name) { }
49 void despawnBots (bool immediately) { }
51 void update();
53 CPathCont& getPathCont() { return _PathCont; }
55 CAIVector const& getPos() const { return _PathCont.getDestination(); }
57 private:
58 CPathCont _PathCont; // this path container is share by all player pets .. (thats accelerate our computing).
59 uint32 _LastUpdate;
60 bool _IsPlayerSpawned;
63 //////////////////////////////////////////////////////////////////////////////
64 // CGrpPet //
65 //////////////////////////////////////////////////////////////////////////////
67 class CGrpPet
68 : public CGroup
70 public:
71 CGrpPet(CMgrPet* mgr, NLMISC::CEntityId const& owner, CAIAliasDescriptionNode* aliasTree = NULL);
73 CDynGrpBase* getGrpDynBase() { return NULL; }
75 RYZOMID::TTypeId getRyzomType() { return RYZOMID::pack_animal; }
77 CAIS::CCounter& getSpawnCounter();
79 /// @name Service events
80 //@{
81 void serviceUp(uint32 serviceId, std::string const& serviceName);
82 void serviceDown(uint32 serviceId, std::string const& serviceName);
83 //@}
85 void init() { }
87 void release() { }
89 void setEvent(uint eventId);
91 NLMISC::CSmartPtr<CSpawnGroup> createSpawnGroup();
93 CPersistentStateInstance* getPersistentStateInstance();
95 NLMISC::CEntityId const& getPetOwner() const { return _PetOwner; }
97 CMgrPet& getPetManager() { return *(NLMISC::safe_cast<CMgrPet*>(getOwner())); }
99 CCont<CBot>& bots() { return _Bots; }
101 virtual std::string getOneLineInfoString() const { return std::string("Pet group '") + getName() + "'"; }
103 private:
104 NLMISC::CEntityId const _PetOwner;
107 /****************************************************************************/
108 /* Inlined methods */
109 /****************************************************************************/
111 //////////////////////////////////////////////////////////////////////////////
112 // CSpawnGroupPet //
113 //////////////////////////////////////////////////////////////////////////////
115 inline
116 CGrpPet& CSpawnGroupPet::getPersistent() const
118 return static_cast<CGrpPet&>(CSpawnGroup::getPersistent());
121 //////////////////////////////////////////////////////////////////////////////
122 // CGrpPet //
123 //////////////////////////////////////////////////////////////////////////////
125 inline
126 CGrpPet::CGrpPet(CMgrPet* mgr, NLMISC::CEntityId const& owner, CAIAliasDescriptionNode* aliasTree)
127 : CGroup(mgr, RYAI_MAP_CRUNCH::Nothing, aliasTree)
128 , _PetOwner(owner)
130 _Bots.setChildSize(4);
133 inline
134 void CGrpPet::setEvent(uint eventId)
136 nlwarning("Can't set event on a CGrpPet object !");
139 inline
140 NLMISC::CSmartPtr<CSpawnGroup> CGrpPet::createSpawnGroup()
142 return new CSpawnGroupPet(*this);
145 inline
146 CPersistentStateInstance* CGrpPet::getPersistentStateInstance()
148 // WE NEVER HAVE TO GO HERE AS PET ARE NOT DERIVED FROM STATE_INSTANCE STUFF !
149 nldebug("State instance stuff called on a pet group");
150 return (CPersistentStateInstance*)NULL;
153 #endif