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/>.
19 #ifndef CL_ATTACK_LIST_H
20 #define CL_ATTACK_LIST_H
22 #include "animation_fx.h"
23 #include "animation_fx_id_array.h"
25 #include "client_sheets/attack_sheet.h"
26 #include "client_sheets/attack_id_sheet.h"
28 #include "nel/misc/string_conversion.h"
37 class CAttackListSheet
;
39 /** Description of a creature attack
44 // pointer on base sheet
45 const CAttackSheet
*Sheet
;
46 CAnimationFXSet AttackBeginFX
; // .animation_fx_set
47 CAnimationFXSet AttackLoopFX
;
48 CAnimationFXSet AttackEndFX
;
49 CAnimationFXSet AttackStaticObjectCastFX
;
50 CAnimationFXSet AttackFailFX
;
51 CAnimationFXSet ProjectileFX
;
52 CAnimationFXSet ImpactFX
;
56 // Init from parent sheet
57 void init(const CAttackSheet
*sheet
, NL3D::UAnimationSet
*as
);
60 /// A named attack, to be inserted in an attack list
61 struct CAttackListEntry
63 CAttackListEntry() : ID(0) { }
64 CAttackListEntry(const CAttackIDSheet
*id
) : ID(id
) { }
65 const CAttackIDSheet
*ID
;
69 inline bool operator == (const CAttackListEntry
&lhs
, const CAttackListEntry
&rhs
)
71 nlassert(lhs
.ID
&& rhs
.ID
);
72 return lhs
.ID
== rhs
.ID
;
75 inline bool operator < (const CAttackListEntry
&lhs
, const CAttackListEntry
&rhs
)
77 nlassert(lhs
.ID
&& rhs
.ID
);
78 return *lhs
.ID
< *rhs
.ID
;
82 /** A list of attacks, sorted by their IDs
88 void init(const CAttackListSheet
*attackList
, NL3D::UAnimationSet
*as
);
90 // get an attack from its ID, or NULL if not found
91 const CAttack
*getAttackFromID(const CAttackIDSheet
&id
) const;
93 std::vector
<CAttackListEntry
> _Attacks
;
97 /** gather all creature attack in a single place
99 class CAttackListManager
102 // get the unique instance of this class
103 static CAttackListManager
&getInstance();
105 static void releaseInstance();
107 * - Init an animation set.
108 * - Build all creature attacks datas and build their tracks.
112 // get an attack list by its name (NULL if not found)
113 const CAttackList
*getAttackList(const std::string
&name
) const;
114 // get auras fx sorted by their id
115 const CAnimationFXIDArray
&getAuras() const { return _Auras
; }
116 // get link fx sorted by their id
117 const CAnimationFXIDArray
&getLinks() const { return _Links
; }
119 typedef std::map
<std::string
,
121 NLMISC::CUnsensitiveStrLessPred
> TAttackListMap
;
122 NL3D::UAnimationSet
*_AnimationSet
;
123 static CAttackListManager
*_Instance
;
124 TAttackListMap _AttackMap
;
126 CAnimationFXIDArray _Auras
;
127 CAnimationFXIDArray _Links
;
130 CAttackListManager();
131 void buildAurasFXs();