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_GRP_PET_H
18 #define RYAI_GRP_PET_H
19 #include "ai_mgr_pet.h"
21 #include "time_interface.h"
22 #include "path_behaviors.h"
23 #include "service_dependencies.h"
28 //////////////////////////////////////////////////////////////////////////////
30 //////////////////////////////////////////////////////////////////////////////
32 /// This is the base class for PET groups
37 CSpawnGroupPet(CPersistent
<CSpawnGroup
>& owner
)
39 , _PathCont(NLMISC::safe_cast
<CGroup
*>(&owner
)->getAStarFlag())
41 _LastUpdate
= CTimeInterface::gameCycle();
42 _IsPlayerSpawned
= true;
45 CGrpPet
& getPersistent() const;
48 void spawnBots(const std::string
&name
) { }
49 void despawnBots (bool immediately
) { }
53 CPathCont
& getPathCont() { return _PathCont
; }
55 CAIVector
const& getPos() const { return _PathCont
.getDestination(); }
58 CPathCont _PathCont
; // this path container is share by all player pets .. (thats accelerate our computing).
60 bool _IsPlayerSpawned
;
63 //////////////////////////////////////////////////////////////////////////////
65 //////////////////////////////////////////////////////////////////////////////
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
81 void serviceUp(uint32 serviceId
, std::string
const& serviceName
);
82 void serviceDown(uint32 serviceId
, std::string
const& serviceName
);
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() + "'"; }
104 NLMISC::CEntityId
const _PetOwner
;
107 /****************************************************************************/
108 /* Inlined methods */
109 /****************************************************************************/
111 //////////////////////////////////////////////////////////////////////////////
113 //////////////////////////////////////////////////////////////////////////////
116 CGrpPet
& CSpawnGroupPet::getPersistent() const
118 return static_cast<CGrpPet
&>(CSpawnGroup::getPersistent());
121 //////////////////////////////////////////////////////////////////////////////
123 //////////////////////////////////////////////////////////////////////////////
126 CGrpPet::CGrpPet(CMgrPet
* mgr
, NLMISC::CEntityId
const& owner
, CAIAliasDescriptionNode
* aliasTree
)
127 : CGroup(mgr
, RYAI_MAP_CRUNCH::Nothing
, aliasTree
)
130 _Bots
.setChildSize(4);
134 void CGrpPet::setEvent(uint eventId
)
136 nlwarning("Can't set event on a CGrpPet object !");
140 NLMISC::CSmartPtr
<CSpawnGroup
> CGrpPet::createSpawnGroup()
142 return new CSpawnGroupPet(*this);
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
;