waypath.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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/wwphys/waypath.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 1/10/01 11:20a $*
  29. * *
  30. * $Revision:: 4 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __WAYPATH_H
  39. #define __WAYPATH_H
  40. #include "persist.h"
  41. #include "refcount.h"
  42. #include "vector.h"
  43. ////////////////////////////////////////////////////////////////
  44. // Forward declarations
  45. ////////////////////////////////////////////////////////////////
  46. class WaypointClass;
  47. class WaypathPositionClass;
  48. class Vector3;
  49. ////////////////////////////////////////////////////////////////
  50. //
  51. // WaypathClass
  52. //
  53. ////////////////////////////////////////////////////////////////
  54. class WaypathClass : public PersistClass, public RefCountClass
  55. {
  56. public:
  57. ////////////////////////////////////////////////////////////////
  58. // Public flags
  59. ////////////////////////////////////////////////////////////////
  60. typedef enum
  61. {
  62. FLAG_TWO_WAY = 0x00000001,
  63. FLAG_LOOPING = 0x00000002,
  64. FLAG_HUMAN = 0x00000004,
  65. FLAG_GROUND_VEHICLE = 0x00000008,
  66. FLAG_FLYING_VEHICLE = 0x00000010,
  67. FLAG_INNATE_PATHFIND = 0x00000020
  68. } FLAGS;
  69. ////////////////////////////////////////////////////////////////
  70. // Public constructors/destructors
  71. ////////////////////////////////////////////////////////////////
  72. WaypathClass (void);
  73. WaypathClass (const WaypathPositionClass &start, const WaypathPositionClass &end);
  74. virtual ~WaypathClass (void);
  75. ////////////////////////////////////////////////////////////////
  76. // Public methods
  77. ////////////////////////////////////////////////////////////////
  78. //
  79. // Identifaction methods
  80. //
  81. int Get_ID (void) const { return m_ID; }
  82. void Set_ID (int id) { m_ID = id; }
  83. //
  84. // Waypoint methods
  85. //
  86. int Get_Point_Count (void) const { return m_Waypoints.Count (); }
  87. WaypointClass * Get_Point (int index) const;
  88. void Add_Point (const WaypointClass &point);
  89. void Add_Point (const Vector3 &point);
  90. //
  91. // Flags
  92. //
  93. int Get_Flags (void) const { return m_Flags; }
  94. void Set_Flags (int flags) { m_Flags = flags; }
  95. bool Get_Flag (int flag) { return bool((m_Flags & flag) == flag); }
  96. void Set_Flag (int flag, bool onoff);
  97. //
  98. // Position methods
  99. //
  100. bool Evaluate_Position (const WaypathPositionClass &pos, Vector3 *position);
  101. //
  102. // Serialization methods (from PersistClass)
  103. //
  104. const PersistFactoryClass & Get_Factory (void) const;
  105. bool Save (ChunkSaveClass &csave);
  106. bool Load (ChunkLoadClass &cload);
  107. void On_Post_Load (void);
  108. protected:
  109. ////////////////////////////////////////////////////////////////
  110. // Protected methods
  111. ////////////////////////////////////////////////////////////////
  112. void Free (void);
  113. bool Load_Variables (ChunkLoadClass &cload);
  114. private:
  115. ////////////////////////////////////////////////////////////////
  116. // Private member data
  117. ////////////////////////////////////////////////////////////////
  118. int m_ID;
  119. int m_Flags;
  120. DynamicVectorClass<WaypointClass *> m_Waypoints;
  121. };
  122. //////////////////////////////////////////////////////////////////////////////
  123. // Get_Point
  124. //////////////////////////////////////////////////////////////////////////////
  125. inline WaypointClass *
  126. WaypathClass::Get_Point (int index) const
  127. {
  128. WaypointClass *waypoint = NULL;
  129. //
  130. // Check to ensure the requested index is valid
  131. //
  132. if (index >= 0 && index < m_Waypoints.Count ()) {
  133. waypoint = m_Waypoints[index];
  134. }
  135. return waypoint;
  136. }
  137. #endif //__WAYPATH_H