2
0

damageablestaticphys.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Combat *
  23. * *
  24. * $Archive:: /Commando/Code/Combat/damageablestaticphys.h $*
  25. * *
  26. * Original Author:: Greg Hjelstrom *
  27. * *
  28. * $Author:: Greg_h $*
  29. * *
  30. * $Modtime:: 8/17/01 8:27p $*
  31. * *
  32. * $Revision:: 9 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #ifndef DAMAGEABLESTATICPHYS_H
  38. #define DAMAGEABLESTATICPHYS_H
  39. #include "always.h"
  40. #include "staticanimphys.h"
  41. #include "damage.h"
  42. class DamageableStaticPhysDefClass;
  43. /**
  44. ** DamageableStaticPhysClass
  45. ** This is a static physics object which tracks its health. When the health drops to zero,
  46. ** it plays its animation and stops on the end frame.
  47. */
  48. class DamageableStaticPhysClass : public StaticAnimPhysClass
  49. {
  50. public:
  51. // Constructor and Destructor
  52. DamageableStaticPhysClass( void );
  53. virtual ~DamageableStaticPhysClass( void );
  54. virtual void Timestep(float dt);
  55. // RTTI
  56. virtual DamageableStaticPhysClass * As_DamageableStaticPhysClass (void) { return this; }
  57. // Definitions
  58. void Init(const DamageableStaticPhysDefClass & definition);
  59. const DamageableStaticPhysDefClass * Get_DamageableStaticPhysDef(void) const { WWASSERT( Definition ); return (DamageableStaticPhysDefClass *)Definition; }
  60. // Damage Management
  61. void Apply_Damage_Static( const OffenseObjectClass & offense );
  62. void Reset_Health(void);
  63. // Save / Load
  64. virtual bool Save(ChunkSaveClass & csave);
  65. virtual bool Load(ChunkLoadClass & cload);
  66. virtual const PersistFactoryClass & Get_Factory(void) const;
  67. protected:
  68. void Start_Loop(void);
  69. void Play_Twitch(void);
  70. void Play_Death_Transition(void);
  71. enum {
  72. STATE_LIVE_LOOP = 0,
  73. STATE_LIVE_TWITCH,
  74. STATE_DEATH_TRANSITION,
  75. STATE_DEAD_LOOP,
  76. STATE_DEAD_TWITCH,
  77. };
  78. int CurState;
  79. DefenseObjectClass DefenseObject;
  80. friend class DSAPONetworkObjectClass;
  81. };
  82. /*
  83. ** DamageableStaticPhysDefClass
  84. ** Damageable static objects support two animation loops and several sequences. An object
  85. ** can have a pair of frame numbers that are looped between while it is alive (the "Live-Loop"),
  86. ** a pair that are looped while it is dead (the "Dead-Loop"), a "twitch" sequence that is played
  87. ** whenever it is shot in either the live or dead state, and a sequence that is played when the
  88. ** object transitions between alive and dead.
  89. */
  90. class DamageableStaticPhysDefClass : public StaticAnimPhysDefClass
  91. {
  92. public:
  93. DamageableStaticPhysDefClass(void);
  94. virtual uint32 Get_Class_ID(void) const;
  95. virtual const char * Get_Type_Name(void) { return "DamageableStaticPhysDef"; }
  96. virtual bool Is_Type(const char *);
  97. virtual PersistClass * Create(void) const ;
  98. virtual bool Save(ChunkSaveClass & csave);
  99. virtual bool Load(ChunkLoadClass & cload);
  100. virtual const PersistFactoryClass & Get_Factory(void) const;
  101. DECLARE_EDITABLE( DamageableStaticPhysDefClass, StaticAnimPhysDefClass );
  102. protected:
  103. int KilledExplosion;
  104. int LiveLoopStart;
  105. int LiveLoopEnd;
  106. int LiveTwitchStart;
  107. int LiveTwitchEnd;
  108. int DeathTransitionStart;
  109. int DeathTransitionEnd;
  110. int DeadLoopStart;
  111. int DeadLoopEnd;
  112. int DeadTwitchStart;
  113. int DeadTwitchEnd;
  114. bool PlayTwitchesToCompletion;
  115. DefenseObjectDefClass DefenseObjectDef;
  116. friend class DamageableStaticPhysClass;
  117. friend class DSAPONetworkObjectClass;
  118. };
  119. #endif // DAMAGEABLESTATICPHYS_H