spawn.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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/spawn.h $*
  25. * *
  26. * $Author:: Tom_s $*
  27. * *
  28. * $Modtime:: 11/19/01 10:27a $*
  29. * *
  30. * $Revision:: 50 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef SPAWN_H
  36. #define SPAWN_H
  37. #ifndef ALWAYS_H
  38. #include "always.h"
  39. #endif
  40. #ifndef PERSIST_H
  41. #include "persist.h"
  42. #endif
  43. #ifndef DEFINITION_H
  44. #include "definition.h"
  45. #endif
  46. #ifndef VECTOR_H
  47. #include "vector.h"
  48. #endif
  49. #ifndef GAMEOBJREF_H
  50. #include "gameobjref.h"
  51. #endif
  52. class PhysicalGameObj;
  53. class SoldierGameObj;
  54. /*
  55. **
  56. */
  57. class SpawnerDefClass : public DefinitionClass {
  58. public:
  59. SpawnerDefClass( void );
  60. virtual uint32 Get_Class_ID( void ) const;
  61. virtual PersistClass * Create( void ) const ;
  62. virtual bool Save( ChunkSaveClass &csave );
  63. virtual bool Load( ChunkLoadClass &cload );
  64. virtual const PersistFactoryClass & Get_Factory( void ) const;
  65. DECLARE_EDITABLE( SpawnerDefClass, DefinitionClass );
  66. const DynamicVectorClass<int> & Get_Spawn_Definition_ID_List (void) const { return SpawnDefinitionIDList; }
  67. int Get_Player_Type( void ) const { return PlayerType; }
  68. bool Is_Multiplay_Weapon_Spawner(void) const { return IsMultiplayWeaponSpawner; }
  69. protected:
  70. DynamicVectorClass<int> SpawnDefinitionIDList;
  71. int PlayerType;
  72. int SpawnMax;
  73. float SpawnDelay;
  74. float SpawnDelayVariation;
  75. bool IsPrimary;
  76. bool IsSoldierStartup;
  77. bool GotoSpawnerPos;
  78. float GotoSpawnerPosPriority;
  79. bool TeleportFirstSpawn;
  80. int SpecialEffectsObjID;
  81. float PostVisualSpawnDelay;
  82. bool StartsDisabled;
  83. bool KillHibernatingSpawn;
  84. bool ApplySpawnMaterialEffect;
  85. bool IsMultiplayWeaponSpawner;
  86. DynamicVectorClass<StringClass> ScriptNameList;
  87. DynamicVectorClass<StringClass> ScriptParameterList;
  88. friend class SpawnerClass;
  89. friend class SpawnManager;
  90. };
  91. /*
  92. **
  93. */
  94. typedef DynamicVectorClass<Matrix3D> SpawnPointListType;
  95. class SpawnerClass : public PersistClass {
  96. public:
  97. // Constructor and Destructor
  98. SpawnerClass( void );
  99. virtual ~SpawnerClass( void );
  100. // Definitions
  101. void Init( const SpawnerDefClass & definition );
  102. const SpawnerDefClass & Get_Definition( void ) const { WWASSERT( Definition ); return *Definition; }
  103. // Save / Load
  104. virtual bool Save( ChunkSaveClass & csave );
  105. virtual bool Load( ChunkLoadClass & cload );
  106. virtual const PersistFactoryClass & Get_Factory( void ) const;
  107. // Parameters
  108. SpawnPointListType * Get_Spawn_Point_List( void ) { return &SpawnPointList; }
  109. Matrix3D Get_TM( void ) { return TM; }
  110. void Set_TM( Matrix3D & tm ) { TM = tm; }
  111. int Get_ID( void ) { return ID; }
  112. void Set_ID( int id ) { ID = id; }
  113. // Needed for Level Editor
  114. PhysicalGameObj * Create_Spawned_Object( int obj_id = -1 );
  115. // Add a script to this spawner instance (only applied to the spawn)
  116. void Add_Script( const char * script_name, const char * script_parameter );
  117. bool Can_Spawn_Object( int obj_def_id );
  118. PhysicalGameObj * Spawn_Object( int obj_def_id );
  119. void Enable( bool enable ) { Enabled = enable; }
  120. private:
  121. int ID;
  122. Matrix3D TM;
  123. Matrix3D SpawnTM;
  124. const SpawnerDefClass * Definition;
  125. GameObjReference LastSpawn;
  126. bool Enabled;
  127. int SpawnCount;
  128. float SpawnDelayTimer;
  129. SpawnPointListType SpawnPointList;
  130. DynamicVectorClass<StringClass> ScriptNameList;
  131. DynamicVectorClass<StringClass> ScriptParameterList;
  132. /*
  133. ** Spawning
  134. */
  135. PhysicalGameObj * Spawn( int obj_id = -1 );
  136. void Check_Auto_Spawn( float dtime );
  137. bool Determine_Spawn_TM( PhysicalGameObj * obj );
  138. friend class SpawnManager;
  139. };
  140. /*
  141. **
  142. */
  143. class SpawnManager {
  144. public:
  145. ~SpawnManager(void);
  146. static void Update( void );
  147. static bool Save( ChunkSaveClass &csave );
  148. static bool Load( ChunkLoadClass &cload );
  149. static Matrix3D Get_Primary_Spawn_Location( void );
  150. static Matrix3D Get_Multiplayer_Spawn_Location( int player_type, SoldierGameObj * soldier );
  151. static Matrix3D Get_Ctf_Spawn_Location( int team );
  152. static bool Spawner_Exists( int player_type );
  153. static SpawnerClass * Get_Primary_Spawner( void );
  154. static PhysicalGameObj * Spawner_Trigger( int id );
  155. static void Spawner_Enable( int id, bool enable );
  156. static void Display_Unused_Spawners( void );
  157. static bool Toggle_Allow_Killing_Hibernating_Spawn( void );
  158. static DynamicVectorClass<SpawnerClass*> Get_Spawner_List(void) {return SpawnerList;}
  159. protected:
  160. static void Remove_All_Spawners( void );
  161. static void Add_Spawner( SpawnerClass * spawner );
  162. static void Remove_Spawner( SpawnerClass * spawner );
  163. static DynamicVectorClass<SpawnerClass*> SpawnerList;
  164. static float AutoSpawnTimer;
  165. friend class SpawnerClass;
  166. };
  167. #endif // SPAWN_H
  168. //static Matrix3D Get_First_Spawn_Location( int player_type );
  169. //int SpawnNumber; // These are used for sequenced spawns
  170. //static int GlobalSpawnNumber;
  171. /*
  172. void Set_Spawn_Number(int spawn_number) {SpawnNumber = spawn_number;}
  173. int Get_Spawn_Number(void) {return SpawnNumber;}
  174. void Update_Spawn_Number( void ) { SpawnNumber = GlobalSpawnNumber++; }
  175. */