SpawnerNode.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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 : LevelEdit *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/LevelEdit/SpawnerNode.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 5/11/01 9:05a $*
  29. * *
  30. * $Revision:: 13 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __SPAWNER_NODE_H
  39. #define __SPAWNER_NODE_H
  40. #include "node.h"
  41. #include "icons.h"
  42. #include "spawn.h"
  43. #include "editorline.h"
  44. ////////////////////////////////////////////////////////////////////////////
  45. // Forward declarations
  46. ////////////////////////////////////////////////////////////////////////////
  47. class PresetClass;
  48. class PhysClass;
  49. class SpawnPointNodeClass;
  50. ////////////////////////////////////////////////////////////////////////////
  51. //
  52. // SpawnerNodeClass
  53. //
  54. ////////////////////////////////////////////////////////////////////////////
  55. class SpawnerNodeClass : public NodeClass
  56. {
  57. public:
  58. //////////////////////////////////////////////////////////////////
  59. // Public constructors/destructors
  60. //////////////////////////////////////////////////////////////////
  61. SpawnerNodeClass (PresetClass *preset = NULL);
  62. SpawnerNodeClass (const SpawnerNodeClass &src);
  63. ~SpawnerNodeClass (void);
  64. //////////////////////////////////////////////////////////////
  65. // Public operators
  66. //////////////////////////////////////////////////////////////
  67. const SpawnerNodeClass &operator= (const SpawnerNodeClass &src);
  68. //////////////////////////////////////////////////////////////////
  69. // Public methods
  70. //////////////////////////////////////////////////////////////////
  71. //
  72. // From PersistClass
  73. //
  74. virtual const PersistFactoryClass & Get_Factory (void) const;
  75. void On_Post_Load (void);
  76. //
  77. // From NodeClass
  78. //
  79. NodeClass * Clone (void) { return new SpawnerNodeClass (*this); }
  80. void Initialize (void);
  81. NODE_TYPE Get_Type (void) const { return NODE_TYPE_SPAWNER; }
  82. int Get_Icon_Index (void) const { return OBJECT_ICON; }
  83. PhysClass * Peek_Physics_Obj (void) const;
  84. bool Is_Static (void) const { return false; }
  85. void Add_To_Scene (void);
  86. void Remove_From_Scene (void);
  87. void Set_ID (uint32 id);
  88. NodeClass * Add_Child_Node (const Matrix3D &tm);
  89. bool Can_Add_Child_Nodes (void) const { return true; }
  90. bool Show_Settings_Dialog (void);
  91. int Get_Sub_Node_Count (void) const { return m_SpawnPointNodes.Count (); }
  92. NodeClass * Get_Sub_Node (int index);
  93. //
  94. // Notifications
  95. //
  96. void On_Rotate (void);
  97. void On_Translate (void);
  98. void On_Transform (void);
  99. //
  100. // Export methods
  101. //
  102. void Pre_Export (void);
  103. void Post_Export (void);
  104. //
  105. // From PersistClass
  106. //
  107. bool Save (ChunkSaveClass &csave);
  108. bool Load (ChunkLoadClass &cload);
  109. //
  110. // Spawner specific
  111. //
  112. uint32 Get_Spawned_Definition_ID (void);
  113. void Load_Assets (void);
  114. RenderObjClass * Get_Spawned_Model (void);
  115. SpawnPointNodeClass * Add_Spawn_Point (const Matrix3D &tm);
  116. void Remove_Spawn_Point (SpawnPointNodeClass *spawn_point);
  117. void Update_Lines (void);
  118. void Copy_Scripts (const SpawnerNodeClass &src);
  119. SCRIPT_LIST & Get_Scripts (void) { return m_Scripts; }
  120. protected:
  121. //////////////////////////////////////////////////////////////////
  122. // Protected methods
  123. //////////////////////////////////////////////////////////////////
  124. bool Load_Variables (ChunkLoadClass &cload);
  125. void Create_Spawner_Obj (void);
  126. void Free_Spawn_Points (void);
  127. void Free_Scripts (void);
  128. void Assign_Scripts (void);
  129. private:
  130. //////////////////////////////////////////////////////////////////
  131. // Private member data
  132. //////////////////////////////////////////////////////////////////
  133. PhysClass * m_PhysObj;
  134. SpawnerClass * m_SpawnerObj;
  135. DynamicVectorClass<SpawnPointNodeClass *> m_SpawnPointNodes;
  136. DynamicVectorClass<EditorLineClass *> m_SpawnPointLines;
  137. DynamicVectorClass<Matrix3D> m_SpawnPointLoadList;
  138. SCRIPT_LIST m_Scripts;
  139. };
  140. //////////////////////////////////////////////////////////////////
  141. // Peek_Physics_Obj
  142. //////////////////////////////////////////////////////////////////
  143. inline PhysClass *
  144. SpawnerNodeClass::Peek_Physics_Obj (void) const
  145. {
  146. return m_PhysObj;
  147. }
  148. //////////////////////////////////////////////////////////////////
  149. // On_Rotate
  150. //////////////////////////////////////////////////////////////////
  151. inline void
  152. SpawnerNodeClass::On_Rotate (void)
  153. {
  154. Update_Lines ();
  155. if (m_SpawnerObj != NULL) {
  156. m_SpawnerObj->Set_TM (m_Transform);
  157. }
  158. NodeClass::On_Rotate ();
  159. return ;
  160. }
  161. //////////////////////////////////////////////////////////////////
  162. // On_Translate
  163. //////////////////////////////////////////////////////////////////
  164. inline void
  165. SpawnerNodeClass::On_Translate (void)
  166. {
  167. Update_Lines ();
  168. if (m_SpawnerObj != NULL) {
  169. m_SpawnerObj->Set_TM (m_Transform);
  170. }
  171. NodeClass::On_Translate ();
  172. return ;
  173. }
  174. //////////////////////////////////////////////////////////////////
  175. // On_Transform
  176. //////////////////////////////////////////////////////////////////
  177. inline void
  178. SpawnerNodeClass::On_Transform (void)
  179. {
  180. Update_Lines ();
  181. if (m_SpawnerObj != NULL) {
  182. m_SpawnerObj->Set_TM (m_Transform);
  183. }
  184. NodeClass::On_Transform ();
  185. return ;
  186. }
  187. #endif //__SPAWNER_NODE_H