1 //**************************************************************************
3 //** ## ## ## ## ## #### #### ### ###
4 //** ## ## ## ## ## ## ## ## ## ## #### ####
5 //** ## ## ## ## ## ## ## ## ## ## ## ## ## ##
6 //** ## ## ######## ## ## ## ## ## ## ## ### ##
7 //** ### ## ## ### ## ## ## ## ## ##
8 //** # ## ## # #### #### ## ##
10 //** Copyright (C) 2018-2023 Ketmar Dark
12 //** This program is free software: you can redistribute it and/or modify
13 //** it under the terms of the GNU General Public License as published by
14 //** the Free Software Foundation, version 3 of the License ONLY.
16 //** This program is distributed in the hope that it will be useful,
17 //** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 //** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 //** GNU General Public License for more details.
21 //** You should have received a copy of the GNU General Public License
22 //** along with this program. If not, see <http://www.gnu.org/licenses/>.
24 //**************************************************************************
25 // decal, decalgroup, decal animator
26 #ifndef VAVOOM_PSIM_DECAL_PRIVATE_HEADER
27 #define VAVOOM_PSIM_DECAL_PRIVATE_HEADER
32 // ////////////////////////////////////////////////////////////////////////// //
33 class VDecalAnimFader
: public VDecalAnim
{
35 enum { TypeId
= TDecAnimFader
};
38 // animator properties
39 DecalFloatVal startTime
, actionTime
; // in seconds
42 virtual void doIO (VStream
&strm
, VNTValueIOEx
&vio
) override
;
45 virtual bool parse (VScriptParser
*sc
) override
;
48 inline VDecalAnimFader (ENoInit
) noexcept
: VDecalAnim(E_NoInit
) {}
49 inline VDecalAnimFader () noexcept
: VDecalAnim(), startTime(0.0f
), actionTime(0.0f
) {}
50 virtual ~VDecalAnimFader ();
52 virtual vuint8
getTypeId () const noexcept override
;
53 virtual const char *getTypeName () const noexcept override
;
55 // this does deep clone, so we can attach it to the actual decal object
56 virtual VDecalAnim
*clone (bool forced
=false) override
;
58 virtual void genValues () noexcept override
;
60 virtual bool animate (decal_t
*decal
, float timeDelta
) override
;
62 virtual bool calcWillDisappear () const noexcept override
;
64 virtual bool isFader () const noexcept override
;
66 friend void ParseDecalDef (VScriptParser
*sc
);
67 friend void ProcessDecalDefs ();
71 // ////////////////////////////////////////////////////////////////////////// //
72 class VDecalAnimStretcher
: public VDecalAnim
{
74 enum { TypeId
= TDecAnimStretcher
};
77 // animator properties
78 DecalFloatVal goalX
, goalY
;
79 DecalFloatVal startTime
, actionTime
; // in seconds
82 virtual void doIO (VStream
&strm
, VNTValueIOEx
&vio
) override
;
85 virtual bool parse (VScriptParser
*sc
) override
;
88 inline VDecalAnimStretcher (ENoInit
) noexcept
: VDecalAnim(E_NoInit
) {}
89 inline VDecalAnimStretcher () noexcept
: VDecalAnim(), goalX(), goalY(), startTime(0.0f
), actionTime(0.0f
) {}
90 virtual ~VDecalAnimStretcher ();
92 virtual vuint8
getTypeId () const noexcept override
;
93 virtual const char *getTypeName () const noexcept override
;
95 // this does deep clone, so we can attach it to the actual decal object
96 virtual VDecalAnim
*clone (bool forced
=false) override
;
98 virtual void genValues () noexcept override
;
100 virtual bool animate (decal_t
*decal
, float timeDelta
) override
;
102 virtual bool calcWillDisappear () const noexcept override
;
103 virtual void calcMaxScales (float *sx
, float *sy
) const noexcept override
;
105 virtual bool isStretcher () const noexcept override
;
107 friend void ParseDecalDef (VScriptParser
*sc
);
108 friend void ProcessDecalDefs ();
112 // ////////////////////////////////////////////////////////////////////////// //
113 class VDecalAnimSlider
: public VDecalAnim
{
115 enum { TypeId
= TDecAnimSlider
};
118 // animator properties
119 DecalFloatVal distX
, distY
;
120 DecalFloatVal startTime
, actionTime
; // in seconds
124 virtual void doIO (VStream
&strm
, VNTValueIOEx
&vio
) override
;
127 virtual bool parse (VScriptParser
*sc
) override
;
130 inline VDecalAnimSlider (ENoInit
) noexcept
: VDecalAnim(E_NoInit
) {}
131 inline VDecalAnimSlider () noexcept
: VDecalAnim(), distX(), distY(), startTime(0.0f
), actionTime(0.0f
), k8reversey(false) {}
132 virtual ~VDecalAnimSlider ();
134 virtual vuint8
getTypeId () const noexcept override
;
135 virtual const char *getTypeName () const noexcept override
;
137 // this does deep clone, so we can attach it to the actual decal object
138 virtual VDecalAnim
*clone (bool forced
=false) override
;
140 virtual void genValues () noexcept override
;
142 virtual bool animate (decal_t
*decal
, float timeDelta
) override
;
144 virtual bool isSlider () const noexcept override
;
146 friend void ParseDecalDef (VScriptParser
*sc
);
147 friend void ProcessDecalDefs ();
151 // ////////////////////////////////////////////////////////////////////////// //
152 class VDecalAnimColorChanger
: public VDecalAnim
{
154 enum { TypeId
= TDecAnimColorChanger
};
157 // animator properties
159 DecalFloatVal startTime
, actionTime
; // in seconds
162 virtual void doIO (VStream
&strm
, VNTValueIOEx
&vio
) override
;
165 virtual bool parse (VScriptParser
*sc
) override
;
168 inline VDecalAnimColorChanger (ENoInit
) noexcept
: VDecalAnim(E_NoInit
) {}
169 inline VDecalAnimColorChanger () noexcept
: VDecalAnim(), startTime(0.0f
), actionTime(0.0f
) { dest
[0] = dest
[1] = dest
[2] = 0.0f
; }
170 virtual ~VDecalAnimColorChanger ();
172 virtual vuint8
getTypeId () const noexcept override
;
173 virtual const char *getTypeName () const noexcept override
;
175 // this does deep clone, so we can attach it to the actual decal object
176 virtual VDecalAnim
*clone (bool forced
=false) override
;
178 virtual void genValues () noexcept override
;
180 virtual bool animate (decal_t
*decal
, float timeDelta
) override
;
182 virtual bool isColorChanger () const noexcept override
;
184 friend void ParseDecalDef (VScriptParser
*sc
);
185 friend void ProcessDecalDefs ();
189 // ////////////////////////////////////////////////////////////////////////// //
190 class VDecalAnimCombiner
: public VDecalAnim
{
192 enum { TypeId
= TDecAnimCombiner
};
198 virtual void doIO (VStream
&strm
, VNTValueIOEx
&vio
) override
;
201 // animator properties
202 TArray
<VName
> nameList
; // can be empty in cloned/loaded object
203 TArray
<VDecalAnim
*> list
; // can contain less items than `nameList`
206 virtual void fixup () override
;
209 virtual bool parse (VScriptParser
*sc
) override
;
212 inline VDecalAnimCombiner (ENoInit
) noexcept
: VDecalAnim(E_NoInit
) {}
213 inline VDecalAnimCombiner () noexcept
: VDecalAnim(), mIsCloned(false), nameList(), list() {}
214 virtual ~VDecalAnimCombiner ();
216 virtual vuint8
getTypeId () const noexcept override
;
217 virtual const char *getTypeName () const noexcept override
;
219 // this does deep clone, so we can attach it to the actual decal object
220 virtual VDecalAnim
*clone (bool forced
=false) override
;
222 virtual void genValues () noexcept override
;
224 virtual bool animate (decal_t
*decal
, float timeDelta
) override
;
226 virtual bool calcWillDisappear () const noexcept override
;
227 virtual void calcMaxScales (float *sx
, float *sy
) const noexcept override
;
229 virtual bool isCombiner () const noexcept override
;
231 virtual int getCount () const noexcept override
;
232 virtual VDecalAnim
*getAt (int idx
) noexcept override
;
233 virtual bool hasTypeId (vuint8 tid
, int depth
=0) const noexcept override
;
235 friend void ParseDecalDef (VScriptParser
*sc
);
236 friend void ProcessDecalDefs ();