basecontroller.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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/basecontroller.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 1/15/02 7:18p $*
  29. * *
  30. * $Revision:: 19 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __BASE_CONTROLLER_H
  39. #define __BASE_CONTROLLER_H
  40. #include "building.h"
  41. #include "obbox.h"
  42. #include "vector.h"
  43. #include "characterclasssettings.h"
  44. #include "networkobject.h"
  45. ////////////////////////////////////////////////////////////////
  46. // Forward declarations
  47. ////////////////////////////////////////////////////////////////
  48. class ChunkSaveClass;
  49. class ChunkLoadClass;
  50. class ConversationClass;
  51. class ActiveConversationClass;
  52. class SoldierGameObj;
  53. class BuildingGameObj;
  54. class VehicleGameObj;
  55. class BeaconGameObj;
  56. ////////////////////////////////////////////////////////////////
  57. //
  58. // BaseControllerClass
  59. //
  60. ////////////////////////////////////////////////////////////////
  61. class BaseControllerClass : public NetworkObjectClass
  62. {
  63. public:
  64. ////////////////////////////////////////////////////////////////
  65. // Friends
  66. ////////////////////////////////////////////////////////////////
  67. friend class BuildingMonitorClass;
  68. ////////////////////////////////////////////////////////////////
  69. // Public constructors/destructors
  70. ////////////////////////////////////////////////////////////////
  71. BaseControllerClass (void);
  72. virtual ~BaseControllerClass (void);
  73. ////////////////////////////////////////////////////////////////
  74. // Public methods
  75. ////////////////////////////////////////////////////////////////
  76. //
  77. // Initialization
  78. //
  79. void Initialize ( int player_type );
  80. void Shutdown (void);
  81. void Delete (void) {};
  82. //
  83. // Networking.
  84. //
  85. // Set_Delete_Pending -
  86. //
  87. // The base controllers persist between levels so they should never be marked for deletion. They will be deleted
  88. // when needed by their owner, the game mode
  89. //
  90. virtual void Set_Delete_Pending (void) {};
  91. //
  92. // Building access
  93. //
  94. void Add_Building (BuildingGameObj *building);
  95. //
  96. // Timestep
  97. //
  98. void Think (void);
  99. //
  100. // Power related methods
  101. //
  102. void Set_Base_Powered (bool onoff);
  103. bool Is_Base_Powered (void) const { return BasePowered; }
  104. void Check_Base_Power (void);
  105. void Power_Base (bool onoff);
  106. void Set_Operation_Time_Factor (float factor);
  107. float Get_Operation_Time_Factor (void) { return OperationTimeFactor; }
  108. //
  109. // Harvester support
  110. //
  111. void Request_Harvester (int def_id);
  112. VehicleGameObj * Get_Harvester_Vehicle (void);
  113. //
  114. // State accessors
  115. //
  116. bool Can_Generate_Soldiers (void) const { return CanGenerateSoldiers; }
  117. bool Can_Generate_Vehicles (void) const { return CanGenerateVehicles; }
  118. void Set_Can_Generate_Soldiers (bool onoff);
  119. void Set_Can_Generate_Vehicles (bool onoff);
  120. //
  121. // Data accessors
  122. //
  123. int Get_Player_Type (void) const { return PlayerType; }
  124. //
  125. // Base destruction
  126. //
  127. void Set_Base_Destroyed ( bool onoff );
  128. bool Is_Base_Destroyed (void) const { return IsBaseDestroyed; }
  129. void Destroy_Base (void);
  130. void Set_Beacon_Destroyed_Base ( bool onoff );
  131. bool Did_Beacon_Destroy_Base ( void ) const { return DidBeaconDestroyBase; }
  132. //
  133. // Beacon zone access
  134. //
  135. const OBBoxClass & Get_Beacon_Zone (void) { return BeaconZone; }
  136. //
  137. // Radar support
  138. //
  139. void Check_Radar (void);
  140. bool Is_Radar_Enabled (void) const { return IsRadarEnabled; }
  141. void Play_Announcement(int text_id);
  142. //
  143. // Notifications
  144. //
  145. void On_Building_Damaged (BuildingGameObj *building);
  146. void On_Building_Destroyed (BuildingGameObj *building);
  147. void On_Vehicle_Generated(VehicleGameObj *vehicle);
  148. void On_Vehicle_Delivered(VehicleGameObj *vehicle);
  149. void On_Vehicle_Damaged(VehicleGameObj* vehicle);
  150. void On_Vehicle_Destroyed(VehicleGameObj* vehicle);
  151. void On_Beacon_Armed(BeaconGameObj* beacon);
  152. void On_Beacon_Disarmed(BeaconGameObj* beacon);
  153. void On_Beacon_Warning(BeaconGameObj* beacon);
  154. //
  155. // Fund support
  156. //
  157. //void Deposit_Funds (int funds);
  158. void Distribute_Funds_To_Each_Teammate (int funds);
  159. //
  160. // Network support
  161. //
  162. void Import_Occasional (BitStreamClass &packet);
  163. void Export_Occasional (BitStreamClass &packet);
  164. //
  165. // Component lookup
  166. //
  167. static BaseControllerClass * Find_Base ( int playertype );
  168. static BaseControllerClass * Find_Base_For_Star (void);
  169. BuildingGameObj * Find_Building (BuildingConstants::BuildingType type);
  170. protected:
  171. ////////////////////////////////////////////////////////////////
  172. // Protected constants
  173. ////////////////////////////////////////////////////////////////
  174. typedef enum
  175. {
  176. BASE_UNDER_ATTACK = 0,
  177. BUILDING_DESTROYED
  178. } Notification;
  179. ////////////////////////////////////////////////////////////////
  180. // Protected methods
  181. ////////////////////////////////////////////////////////////////
  182. void Initialize_Building_List (void);
  183. void Reset_Building_List (void);
  184. void Enable_Radar (bool onoff);
  185. //
  186. // Team notification
  187. //
  188. void Notify_Team (Notification event, BuildingConstants::BuildingType type);
  189. private:
  190. ////////////////////////////////////////////////////////////////
  191. // Private methods
  192. ////////////////////////////////////////////////////////////////
  193. bool Are_All_Buildings_Destroyed (void);
  194. ////////////////////////////////////////////////////////////////
  195. // Private member data
  196. ////////////////////////////////////////////////////////////////
  197. float OperationTimeFactor;
  198. int PlayerType; // Team
  199. DynamicVectorClass<BuildingGameObj *> BuildingList;
  200. bool BasePowered;
  201. bool CanGenerateSoldiers;
  202. bool CanGenerateVehicles;
  203. bool IsRadarEnabled;
  204. bool IsBaseDestroyed;
  205. bool DidBeaconDestroyBase;
  206. OBBoxClass BeaconZone;
  207. int AnnounceInterval;
  208. float AnnouncedAlliedBldgDamageTime;
  209. float AnnouncedEnemyBldgDamageTime;
  210. float AnnouncedAlliedVehicleDamageTime;
  211. float AnnouncedEnemyVehicleDamageTime;
  212. static BaseControllerClass * CurrentBases[BuildingConstants::BASE_COUNT];
  213. };
  214. #endif //__BASE_CONTROLLER_H