Skip to content

Commit f41010b

Browse files
committed
allow setting Animation2D in StickyBombUpdate
1 parent aa3c558 commit f41010b

File tree

3 files changed

+80
-3
lines changed

3 files changed

+80
-3
lines changed

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/StickyBombUpdate.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#define __STICK_BOMB_UPDATE_H
3535

3636
#include "GameLogic/Module/UpdateModule.h"
37+
#include "GameClient/Anim2D.h"
3738

3839
class WeaponTemplate;
3940
class FXList;
@@ -47,11 +48,16 @@ class StickyBombUpdateModuleData : public UpdateModuleData
4748
WeaponTemplate* m_geometryBasedDamageWeaponTemplate;
4849
FXList* m_geometryBasedDamageFX;
4950

51+
AsciiString m_animBaseTemplate;
52+
AsciiString m_animTimedTemplate;
53+
5054
StickyBombUpdateModuleData()
5155
{
5256
m_offsetZ = 10.0f;
5357
m_geometryBasedDamageWeaponTemplate = NULL;
5458
m_geometryBasedDamageFX = NULL;
59+
m_animBaseTemplate = AsciiString::TheEmptyString;
60+
m_animTimedTemplate = AsciiString::TheEmptyString;
5561
}
5662

5763
static void buildFieldParse(MultiIniFieldParse& p)
@@ -63,6 +69,8 @@ class StickyBombUpdateModuleData : public UpdateModuleData
6369
{ "OffsetZ", INI::parseReal, NULL, offsetof( StickyBombUpdateModuleData, m_offsetZ ) },
6470
{ "GeometryBasedDamageWeapon",INI::parseWeaponTemplate, NULL, offsetof( StickyBombUpdateModuleData, m_geometryBasedDamageWeaponTemplate ) },
6571
{ "GeometryBasedDamageFX", INI::parseFXList, NULL, offsetof( StickyBombUpdateModuleData, m_geometryBasedDamageFX ) },
72+
{ "Animation2DBase", INI::parseAsciiString, NULL, offsetof( StickyBombUpdateModuleData, m_animBaseTemplate) },
73+
{ "Animation2DTimed", INI::parseAsciiString, NULL, offsetof( StickyBombUpdateModuleData, m_animTimedTemplate) },
6674
{ 0, 0, 0, 0 }
6775
};
6876
p.add(dataFieldParse);
@@ -92,11 +100,21 @@ class StickyBombUpdate : public UpdateModule
92100
Object* getTargetObject() const;
93101
void setTargetObject( Object *obj );
94102

103+
//AsciiString getAnimBaseTemplate() { return getStickyBombUpdateModuleData()->m_animBaseTemplate; }
104+
//AsciiString getAnimTimedTemplate() { return getStickyBombUpdateModuleData()->m_animTimedTemplate; }
105+
106+
Anim2DTemplate* getAnimBaseTemplate();
107+
Anim2DTemplate* getAnimTimedTemplate();
108+
95109
private:
96110

97111
ObjectID m_targetID;
98112
UnsignedInt m_dieFrame;
99113
UnsignedInt m_nextPingFrame;
114+
115+
Anim2DTemplate* m_animBaseTemplate;
116+
Anim2DTemplate* m_animTimedTemplate;
117+
100118
};
101119

102120
#endif // __STICK_BOMB_UPDATE_H

GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3679,6 +3679,7 @@ void Drawable::drawBombed(const IRegion2D* healthBarRegion)
36793679
StickyBombUpdate *update = (StickyBombUpdate*)obj->findUpdateModule( key_StickyBombUpdate );
36803680
if( update )
36813681
{
3682+
36823683
//This case is tricky. The object that is bombed doesn't know it... but the bomb itself does.
36833684
//So what we do is get it's target, then determine if the target has the icon or not.
36843685
Object *target = update->getTargetObject();
@@ -3689,8 +3690,20 @@ void Drawable::drawBombed(const IRegion2D* healthBarRegion)
36893690
//Timed bomb
36903691
if( !getIconInfo()->m_icon[ ICON_BOMB_TIMED ] )
36913692
{
3692-
getIconInfo()->m_icon[ ICON_BOMB_REMOTE ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BOMB_REMOTE ], TheAnim2DCollection );
3693-
getIconInfo()->m_icon[ ICON_BOMB_TIMED ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BOMB_TIMED ], TheAnim2DCollection );
3693+
Anim2DTemplate* templ = update->getAnimBaseTemplate();
3694+
3695+
if (templ == NULL) // Default icon
3696+
templ = s_animationTemplates[ICON_BOMB_REMOTE];
3697+
3698+
getIconInfo()->m_icon[ICON_BOMB_REMOTE] = newInstance(Anim2D)(templ, TheAnim2DCollection);
3699+
3700+
templ = update->getAnimTimedTemplate();
3701+
3702+
if (templ == NULL) // Default icon
3703+
templ = s_animationTemplates[ICON_BOMB_TIMED];
3704+
3705+
getIconInfo()->m_icon[ICON_BOMB_TIMED] = newInstance(Anim2D)(templ, TheAnim2DCollection);
3706+
36943707

