ObjectNode.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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/ObjectNode.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 2/08/01 10:30a $*
  29. * *
  30. * $Revision:: 13 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __OBJECT_NODE_H
  39. #define __OBJECT_NODE_H
  40. #include "node.h"
  41. #include "icons.h"
  42. #include "physicalgameobj.h"
  43. #include "listtypes.h"
  44. ////////////////////////////////////////////////////////////////////////////
  45. // Forward declarations
  46. ////////////////////////////////////////////////////////////////////////////
  47. class PresetClass;
  48. ////////////////////////////////////////////////////////////////////////////
  49. //
  50. // ObjectNodeClass
  51. //
  52. ////////////////////////////////////////////////////////////////////////////
  53. class ObjectNodeClass : public NodeClass
  54. {
  55. public:
  56. //////////////////////////////////////////////////////////////////
  57. // Public constructors/destructors
  58. //////////////////////////////////////////////////////////////////
  59. ObjectNodeClass (PresetClass *preset = NULL);
  60. ObjectNodeClass (const ObjectNodeClass &src);
  61. ~ObjectNodeClass (void);
  62. //////////////////////////////////////////////////////////////
  63. // Public operators
  64. //////////////////////////////////////////////////////////////
  65. const ObjectNodeClass &operator= (const ObjectNodeClass &src);
  66. //////////////////////////////////////////////////////////////////
  67. // Public methods
  68. //////////////////////////////////////////////////////////////////
  69. //
  70. // From PersistClass
  71. //
  72. virtual const PersistFactoryClass & Get_Factory (void) const;
  73. //
  74. // RTTI
  75. //
  76. ObjectNodeClass * As_ObjectNodeClass (void) { return this; }
  77. //
  78. // From NodeClass
  79. //
  80. void Initialize (void);
  81. NodeClass * Clone (void) { return new ObjectNodeClass (*this); }
  82. NODE_TYPE Get_Type (void) const { return NODE_TYPE_OBJECT; }
  83. int Get_Icon_Index (void) const { return OBJECT_ICON; }
  84. PhysClass * Peek_Physics_Obj (void) const;
  85. bool Is_Static (void) const { return false; }
  86. bool Show_Settings_Dialog (void);
  87. void Add_To_Scene (void);
  88. void Remove_From_Scene (void);
  89. void Set_ID (uint32 id);
  90. //
  91. // From PersistClass
  92. //
  93. bool Save (ChunkSaveClass &csave);
  94. bool Load (ChunkLoadClass &cload);
  95. //
  96. // ObjectNode specific
  97. //
  98. void Copy_Scripts (const ObjectNodeClass &src);
  99. SCRIPT_LIST & Get_Scripts (void) { return m_Scripts; }
  100. PhysicalGameObj * Peek_Game_Obj (void) const;
  101. protected:
  102. //////////////////////////////////////////////////////////////////
  103. // Protected methods
  104. //////////////////////////////////////////////////////////////////
  105. void Create_Game_Obj (void);
  106. void Destroy_Game_Obj (void);
  107. void Free_Scripts (void);
  108. void Assign_Scripts (void);
  109. //////////////////////////////////////////////////////////////////
  110. // Protected member data
  111. //////////////////////////////////////////////////////////////////
  112. ScriptableGameObj * m_GameObj;
  113. SCRIPT_LIST m_Scripts;
  114. };
  115. //////////////////////////////////////////////////////////////////
  116. // Peek_Game_Obj
  117. //////////////////////////////////////////////////////////////////
  118. inline PhysicalGameObj *
  119. ObjectNodeClass::Peek_Game_Obj (void) const
  120. {
  121. PhysicalGameObj *game_obj = NULL;
  122. if (m_GameObj != NULL) {
  123. game_obj = m_GameObj->As_PhysicalGameObj ();
  124. }
  125. return game_obj;
  126. }
  127. //////////////////////////////////////////////////////////////////
  128. // Peek_Physics_Obj
  129. //////////////////////////////////////////////////////////////////
  130. inline PhysClass *
  131. ObjectNodeClass::Peek_Physics_Obj (void) const
  132. {
  133. PhysClass *phys_obj = NULL;
  134. //
  135. // If our game object has a phys object, then return it to the caller.
  136. //
  137. PhysicalGameObj *phys_game_obj = Peek_Game_Obj ();
  138. if (phys_game_obj != NULL) {
  139. phys_obj = phys_game_obj->Peek_Physical_Object ();
  140. }
  141. return phys_obj;
  142. }
  143. #endif //__OBJECT_NODE_H