scriptablegameobj.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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/scriptablegameobj.h $*
  25. * *
  26. * $Author:: Tom_s $*
  27. * *
  28. * $Modtime:: 1/05/02 10:52a $*
  29. * *
  30. * $Revision:: 25 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef SCRIPTABLEGAMEOBJ_H
  36. #define SCRIPTABLEGAMEOBJ_H
  37. #ifndef ALWAYS_H
  38. #include "always.h"
  39. #endif
  40. #ifndef BASEGAMEOBJ_H
  41. #include "basegameobj.h"
  42. #endif
  43. #ifndef GAMEOBJREF_H
  44. #include "gameobjref.h"
  45. #endif
  46. #ifndef TIMEMGR_H
  47. #include "timemgr.h"
  48. #endif
  49. #ifndef GAMEOBJOBSERVER_H
  50. #include "gameobjobserver.h"
  51. #endif
  52. #ifndef SIMPLEVEC_H
  53. #include "simplevec.h"
  54. #endif
  55. #ifndef VECTOR_H
  56. #include "vector.h"
  57. #endif
  58. #ifndef __AUDIO_EVENTS_H
  59. #include "audioevents.h"
  60. #endif
  61. typedef SimpleDynVecClass<GameObjObserverClass *> GameObjObserverList;
  62. class GameObjObserverTimerClass;
  63. class GameObjCustomTimerClass;
  64. class DamageableGameObj;
  65. class BuildingGameObj;
  66. class SoldierGameObj;
  67. class ScriptZoneGameObj;
  68. /*
  69. ** ScriptableGameObjDef - Defintion class for a ScriptableGameObj
  70. */
  71. class ScriptableGameObjDef : public BaseGameObjDef
  72. {
  73. public:
  74. ScriptableGameObjDef( void );
  75. virtual bool Save( ChunkSaveClass &csave );
  76. virtual bool Load( ChunkLoadClass &cload );
  77. DECLARE_EDITABLE( ScriptableGameObjDef, BaseGameObjDef );
  78. protected:
  79. DynamicVectorClass<StringClass> ScriptNameList;
  80. DynamicVectorClass<StringClass> ScriptParameterList;
  81. friend class ScriptableGameObj;
  82. };
  83. /*
  84. **
  85. */
  86. class ScriptableGameObj : public BaseGameObj, public ReferenceableGameObj, public AudioCallbackClass
  87. {
  88. public:
  89. // Constructor and Destructor
  90. ScriptableGameObj( void );
  91. virtual ~ScriptableGameObj( void );
  92. // Definitions
  93. void Init( const ScriptableGameObjDef & definition );
  94. void Copy_Settings( const ScriptableGameObjDef & definition );
  95. void Re_Init( const ScriptableGameObjDef & definition );
  96. virtual void Post_Re_Init( void );
  97. const ScriptableGameObjDef & Get_Definition( void ) const ;
  98. virtual void Set_Delete_Pending (void);
  99. // Save / Load
  100. virtual bool Save( ChunkSaveClass & csave );
  101. virtual bool Load( ChunkLoadClass & cload );
  102. virtual void On_Post_Load( void );
  103. // Thinking
  104. virtual void Think();
  105. virtual void Post_Think();
  106. virtual void Get_Position(Vector3 * set_pos) const = 0;
  107. // Observers
  108. void Add_Observer( GameObjObserverClass * observer );
  109. void Remove_Observer( GameObjObserverClass * observer );
  110. void Remove_All_Observers(void);
  111. // Start_Observers will call created on all observers. Should be used
  112. // in On_Post_Load (if first load), and after spawning / creating.
  113. // Observers added in other cases will already have Created called.
  114. void Start_Observers( void );
  115. const GameObjObserverList & Get_Observers( void ) { return Observers; }
  116. // This just adds to the list and calls attached, does not call Created
  117. void Insert_Observer( GameObjObserverClass * observer );
  118. // Timers
  119. void Start_Observer_Timer( int observer_id, float duration, int timer_id );
  120. void Start_Custom_Timer( ScriptableGameObj * from, float delay, int type, int param );
  121. // Type identification
  122. virtual ScriptableGameObj *As_ScriptableGameObj( void ) { return this; };
  123. virtual DamageableGameObj *As_DamageableGameObj( void ) { return NULL; };
  124. virtual BuildingGameObj *As_BuildingGameObj( void ) { return NULL; };
  125. virtual SoldierGameObj *As_SoldierGameObj( void ) { return NULL; };
  126. virtual ScriptZoneGameObj *As_ScriptZoneGameObj( void ) { return NULL; };
  127. ReferenceableGameObj * As_ReferenceableGameObj( void ) { return this; }
  128. virtual void Get_Information( StringClass & string );
  129. // From AudioCallbackClass
  130. virtual void On_Sound_Ended( SoundSceneObjClass *sound_obj );
  131. // Network support
  132. virtual bool Is_Always_Dirty( void ) { return true; }
  133. //virtual bool Exists_On_Client( void ) const { return true; }
  134. virtual void Export_Creation( BitStreamClass &packet );
  135. virtual void Import_Creation( BitStreamClass &packet );
  136. protected:
  137. bool ObserverCreatedPending;
  138. GameObjObserverList Observers;
  139. DynamicVectorClass<GameObjObserverTimerClass *> ObserverTimerList;
  140. DynamicVectorClass<GameObjCustomTimerClass *> CustomTimerList;
  141. };
  142. #endif // SCRIPTABLEGAMEOBJ_H