36953708
//Because this is a counter icon that ranges from 0-60 seconds, we need to calculate which frame to
36963709
//start the animation from. Because timers are second based -- 1000 ms equal 1 frame. So we simply
@@ -3752,7 +3765,13 @@ void Drawable::drawBombed(const IRegion2D* healthBarRegion)
37523765
//Timed bomb
37533766
if( !getIconInfo()->m_icon[ ICON_BOMB_REMOTE ] )
37543767
{
3755-
getIconInfo()->m_icon[ ICON_BOMB_REMOTE ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BOMB_REMOTE ], TheAnim2DCollection );
3768+
Anim2DTemplate* templ = update->getAnimBaseTemplate();
3769+
3770+
if (templ == NULL) // Default icon
3771+
templ = s_animationTemplates[ICON_BOMB_REMOTE];
3772+
3773+
getIconInfo()->m_icon[ICON_BOMB_REMOTE] = newInstance(Anim2D)(templ, TheAnim2DCollection);
3774+
37563775
}
37573776
if( getIconInfo()->m_icon[ ICON_BOMB_REMOTE ] )
37583777
{

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StickyBombUpdate.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,46 @@ void StickyBombUpdate::detonate()
285285
getObject()->kill();// Most things just fire weapons in their death modules
286286
}
287287

288+
289+
290+
// ------------------------------------------------------------------------------------------------
291+
// ------------------------------------------------------------------------------------------------
292+
Anim2DTemplate* StickyBombUpdate::getAnimBaseTemplate() {
293+
294+
if (getStickyBombUpdateModuleData()->m_animBaseTemplate.isNotEmpty()) {
295+
//DEBUG_LOG(("SBU::getAnimBaseTemplate - isNotEmpty"));
296+
if (m_animBaseTemplate == NULL) {
297+
m_animBaseTemplate = TheAnim2DCollection->findTemplate(getStickyBombUpdateModuleData()->m_animBaseTemplate);
298+
}
299+
//DEBUG_LOG(("SBU::getAnimBaseTemplate - isNull = %d", m_animBaseTemplate == NULL));
300+
return m_animBaseTemplate;
301+
}
302+
303+
//DEBUG_LOG(("SBU::getAnimBaseTemplate - is Empty ?!"));
304+
305+
return NULL;
306+
}
307+
// ------------------------------------------------------------------------------------------------
308+
// ------------------------------------------------------------------------------------------------
309+
310+
Anim2DTemplate* StickyBombUpdate::getAnimTimedTemplate() {
311+
if (getStickyBombUpdateModuleData()->m_animTimedTemplate.isNotEmpty()) {
312+
//DEBUG_LOG(("SBU::getAnimTimedTemplate - isNotEmpty"));
313+
if (m_animTimedTemplate == NULL) {
314+
m_animTimedTemplate = TheAnim2DCollection->findTemplate(getStickyBombUpdateModuleData()->m_animTimedTemplate);
315+
}
316+
//DEBUG_LOG(("SBU::getAnimTimedTemplate - isNull = %d", m_animTimedTemplate == NULL));
317+
return m_animTimedTemplate;
318+
}
319+
320+
//DEBUG_LOG(("SBU::getAnimTimedTemplate - is Empty ?!"));
321+
322+
return NULL;
323+
324+
}
325+
// ------------------------------------------------------------------------------------------------
326+
// ------------------------------------------------------------------------------------------------
327+
288328
// ------------------------------------------------------------------------------------------------
289329
/** CRC */
290330
// ------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)