beacongameobj.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Combat/beacongameobj.h $*
  25. * *
  26. * $Author:: Byon_g $*
  27. * *
  28. * $Modtime:: 1/04/02 2:58p $*
  29. * *
  30. * $Revision:: 16 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __BEACONGAMEOBJ_H
  39. #define __BEACONGAMEOBJ_H
  40. #include "always.h"
  41. #include "simplegameobj.h"
  42. #include "timemgr.h"
  43. ////////////////////////////////////////////////////////////////
  44. // Forward delcarations
  45. ////////////////////////////////////////////////////////////////
  46. class BaseControllerClass;
  47. class WeaponDefinitionClass;
  48. class AudibleSoundClass;
  49. ////////////////////////////////////////////////////////////////
  50. //
  51. // BeaconGameObjDef
  52. //
  53. ////////////////////////////////////////////////////////////////
  54. class BeaconGameObjDef : public SimpleGameObjDef
  55. {
  56. public:
  57. ////////////////////////////////////////////////////////////////
  58. // Public constructors/destructors
  59. ////////////////////////////////////////////////////////////////
  60. BeaconGameObjDef (void);
  61. ~BeaconGameObjDef (void);
  62. ////////////////////////////////////////////////////////////////
  63. // Public methods
  64. ////////////////////////////////////////////////////////////////
  65. virtual uint32 Get_Class_ID (void) const;
  66. virtual PersistClass * Create (void) const;
  67. virtual bool Save (ChunkSaveClass &csave);
  68. virtual bool Load (ChunkLoadClass &cload);
  69. virtual const PersistFactoryClass & Get_Factory (void) const;
  70. bool Is_Nuke(void) const {return (IsNuke != 0);}
  71. DECLARE_EDITABLE (BeaconGameObjDef, SimpleGameObjDef);
  72. protected:
  73. ////////////////////////////////////////////////////////////////
  74. // Protected methods
  75. ////////////////////////////////////////////////////////////////
  76. void Load_Variables (ChunkLoadClass &cload);
  77. ////////////////////////////////////////////////////////////////
  78. // Protected friends
  79. ////////////////////////////////////////////////////////////////
  80. friend class BeaconGameObj;
  81. ////////////////////////////////////////////////////////////////
  82. // Protected member data
  83. ////////////////////////////////////////////////////////////////
  84. float BroadcastToAllTime;
  85. float ArmTime;
  86. float DisarmTime;
  87. float PreDetonateCinematicDelay;
  88. float DetonateTime;
  89. float PostDetonateTime;
  90. int ArmedSoundDefID;
  91. int DisarmingTextID;
  92. int DisarmedTextID;
  93. int ArmingTextID;
  94. int ArmingInterruptedTextID;
  95. int DisarmingInterruptedTextID;
  96. int PreDetonateCinematicDefID;
  97. int PostDetonateCinematicDefID;
  98. int ExplosionDefID;
  99. int IsNuke;
  100. StringClass ArmingAnimationName;
  101. };
  102. ////////////////////////////////////////////////////////////////
  103. //
  104. // BeaconGameObj
  105. //
  106. ////////////////////////////////////////////////////////////////
  107. class BeaconGameObj : public SimpleGameObj
  108. {
  109. public:
  110. ////////////////////////////////////////////////////////////////
  111. // Public constructors/destructors
  112. ////////////////////////////////////////////////////////////////
  113. BeaconGameObj (void);
  114. virtual ~BeaconGameObj (void);
  115. ////////////////////////////////////////////////////////////////
  116. // Public methods
  117. ////////////////////////////////////////////////////////////////
  118. //
  119. // Definition support
  120. //
  121. virtual void Init( void );
  122. void Init (const BeaconGameObjDef & definition);
  123. const BeaconGameObjDef & Get_Definition (void) const;
  124. //
  125. // RTTI
  126. //
  127. virtual BeaconGameObj * As_BeaconGameObj (void) { return this; }
  128. //
  129. // Save / Load / Construction Factory
  130. //
  131. bool Save (ChunkSaveClass & csave);
  132. bool Load (ChunkLoadClass & cload);
  133. const PersistFactoryClass & Get_Factory (void) const;
  134. //
  135. // GameObj methods
  136. //
  137. void Think (void);
  138. void Get_Information (StringClass &string);
  139. //
  140. // Beacon initialization
  141. //
  142. void Init_Beacon (const WeaponDefinitionClass *definiton, SoldierGameObj *owner, const Vector3 &position);
  143. //
  144. // Beacon stuff
  145. //
  146. bool Can_Place_Here (const Vector3 &position);
  147. void On_Arming_Interrupted (void);
  148. void Begin_Arming (void);
  149. void On_Poked (ScriptableGameObj *poker);
  150. virtual void Completely_Damaged( const OffenseObjectClass & damager );
  151. virtual void Export_Rare( BitStreamClass &packet );
  152. virtual void Import_Rare( BitStreamClass &packet );
  153. SoldierGameObj * Get_Owner (void);
  154. private:
  155. ////////////////////////////////////////////////////////////////
  156. // Private methods
  157. ////////////////////////////////////////////////////////////////
  158. void Load_Variables (ChunkLoadClass &cload);
  159. void Stop_Armed_Sound (void);
  160. void Stop_Current_Message_Sound (void);
  161. void Display_Message (int text_id);
  162. void Start_Owner_Animation (void);
  163. void Stop_Owner_Animation (void);
  164. bool Was_Owner_Interrupted (void);
  165. void Start_Cinematic (int id);
  166. bool Is_In_Enemy_Base( void );
  167. void Create_Explosion (void);
  168. //
  169. // State support
  170. //
  171. void Set_State (int state);
  172. void Update_State (void);
  173. BaseControllerClass * Get_Enemy_Base (void);
  174. ////////////////////////////////////////////////////////////////
  175. // Private constants
  176. ////////////////////////////////////////////////////////////////
  177. enum
  178. {
  179. STATE_NULL = 0,
  180. STATE_ARMING,
  181. STATE_ARMED,
  182. STATE_DISARMED,
  183. STATE_DETONATING
  184. };
  185. ////////////////////////////////////////////////////////////////
  186. // Private member data
  187. ////////////////////////////////////////////////////////////////
  188. GameObjReference Owner;
  189. int State;
  190. float StateTimer;
  191. float PreDetonateTimer;
  192. float DetonateTimer;
  193. float WarningTimer;
  194. AudibleSoundClass * ArmedSound;
  195. AudibleSoundClass * MessageSound;
  196. bool IsArmed;
  197. const WeaponDefinitionClass * WeaponDefinition;
  198. GameObjReference CinematicObject;
  199. void * OwnerBackup;
  200. void Restore_Owner( void );
  201. };
  202. #endif // __BEACONGAMEOBJ_H