WaypathNode.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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/WaypathNode.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 5/11/01 8:59a $*
  29. * *
  30. * $Revision:: 11 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __WAYPATH_NODE_H
  39. #define __WAYPATH_NODE_H
  40. #include "node.h"
  41. #include "vector.h"
  42. #include "vector3.h"
  43. #include "icons.h"
  44. #include "decophys.h"
  45. #include "waypointnode.h"
  46. #include "waypath.h"
  47. ////////////////////////////////////////////////////////////////////////////
  48. // Forward declarations
  49. ////////////////////////////////////////////////////////////////////////////
  50. class PresetClass;
  51. class SegmentedLineClass;
  52. class WaypathClass;
  53. ////////////////////////////////////////////////////////////////////////////
  54. //
  55. // WaypathNodeClass
  56. //
  57. ////////////////////////////////////////////////////////////////////////////
  58. class WaypathNodeClass : public NodeClass
  59. {
  60. public:
  61. //////////////////////////////////////////////////////////////////
  62. // Public constructors/destructors
  63. //////////////////////////////////////////////////////////////////
  64. WaypathNodeClass (PresetClass *preset = NULL);
  65. WaypathNodeClass (const WaypathNodeClass &src);
  66. ~WaypathNodeClass (void);
  67. //////////////////////////////////////////////////////////////
  68. // Public operators
  69. //////////////////////////////////////////////////////////////
  70. const WaypathNodeClass &operator= (const WaypathNodeClass &src);
  71. //////////////////////////////////////////////////////////////////
  72. // Public methods
  73. //////////////////////////////////////////////////////////////////
  74. //
  75. // From PersistClass
  76. //
  77. const PersistFactoryClass & Get_Factory (void) const;
  78. void On_Post_Load (void);
  79. //
  80. // RTTI
  81. //
  82. WaypathNodeClass *As_WaypathNodeClass (void) { return this; }
  83. //
  84. // From NodeClass
  85. //
  86. void Initialize (void);
  87. NodeClass * Clone (void) { return new WaypathNodeClass (*this); }
  88. NODE_TYPE Get_Type (void) const { return NODE_TYPE_WAYPATH; }
  89. int Get_Icon_Index (void) const { return WAYPATH_ICON; }
  90. PhysClass * Peek_Physics_Obj (void) const { return m_PhysObj; }
  91. bool Is_Static (void) const { return false; }
  92. bool Show_Settings_Dialog (void);
  93. bool Can_Be_Rotated_Freely (void) const { return true; }
  94. void Set_Transform (const Matrix3D &tm);
  95. void Add_To_Scene (void);
  96. void Remove_From_Scene (void);
  97. void Hide (bool hide);
  98. void On_Delete (void);
  99. void On_Restore (void);
  100. int Get_Sub_Node_Count (void) const { return Get_Point_Count (); }
  101. NodeClass * Get_Sub_Node (int index) { return m_PointList[index]; }
  102. //
  103. // Export methods
  104. //
  105. void Pre_Export (void);
  106. void Post_Export (void);
  107. // From PersistClass
  108. bool Save (ChunkSaveClass &csave);
  109. bool Load (ChunkLoadClass &cload);
  110. //
  111. // WaypathNodeClass specific
  112. //
  113. int Add_Point (const Vector3 &point);
  114. void Insert_Point (int index, const Vector3 &point);
  115. void Delete_Point (int index);
  116. int Find_Index (WaypointNodeClass *waypoint);
  117. void On_Point_Moved (int index, const Vector3 &new_pos);
  118. int Get_Point_Count (void) const;
  119. void Get_Point (int index, Vector3 &point);
  120. void Get_Point (int index, WaypointNodeClass **waypoint);
  121. void Update_Line (void);
  122. void Set_Flags (int flags);
  123. void Set_Flag (int flag, bool onoff);
  124. bool Get_Flag (int flag);
  125. //////////////////////////////////////////////////////////////////
  126. // Public flags
  127. //////////////////////////////////////////////////////////////////
  128. typedef enum
  129. {
  130. FLAG_TWO_WAY = WaypathClass::FLAG_TWO_WAY,
  131. FLAG_LOOPING = WaypathClass::FLAG_LOOPING,
  132. FLAG_HUMAN = WaypathClass::FLAG_HUMAN,
  133. FLAG_GROUND_VEHICLE = WaypathClass::FLAG_GROUND_VEHICLE,
  134. FLAG_FLYING_VEHICLE = WaypathClass::FLAG_FLYING_VEHICLE,
  135. FLAG_INNATE_PATHFIND = WaypathClass::FLAG_INNATE_PATHFIND
  136. } FLAGS;
  137. protected:
  138. //////////////////////////////////////////////////////////////////
  139. // Protected methods
  140. //////////////////////////////////////////////////////////////////
  141. //
  142. // Save/load methods
  143. //
  144. bool Load_Variables (ChunkLoadClass &cload);
  145. //
  146. // Misc utility methods
  147. //
  148. void Free_Waypoints (void);
  149. SegmentedLineClass * Peek_Line (void);
  150. WaypointNodeClass * Create_Waypoint (const Vector3 &point);
  151. //////////////////////////////////////////////////////////////////
  152. // Protected member data
  153. //////////////////////////////////////////////////////////////////
  154. DecorationPhysClass * m_PhysObj;
  155. DynamicVectorClass<WaypointNodeClass *> m_PointList;
  156. int m_Flags;
  157. WaypathClass * m_RuntimeWaypath;
  158. bool m_HasLoadCompleted;
  159. DynamicVectorClass<WaypointNodeClass *> m_OldStylePointList;
  160. };
  161. //////////////////////////////////////////////////////////////////
  162. // Get_Point_Count
  163. //////////////////////////////////////////////////////////////////
  164. inline int
  165. WaypathNodeClass::Get_Point_Count (void) const
  166. {
  167. return m_PointList.Count ();
  168. }
  169. //////////////////////////////////////////////////////////////////
  170. // Get_Point
  171. //////////////////////////////////////////////////////////////////
  172. inline void
  173. WaypathNodeClass::Get_Point (int index, Vector3 &point)
  174. {
  175. if (index >= 0 && index < m_PointList.Count ()) {
  176. point = m_PointList[index]->Get_Position ();
  177. }
  178. return ;
  179. }
  180. //////////////////////////////////////////////////////////////////
  181. // Get_Point
  182. //////////////////////////////////////////////////////////////////
  183. inline void
  184. WaypathNodeClass::Get_Point (int index, WaypointNodeClass **waypoint)
  185. {
  186. if (index >= 0 && index < m_PointList.Count ()) {
  187. (*waypoint) = m_PointList[index];
  188. }
  189. return ;
  190. }
  191. #endif //__WAYPATH_NODE_H