pilot.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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/Combat/pilot.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 7/13/01 2:39p $*
  29. * *
  30. * $Revision:: 11 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __PILOT_H
  39. #define __PILOT_H
  40. #include "vector3.h"
  41. #include "gameobjref.h"
  42. #include "matrix3d.h"
  43. ////////////////////////////////////////////////////////////////
  44. // Forward declarations
  45. ////////////////////////////////////////////////////////////////
  46. class PathClass;
  47. class SmartGameObj;
  48. class ChunkSaveClass;
  49. class ChunkLoadClass;
  50. ////////////////////////////////////////////////////////////////
  51. //
  52. // PilotClass
  53. //
  54. ////////////////////////////////////////////////////////////////
  55. class PilotClass
  56. {
  57. public:
  58. ////////////////////////////////////////////////////////////////
  59. // Public data types
  60. ////////////////////////////////////////////////////////////////
  61. typedef enum
  62. {
  63. MODE_HOVER = 0,
  64. MODE_FLY_TO_POINT,
  65. MODE_CIRCLE_POINT,
  66. } MODE;
  67. ////////////////////////////////////////////////////////////////
  68. // Public constructors/destructors
  69. ////////////////////////////////////////////////////////////////
  70. PilotClass (void);
  71. virtual ~PilotClass (void) { Free (); }
  72. ////////////////////////////////////////////////////////////////
  73. // Public methods
  74. ////////////////////////////////////////////////////////////////
  75. //
  76. // Startup/shutdown
  77. //
  78. void Initialize (SmartGameObj *game_obj);
  79. void Reset (void);
  80. //
  81. // Mode control
  82. // Destination - point for the vtol to try to fly to
  83. // Arrived_Distance - radius around the destination where we are "close enough"
  84. // Hover_Distance - radius around the destination where we try to slow down and maintain
  85. // our position. Should be at least 10m more than Arrived_Distance!
  86. // Target - point to aim at (if NULL is passed, vehicle will not aim in any particular direction)
  87. //
  88. void Set_Destination (const Vector3 &dest) { m_FinalDest = dest; m_NextPoint = dest; }
  89. const Vector3 & Get_Destination (void) const { return m_FinalDest; }
  90. void Set_Next_Point (const Vector3 &pos) { m_NextPoint = pos; }
  91. const Vector3 & Get_Next_Point (void) const { return m_NextPoint; }
  92. void Set_Arrived_Dist (float dist) { m_ArrivedDist = dist; }
  93. float Get_Arrived_Dist (void) const { return m_ArrivedDist; }
  94. void Set_Hover_Dist (float dist) { m_HoverDist = dist; }
  95. float Get_Hover_Dist (void) const { return m_HoverDist; }
  96. void Set_Target (const Vector3 *target);
  97. bool Get_Target (Vector3 &target) const { target = m_TargetLocation; return m_FaceTarget; }
  98. void Set_Mode (MODE mode);
  99. MODE Get_Mode (void) const { return m_Mode; }
  100. void Set_Circle_Dist (float circle_dist) { m_CircleDist = circle_dist; }
  101. float Get_Circle_Dist (void) const { return m_CircleDist; }
  102. void Set_Current_Path (PathClass *path) { m_CurrentPath = path; }
  103. PathClass * Get_Current_Path (void) const { return m_CurrentPath; }
  104. void Set_Circle_Angle (float angle);
  105. void Set_Circle_Pos (const Vector3 &pos);
  106. float Get_Circle_Angle (void) const { return m_CircleAngle; }
  107. float Get_Current_Circle_Angle (void) const;
  108. void Set_Circle_Bounds (float min_angle = -DEG_TO_RADF(180), float max_angle = DEG_TO_RADF(180));
  109. //
  110. // Z interpretation
  111. //
  112. bool Get_Is_Exact_Z_Important (void) const { return m_IsExactZImportant; }
  113. void Set_Is_Exact_Z_Important (bool onoff) { m_IsExactZImportant = onoff; }
  114. //
  115. // Timeslice control
  116. //
  117. bool Think (void);
  118. //
  119. // Status methods
  120. //
  121. bool Has_Arrived (void) const;
  122. //
  123. // Speed methods
  124. //
  125. float Get_Aggressivness (void) const { return m_Aggressiveness; }
  126. void Set_Aggressivness (float factor) { m_Aggressiveness = factor; }
  127. void Set_Max_Speed (float max_speed) { m_MaxSpeed = max_speed; }
  128. float Get_Max_Speed (void) const { return m_MaxSpeed;}
  129. void Set_Speed_Factor (float factor) { m_SpeedFactor = factor; }
  130. float Get_Speed_Factor (void) const { return m_SpeedFactor; }
  131. //
  132. // Save/load stuff
  133. //
  134. void Save (ChunkSaveClass &csave);
  135. void Load (ChunkLoadClass &cload);
  136. protected:
  137. ////////////////////////////////////////////////////////////////
  138. // Protected methods
  139. ////////////////////////////////////////////////////////////////
  140. void Free () { }
  141. //
  142. // Mode handlers
  143. //
  144. void Process_Fly_To_Point (void);
  145. void Process_Hover (void);
  146. void Process_Circle_Point (void);
  147. //
  148. // Calculation methods
  149. //
  150. void Calculate_Turn_Sharpness (void);
  151. void Calculate_Strafe_Speed (void);
  152. void Calculate_Forward_Speed (float distance);
  153. void Calculate_Lift_Speed (void);
  154. float Calculate_Desired_Relative_Facing (void);
  155. void Check_Completion (void);
  156. void Update_Transform (void);
  157. float Determine_Preferred_Height (void);
  158. //
  159. // Game object control methods
  160. //
  161. void Apply_Controls (void);
  162. //
  163. // Information methods
  164. //
  165. void Get_Object_Space_Velocity (Vector3 &vel_vector) const;
  166. //
  167. // Save/load methods
  168. //
  169. void Load_Variables (ChunkLoadClass &cload);
  170. private:
  171. ////////////////////////////////////////////////////////////////
  172. // Private member data
  173. ////////////////////////////////////////////////////////////////
  174. Vector3 m_FinalDest;
  175. Vector3 m_NextPoint;
  176. Matrix3D m_CurrentTM;
  177. Vector3 m_ObjSpaceDest;
  178. Vector3 m_ObjSpaceWaypoint;
  179. PathClass * m_CurrentPath;
  180. SmartGameObj * m_GameObj;
  181. float m_MaxSpeed;
  182. float m_SpeedFactor;
  183. float m_Aggressiveness;
  184. float m_ArrivedDist;
  185. float m_HoverDist;
  186. bool m_IsExactZImportant;
  187. bool m_FaceTarget;
  188. Vector3 m_TargetLocation;
  189. MODE m_Mode;
  190. float m_ForwardSpeed;
  191. float m_StrafeSpeed;
  192. float m_LiftSpeed;
  193. float m_TurnSharpness;
  194. float m_CircleAngle;
  195. float m_CircleDist;
  196. float m_MinCircleAngle;
  197. float m_MaxCircleAngle;
  198. };
  199. #endif //__PILOT_H