DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ OnInput()

override void OnInput ( float dt)
protected

См. определение в файле MotorbikeScript.c строка 837

838 {
839 super.OnInput(dt);
840
841#ifdef DIAG_DEVELOPER
842 if (m_DebugMode == EMotorbikeDebugMode.NONE)
843 return;
844
845 float currentRPM = EngineGetRPM();
846 if (currentRPM < EngineGetRPMIdle())
847 {
848 if (currentRPM < 1.0 && EngineIsOn())
849 {
851 EngineStop();
852 }
853 else if (!EngineIsOn())
854 {
855 EngineStart();
856 }
857
858 return;
859 }
860
861 float speed = GetSpeedometerAbsolute();
862
863 float thrustWanted = 0.0;
864 float steeringWanted = 0.0;
865
866 bool attemptSpeed = false;
867 float speedWanted = 0;
868
869 switch (m_DebugMode)
870 {
871 case EMotorbikeDebugMode.FORWARD_10:
872 attemptSpeed = true;
873 speedWanted = 10;
874 break;
875 case EMotorbikeDebugMode.FORWARD_50:
876 attemptSpeed = true;
877 speedWanted = 50;
878 break;
879 }
880
881 if (attemptSpeed)
882 {
883 // very basic and doesn't actually work
884 thrustWanted = Math.Clamp(1.0 - Math.InverseLerp(0, speedWanted, speed), 0, 1);
885 }
886
887 bool isManual = GearboxGetType() == CarGearboxType.MANUAL;
888 bool isReverse = GetGear() == CarGear.REVERSE;
889
890 if (isManual)
891 {
892 float thrustWantedAbs = Math.AbsFloat(thrustWanted);
893
894 if (currentRPM > EngineGetRPMRedline() * 0.8)
895 {
896 if (thrustWantedAbs > 0.1)
897 {
898 ShiftUp();
899 }
900 }
901 else if (GetGear() > CarGear.FIRST && thrustWantedAbs < 0.1)
902 {
903 ShiftDown();
904 }
905 else if (GetGear() < CarGear.FIRST || (thrustWanted > 0.0 && speed < 5.0))
906 {
907 ShiftTo(CarGear.FIRST);
908 }
909 }
910
911 SetThrottle(thrustWanted);
912 SetSteering(steeringWanted);
913 SetBrake(0.0);
914 SetHandbrake(0.0);
915 SetKickstand(0.0);
916#endif
917 }
CarGearboxType
Enumerated gearbox types. (native, do not change or extend)
Определения Car.c:24
proto native void ShiftTo(int gear)
Shifts the future gear to selected gear, triggering gearbox simulation.
proto native void SetThrottle(float value)
Sets the future throttle value.
proto native float EngineGetRPMRedline()
Returns engine's maximal working rpm without damaging the engine.
proto native void SetHandbrake(float value)
Sets the future front brake value.
proto native CarGearboxType GearboxGetType()
Returns gearbox type. See CarGearboxType enum for more info.
proto native void SetKickstand(float value)
Sets the future kickstand value.
proto native void EngineStop()
Stops the engine.
proto native void SetBrake(float value)
Sets the future rear brake value.
proto native bool EngineIsOn()
Returns true when engine is running, false otherwise.
proto native float EngineGetRPMIdle()
Returns engine's idle rpm before engine stalls.
proto native void ShiftDown()
Shifts the future gear down, triggering gearbox simulation.
proto native void ShiftUp()
Shifts the future gear up, triggering gearbox simulation.
proto native void EngineStart()
Starts the engine.
proto native float EngineGetRPM()
Returns engine's rpm value.
proto native void SetSteering(float value)
Sets the future steering value.
proto native int GetGear()
Returns the index of the future gear, -1 if there is no engine.
float GetSpeedometerAbsolute()
Returns the current speed of the vehicle in km/h. Value is absolute.
Определения Motorbike.c:55
Определения EnMath.c:7
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
static proto float AbsFloat(float f)
Returns absolute value.

Перекрестные ссылки Math::AbsFloat(), Math::Clamp(), EngineGetRPM(), EngineGetRPMIdle(), EngineGetRPMRedline(), EngineIsOn(), EngineStart(), EngineStop(), GearboxGetType(), GetGear(), GetSpeedometerAbsolute(), Math::InverseLerp(), SetBrake(), SetHandbrake(), SetKickstand(), SetSteering(), SetThrottle(), ShiftDown(), ShiftTo() и ShiftUp().