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/>.
18 #include "item_fx_sheet.h"
19 #include "client_sheets.h"
21 #include "nel/georges/u_form_elm.h"
23 // *******************************************************************************************
24 CItemFXSheet::CItemFXSheet()
27 TrailMinSliceTime
= 0.05f
;
28 TrailMaxSliceTime
= 0.05f
;
32 AttackFXRot
.set(0.f
, 0.f
, 0.f
);
35 // *******************************************************************************************
36 void CItemFXSheet::build(const NLGEORGES::UFormElm
&item
, const std::string
&prefix
)
39 item
.getValueByName(trail
, (prefix
+ "Trail").c_str());
40 _Trail
= ClientSheetsStrings
.add(trail
);
41 item
.getValueByName(TrailMinSliceTime
, (prefix
+ "TrailMinSliceTime").c_str());
42 item
.getValueByName(TrailMaxSliceTime
, (prefix
+ "TrailMaxSliceTime").c_str());
43 std::string advantageFX
;
44 item
.getValueByName(advantageFX
, (prefix
+ "AdvantageFX").c_str());
45 _AdvantageFX
= ClientSheetsStrings
.add(advantageFX
);
47 item
.getValueByName(attackFX
, (prefix
+ "AttackFX").c_str());
48 _AttackFX
= ClientSheetsStrings
.add(attackFX
);
49 item
.getValueByName(AttackFXOffset
.x
, (prefix
+ "AttackFXOffset.X").c_str());
50 item
.getValueByName(AttackFXOffset
.y
, (prefix
+ "AttackFXOffset.Y").c_str());
51 item
.getValueByName(AttackFXOffset
.z
, (prefix
+ "AttackFXOffset.Z").c_str());
52 item
.getValueByName(AttackFXRot
.x
, (prefix
+ "AttackFXRot.X").c_str());
53 item
.getValueByName(AttackFXRot
.y
, (prefix
+ "AttackFXRot.Y").c_str());
54 item
.getValueByName(AttackFXRot
.z
, (prefix
+ "AttackFXRot.Z").c_str());
55 item
.getValueByName(ImpactFXDelay
, (prefix
+ "ImpactFXDelay").c_str());
56 const NLGEORGES::UFormElm
*array
= NULL
;
57 if (item
.getNodeByName(&array
, prefix
+ "StaticFXs") && array
)
60 nlverify(array
->getArraySize(count
));
61 _StaticFXs
.reserve(count
);
62 for(uint k
= 0; k
< count
; ++k
)
64 const NLGEORGES::UFormElm
*node
;
65 if (array
->getArrayNode(&node
, k
))
69 _StaticFXs
.push_back(fx
);
75 // *******************************************************************************************
76 void CItemFXSheet::serial(NLMISC::IStream
&f
)
78 f
.serial(TrailMinSliceTime
);
79 f
.serial(TrailMaxSliceTime
);
80 f
.serial(AttackFXOffset
);
81 ClientSheetsStrings
.serial(f
, _Trail
);
82 ClientSheetsStrings
.serial(f
, _AdvantageFX
);
83 ClientSheetsStrings
.serial(f
, _AttackFX
);
84 f
.serial(AttackFXRot
);
85 f
.serial(ImpactFXDelay
);
86 f
.serialCont(_StaticFXs
);
89 // *******************************************************************************************
90 const char *CItemFXSheet::getTrail() const
92 return _Trail
? ClientSheetsStrings
.get(_Trail
) : "";
95 // *******************************************************************************************
96 const char *CItemFXSheet::getAdvantageFX() const
98 return _AdvantageFX
? ClientSheetsStrings
.get(_AdvantageFX
) : "";
101 // *******************************************************************************************
102 const char *CItemFXSheet::getAttackFX() const
104 return _AttackFX
? ClientSheetsStrings
.get(_AttackFX
) : "";
107 // *******************************************************************************************
108 void CItemFXSheet::CStaticFX::build(const NLGEORGES::UFormElm
&item
)
112 item
.getValueByName(name
, "Name");
113 item
.getValueByName(bone
, "Bone");
114 Name
= ClientSheetsStrings
.add(name
);
115 Bone
= ClientSheetsStrings
.add(bone
);
116 item
.getValueByName(Offset
.x
, "OffsetX");
117 item
.getValueByName(Offset
.y
, "OffsetY");
118 item
.getValueByName(Offset
.z
, "OffsetZ");
121 // *******************************************************************************************
122 void CItemFXSheet::CStaticFX::serial(NLMISC::IStream
&f
)
124 ClientSheetsStrings
.serial(f
, Name
);
125 ClientSheetsStrings
.serial(f
, Bone
);
129 // *******************************************************************************************
130 const char *CItemFXSheet::getStaticFXName(uint index
) const
132 nlassert(index
< _StaticFXs
.size());
133 return _StaticFXs
[index
].Name
? ClientSheetsStrings
.get(_StaticFXs
[index
].Name
) : "";
136 // *******************************************************************************************
137 const char *CItemFXSheet::getStaticFXBone(uint index
) const
139 nlassert(index
< _StaticFXs
.size());
140 return _StaticFXs
[index
].Bone
? ClientSheetsStrings
.get(_StaticFXs
[index
].Bone
) : "";
143 // *******************************************************************************************
144 const NLMISC::CVector
&CItemFXSheet::getStaticFXOffset(uint index
) const
146 nlassert(index
< _StaticFXs
.size());
147 return _StaticFXs
[index
].Offset
;