scriptzone.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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/scriptzone.h $*
  25. * *
  26. * $Author:: Patrick $*
  27. * *
  28. * $Modtime:: 11/27/01 4:46p $*
  29. * *
  30. * $Revision:: 14 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef SCRIPTZONEOBJ_H
  36. #define SCRIPTZONEOBJ_H
  37. #ifndef ALWAYS_H
  38. #include "always.h"
  39. #endif
  40. #ifndef SCRIPTABLEGAMEOBJ_H
  41. #include "scriptablegameobj.h"
  42. #endif
  43. #ifndef OBBOX_H
  44. #include "obbox.h"
  45. #endif
  46. #ifndef SLIST_H
  47. #include "slist.h"
  48. #endif
  49. /*
  50. ** ZoneConstants
  51. ** Convienent namespace declaration for the constants used with zones
  52. */
  53. namespace ZoneConstants
  54. {
  55. typedef enum
  56. {
  57. TYPE_DEFAULT = 0,
  58. TYPE_CTF,
  59. TYPE_VEHICLE_CONSTRUCTION,
  60. TYPE_VEHICLE_REPAIR,
  61. TYPE_TIBERIUM_FIELD,
  62. TYPE_BEACON,
  63. TYPE_GDI_TIB_FIELD,
  64. TYPE_NOD_TIB_FIELD,
  65. TYPE_COUNT
  66. } ZoneType;
  67. }
  68. /*
  69. ** ZoneGameObjDef - Defintion class for a ZoneGameObj
  70. */
  71. class ScriptZoneGameObjDef : public ScriptableGameObjDef
  72. {
  73. public:
  74. ScriptZoneGameObjDef( void );
  75. virtual uint32 Get_Class_ID( void ) const;
  76. virtual PersistClass * Create( void ) const ;
  77. virtual bool Save( ChunkSaveClass &csave );
  78. virtual bool Load( ChunkLoadClass &cload );
  79. virtual bool Is_Valid_Config (StringClass &message) { return true; }
  80. virtual const PersistFactoryClass & Get_Factory( void ) const;
  81. DECLARE_EDITABLE( ScriptZoneGameObjDef, ScriptableGameObjDef );
  82. const Vector3 & Get_Color (void) const { return Color; }
  83. ZoneConstants::ZoneType Get_Type (void) const { return ZoneType; }
  84. protected:
  85. ZoneConstants::ZoneType ZoneType;
  86. Vector3 Color;
  87. bool IsCTFZone;
  88. bool CheckStarsOnly;
  89. bool IsEnvironmentZone;
  90. friend class ScriptZoneGameObj;
  91. };
  92. /*
  93. **
  94. */
  95. class ScriptZoneGameObj : public ScriptableGameObj {
  96. public:
  97. ScriptZoneGameObj();
  98. virtual ~ScriptZoneGameObj();
  99. // Definitions
  100. virtual void Init( void );
  101. void Init( const ScriptZoneGameObjDef & definition );
  102. const ScriptZoneGameObjDef & Get_Definition( void ) const;
  103. // RTTI
  104. ScriptZoneGameObj *As_ScriptZoneGameObj( void ) { return this; };
  105. // Save / Load / Construction Factory
  106. virtual bool Save( ChunkSaveClass & csave );
  107. virtual bool Load( ChunkLoadClass & cload );
  108. virtual const PersistFactoryClass & Get_Factory( void ) const;
  109. // Thinking
  110. virtual void Think();
  111. virtual void Get_Position(Vector3 * set_pos) const { *set_pos = BoundingBox.Center; }
  112. // Bounding Box
  113. void Set_Bounding_Box( OBBoxClass & box ) { BoundingBox = box; }
  114. const OBBoxClass & Get_Bounding_Box(void) { return BoundingBox; }
  115. // PlayerType (a simple copy of what's used in PhyiscalGameObj, needed for CTF
  116. int Get_Player_Type( void) const { return PlayerType; }
  117. void Set_Player_Type( int type ) { PlayerType = type; }
  118. int Count_Team_Members_Inside( int player_type );
  119. static ScriptZoneGameObj * Find_Closest_Zone (const Vector3 &pos, ZoneConstants::ZoneType type);
  120. // Network support
  121. //virtual bool Exists_On_Client( void ) const;
  122. bool Is_Environment_Zone( void ) { return Get_Definition().IsEnvironmentZone; }
  123. protected:
  124. OBBoxClass BoundingBox;
  125. int PlayerType;
  126. // a list of all SMART objects currently inside me and a checking function
  127. SList<GameObjReference> InsideList;
  128. void Entered( SmartGameObj * obj );
  129. bool In_List( SmartGameObj * obj );
  130. bool Inside_Me( const SmartGameObj * obj );
  131. };
  132. #endif
  133. #if 0
  134. // New Zone System
  135. // We need zones for script triggering, transitions, doors, elevators, spawners
  136. // Can Zones trigger from Soldier / smart / physical?
  137. /*
  138. **
  139. */
  140. class ZoneObserverClass {
  141. typedef enum {
  142. ENTERED,
  143. EXITED,
  144. TRIGGER,
  145. VEHICLE_KEY,
  146. };
  147. void Trigger( SmartGameObj * obj, int trigger_type ) = 0;
  148. void Object_Entered( SmartGameObj * obj ) = 0;
  149. void Object_Exited( SmartGameObj * obj ) = 0;
  150. void Object_Inside_Actioned( SmartGameObj * obj, int action_type ) = 0;
  151. };
  152. /*
  153. ** Abstract Base ZoneClass
  154. */
  155. class ZoneClass {
  156. public:
  157. void Set_Zone( const OBBoxClass & zone );
  158. void Set_Observer( ZoneObserverClass * observer );
  159. void Trigger_Check( const DynamicVectorClass<SmartGameObj *> & obj_list ) = 0;
  160. protected:
  161. OBBoxClass ZoneBox;
  162. ZoneObserverClass * Observer;
  163. }
  164. /*
  165. ** EnterExitZoneClass maintains a list of SmartGameObject inside it
  166. ** and notifies observer of enter and exit changes.
  167. */
  168. class EnterExitZoneClass : public ZoneClass {
  169. public:
  170. void Trigger_Check( const DynamicVectorClass<SmartGameObj *> & obj_list );
  171. protected:
  172. DynamicVectorClass<SmartGameObj *> Contents; // Must be a gameobjreference
  173. };
  174. /*
  175. ** TransitionZoneClass
  176. */
  177. class TransitionZoneClass : public ZoneClass {
  178. public:
  179. void Set_Trigger_Movement_Vector( const Vector3 & trigger_move );
  180. void Set_Trigger_Movement_Threshhold( float threshold );
  181. void Set_TM( const Matrix3D & tm );
  182. void Trigger_Check( const DynamicVectorClass<SmartGameObj *> & obj_list );
  183. protected:
  184. Matrix3D TM;
  185. };
  186. /*
  187. **
  188. */
  189. class ZoneManager {
  190. void Update( void );
  191. // Add a zone
  192. void Add_Zone( ZoneClass * zone );
  193. void Remove_Zone( ZoneClass * zone );
  194. };
  195. #endif // SCRIPTZONEOBJ