vehicledriver.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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/vehicledriver.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 10/14/01 2:57p $*
  29. * *
  30. * $Revision:: 11 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __VEHICLEDRIVER_H
  39. #define __VEHICLEDRIVER_H
  40. #include "vector3.h"
  41. ////////////////////////////////////////////////////////////////
  42. // Forward declarations
  43. ////////////////////////////////////////////////////////////////
  44. class PathClass;
  45. class SmartGameObj;
  46. class ChunkSaveClass;
  47. class ChunkLoadClass;
  48. class Matrix3D;
  49. ////////////////////////////////////////////////////////////////
  50. //
  51. // VehicleDriverClass
  52. //
  53. ////////////////////////////////////////////////////////////////
  54. class VehicleDriverClass
  55. {
  56. public:
  57. ////////////////////////////////////////////////////////////////
  58. // Public constructors/destructors
  59. ////////////////////////////////////////////////////////////////
  60. VehicleDriverClass (void);
  61. virtual ~VehicleDriverClass (void);
  62. ////////////////////////////////////////////////////////////////
  63. // Public methods
  64. ////////////////////////////////////////////////////////////////
  65. void Initialize (SmartGameObj *game_obj, PathClass *path);
  66. void Reset (void);
  67. void Set_Dest_Position (const Vector3 &pos) { m_FinalDest = pos; }
  68. void Set_Next_Position (const Vector3 &pos) { m_CurrentDest = pos; }
  69. bool Drive (void);
  70. void Force_Backup (bool onoff);
  71. bool Is_Backup_Forced (void) const;
  72. void Get_Velocity (const Matrix3D &tm, Vector3 &vel_vector);
  73. void Set_Max_Speed (float max_speed) { m_MaxSpeed = max_speed; }
  74. float Get_Max_Speed (void) const { return m_MaxSpeed;}
  75. void Set_Speed_Factor (float factor) { m_SpeedFactor = factor; }
  76. float Get_Speed_Factor (void) const { return m_SpeedFactor; }
  77. void Set_Arrived_Dist (float dist) { m_ArrivedDist = dist; }
  78. float Get_Arrived_Dist (void) const { return m_ArrivedDist; }
  79. //
  80. // Save/load support
  81. //
  82. void Save (ChunkSaveClass &csave);
  83. void Load (ChunkLoadClass &cload);
  84. protected:
  85. ////////////////////////////////////////////////////////////////
  86. // Protected methods
  87. ////////////////////////////////////////////////////////////////
  88. void Free () { }
  89. bool Are_We_Stuck (const Vector3 &curr_pos);
  90. void Apply_Controls (float forward_accel, float left_accel);
  91. void Load_Variables (ChunkLoadClass &cload);
  92. bool Drive_Tracked (void);
  93. bool Drive_Wheeled (void);
  94. float Calculate_Brake (float dist_to_goal, float expected_velocity, float curr_speed, float max_speed);
  95. private:
  96. ////////////////////////////////////////////////////////////////
  97. // Private member data
  98. ////////////////////////////////////////////////////////////////
  99. Vector3 m_CurrentDest;
  100. Vector3 m_FinalDest;
  101. PathClass * m_CurrentPath;
  102. SmartGameObj * m_GameObj;
  103. float m_MaxSpeed;
  104. float m_SpeedFactor;
  105. float m_ArrivedDist;
  106. Vector3 m_LastPos;
  107. int m_BadProgressCount;
  108. bool m_IsBackingUp;
  109. bool m_IsBackupLocked;
  110. bool m_TurnOffEngineWhenDone;
  111. //bool m_IsBrakingForEnd;
  112. float m_BrakingDist;
  113. float m_LastFrameExpectedVelocity;
  114. };
  115. #endif //__VEHICLEDRIVER_H