vehiclefactorygameobj.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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/vehiclefactorygameobj.h $Author:: Patrick $*
  25. * *
  26. * $Modtime:: 12/10/01 4:41p $*
  27. * *
  28. * $Revision:: 12 $*
  29. * *
  30. *---------------------------------------------------------------------------------------------*
  31. * Functions: *
  32. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  33. #if defined(_MSC_VER)
  34. #pragma once
  35. #endif
  36. #ifndef __VEHICLEFACTORYGAMEOBJ_H
  37. #define __VEHICLEFACTORYGAMEOBJ_H
  38. #include "always.h"
  39. #include "building.h"
  40. ////////////////////////////////////////////////////////////////
  41. // Forward delcarations
  42. ////////////////////////////////////////////////////////////////
  43. class BaseControllerClass;
  44. class VehicleGameObj;
  45. class SoldierGameObj;
  46. ////////////////////////////////////////////////////////////////
  47. //
  48. // VehicleFactoryGameObjDef
  49. //
  50. ////////////////////////////////////////////////////////////////
  51. class VehicleFactoryGameObjDef : public BuildingGameObjDef
  52. {
  53. public:
  54. ////////////////////////////////////////////////////////////////
  55. // Friends
  56. ////////////////////////////////////////////////////////////////
  57. friend class VehicleFactoryGameObj;
  58. ////////////////////////////////////////////////////////////////
  59. // Public constructors/destructors
  60. ////////////////////////////////////////////////////////////////
  61. VehicleFactoryGameObjDef (void);
  62. ~VehicleFactoryGameObjDef (void);
  63. ////////////////////////////////////////////////////////////////
  64. // Public methods
  65. ////////////////////////////////////////////////////////////////
  66. uint32 Get_Class_ID (void) const;
  67. PersistClass * Create (void) const;
  68. bool Save (ChunkSaveClass &csave);
  69. bool Load (ChunkLoadClass &cload);
  70. const PersistFactoryClass & Get_Factory (void) const;
  71. int Get_Pad_Clearing_Warhead(void) const { return PadClearingWarhead; }
  72. float Get_Total_Building_Time(void) const { return TotalBuildingTime; }
  73. ////////////////////////////////////////////////////////////////
  74. // Editable support
  75. ////////////////////////////////////////////////////////////////
  76. DECLARE_EDITABLE (VehicleFactoryGameObjDef, BuildingGameObjDef);
  77. protected:
  78. ////////////////////////////////////////////////////////////////
  79. // Protected methods
  80. ////////////////////////////////////////////////////////////////
  81. void Load_Variables (ChunkLoadClass &cload);
  82. ////////////////////////////////////////////////////////////////
  83. // Protected member data
  84. ////////////////////////////////////////////////////////////////
  85. int PadClearingWarhead; // warhead used to destroy objects blocking construction area
  86. float TotalBuildingTime; // total time for slowest vehicle to be constructed and driven out.
  87. };
  88. ////////////////////////////////////////////////////////////////
  89. //
  90. // VehicleFactoryGameObj
  91. //
  92. ////////////////////////////////////////////////////////////////
  93. class VehicleFactoryGameObj : public BuildingGameObj
  94. {
  95. public:
  96. ////////////////////////////////////////////////////////////////
  97. // Public constructors/destructors
  98. ////////////////////////////////////////////////////////////////
  99. VehicleFactoryGameObj (void);
  100. ~VehicleFactoryGameObj (void);
  101. ////////////////////////////////////////////////////////////////
  102. // Public methods
  103. ////////////////////////////////////////////////////////////////
  104. //
  105. // Definition support
  106. //
  107. virtual void Init( void );
  108. void Init (const VehicleFactoryGameObjDef & definition);
  109. const VehicleFactoryGameObjDef & Get_Definition (void) const;
  110. //
  111. // RTTI
  112. //
  113. VehicleFactoryGameObj * As_VehicleFactoryGameObj (void) { return this; }
  114. //
  115. // Persist support
  116. //
  117. bool Save (ChunkSaveClass &csave);
  118. bool Load (ChunkLoadClass &cload);
  119. const PersistFactoryClass & Get_Factory (void) const;
  120. //
  121. // From BuildingGameObj
  122. //
  123. void CnC_Initialize (BaseControllerClass *base);
  124. void On_Destroyed (void);
  125. //
  126. // GameObj methods
  127. //
  128. void Think (void);
  129. //
  130. // Factory state access
  131. //
  132. bool Is_Available (void) const { return (IsBusy == false) && (IsDestroyed == false); }
  133. bool Is_Available_For_Purchase (void) const;
  134. bool Is_Busy (void) const { return IsBusy; }
  135. int Get_Team_Vehicle_Count(void) const;
  136. //
  137. // Factory access
  138. //
  139. bool Request_Vehicle (int defintion_id, float generation_time,SoldierGameObj * player = NULL);
  140. //
  141. // Creation transform access
  142. //
  143. const Matrix3D & Get_Creation_TM (void) { return CreationTM; }
  144. void Set_Creation_TM (const Matrix3D &tm) { CreationTM = tm; }
  145. //
  146. // Network object support
  147. //
  148. void Import_Rare (BitStreamClass &packet);
  149. void Export_Rare (BitStreamClass &packet);
  150. //
  151. // Vehicle limits
  152. //
  153. static void Set_Max_Vehicles_Per_Team(int max) { WWASSERT(max > 0); MaxVehiclesPerTeam = max; }
  154. static int Get_Max_Vehicles_Per_Team(void) { return MaxVehiclesPerTeam; }
  155. protected:
  156. ////////////////////////////////////////////////////////////////
  157. // Protected methods
  158. ////////////////////////////////////////////////////////////////
  159. void Load_Variables (ChunkLoadClass &cload);
  160. virtual void Destroy_Blocking_Objects (void);
  161. void Deliver_Vehicle(void);
  162. VehicleGameObj * Create_Vehicle (void);
  163. virtual void Begin_Generation (void) {};
  164. virtual void On_Generation_Complete (void);
  165. ////////////////////////////////////////////////////////////////
  166. // Protected member data
  167. ////////////////////////////////////////////////////////////////
  168. GameObjReference Vehicle;
  169. Matrix3D CreationTM;
  170. OBBoxClass GeneratingRegion;
  171. float GenerationTime;
  172. int GeneratingVehicleID;
  173. bool IsBusy;
  174. GameObjReference Purchaser;
  175. int LastDeliveryPath;
  176. float EndTimer;
  177. static int MaxVehiclesPerTeam;
  178. };
  179. #endif // __VEHICLEFACTORYGAMEOBJ_H