boat.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. //! Boat's sound controller list. (native, do not change or extend)
  2. enum BoatSoundCtrl
  3. {
  4. // simulation
  5. ENGINE, //!< indicates if engine is ON
  6. SPEED, //!< speed of the boat in km/h
  7. // miscellaneous
  8. PLAYER //!< indicates if driver is controlled by player
  9. };
  10. //! Type of vehicle's fluid. (native, do not change or extend)
  11. enum BoatFluid
  12. {
  13. FUEL
  14. };
  15. class BoatOwnerState : TransportOwnerState
  16. {
  17. };
  18. class BoatMove : TransportMove
  19. {
  20. };
  21. class Boat extends Transport
  22. {
  23. //!
  24. protected override event typename GetOwnerStateType()
  25. {
  26. return BoatOwnerState;
  27. }
  28. //!
  29. protected override event typename GetMoveType()
  30. {
  31. return BoatMove;
  32. }
  33. //! Returns the actual throttle value in range <0, 1>.
  34. proto native float GetThrottle();
  35. //! Sets the future throttle value.
  36. proto native void SetThrottle(float value);
  37. //! Returns the actual steering value in range <-1, 1>.
  38. proto native float GetSteering();
  39. //! Sets the future steering value.
  40. proto native void SetSteering(float value);
  41. //! Returns the number of gears.
  42. proto native int GetGearCount();
  43. //! Returns the index of the neutral gear.
  44. proto native int GetNeutralGear();
  45. //! Returns the index of the future gear, -1 if there is no engine.
  46. proto native int GetGear();
  47. //! Returns the index of the current gear, -1 if there is no engine.
  48. proto native int GetCurrentGear();
  49. //! Returns the value of how much the clutch is disengaged.
  50. proto native int GetClutch();
  51. //! Shifts the future gear up, triggering gearbox simulation.
  52. proto native void ShiftUp();
  53. //! Shifts the future gear to selected gear, triggering gearbox simulation.
  54. proto native void ShiftTo(int gear);
  55. //! Shifts the future gear down, triggering gearbox simulation.
  56. proto native void ShiftDown();
  57. //! Returns if there is an engine.
  58. proto native bool HasEngine();
  59. //! Returns engine's min operating rpm.
  60. proto native float EngineGetRPMMin();
  61. //! Returns engine's idle rpm before engine stalls.
  62. proto native float EngineGetRPMIdle();
  63. //! Returns engine's max rpm before engine blows up.
  64. proto native float EngineGetRPMMax();
  65. //! Returns engine's maximal working rpm without damaging the engine.
  66. proto native float EngineGetRPMRedline();
  67. //! Returns engine's rpm value.
  68. proto native float EngineGetRPM();
  69. //! Returns true when engine is running, false otherwise.
  70. proto native bool EngineIsOn();
  71. //! Starts the engine.
  72. proto native void EngineStart();
  73. //! Stops the engine.
  74. proto native void EngineStop();
  75. //! Returns the propeller position in local space
  76. proto native vector PropellerGetPosition();
  77. //! Returns the angular velocity of the propeller
  78. proto native float PropellerGetAngularVelocity();
  79. /*!
  80. Returns tank capacity for the specified vehicle's fluid.
  81. \param fluid the specified fluid type
  82. */
  83. proto native float GetFluidCapacity(BoatFluid fluid);
  84. /*!
  85. Returns fraction value (in range <0, 1>)
  86. of the current state of the specified vehicle's fluid.
  87. \param[in] fluid the specified fluid type
  88. */
  89. proto native float GetFluidFraction(BoatFluid fluid);
  90. //! Removes from the specified fluid the specified amount.
  91. proto native void Leak(BoatFluid fluid, float amount);
  92. //! Removes all the specified fluid from vehicle.
  93. proto native void LeakAll(BoatFluid fluid);
  94. //! Adds to the specified fluid the specified amount.
  95. proto native void Fill(BoatFluid fluid, float amount);
  96. /*!
  97. Called every physics simulation step before inputs are applied.
  98. */
  99. void OnInput(float dt) {}
  100. /*!
  101. Is called every time the game wants to start the engine.
  102. \return true if the engine can start, false otherwise.
  103. */
  104. bool OnBeforeEngineStart()
  105. {
  106. // engine can start by default
  107. return true;
  108. }
  109. /*!
  110. Is called every time the engine starts.
  111. */
  112. void OnEngineStart() {}
  113. /*!
  114. Is called every time the engine stops.
  115. */
  116. void OnEngineStop() {}
  117. /*!
  118. Is called every time when the simulation changed gear.
  119. \param[in] newGear new gear level
  120. \param[in] oldGear previous gear level before gear shift
  121. */
  122. void OnGearChanged(int newGear, int oldGear) {}
  123. /*!
  124. Is called every time when the specified vehicle's fluid level changes.
  125. This callback is called on owner only.
  126. \param[in] fluid fluid identifier, \see BoatFluid
  127. \param[in] newValue new fluid level
  128. \param[in] oldValue previous fluid level before change
  129. */
  130. void OnFluidChanged(BoatFluid fluid, float newValue, float oldValue) {}
  131. /*!
  132. Is called every sound simulation step.
  133. In this callback, user can modify behaviour of sound controllers.
  134. \param[in] ctrl sound controller identifier, \see BoatSoundCtrl
  135. \param[in] oldValue already computed value by the game code
  136. \return new value of the specified sound controller.
  137. */
  138. float OnSound(BoatSoundCtrl ctrl, float oldValue)
  139. {
  140. // just use the computed value by the game code
  141. return oldValue;
  142. }
  143. };