public void drive(FlightCtrlState s)
{
if (!vessel.isActiveVessel)
{
delayedBuffer.setNeutral(s);
}
if (!localControl)
{
if (!InContact || !powered)
{
//lock out the player if we are out of radio contact or out of power
delayedBuffer.setNeutral(s);
}
else
if (vessel.isActiveVessel)
{
//this is a somewhat crude fix for the buggy throttle controls introduced in KSP 0.17. It works nicely though.
if (GameSettings.AXIS_THROTTLE.GetAxis() == this.LastAxisThrottle)
{
if (!DockingMode)
{
if (GameSettings.THROTTLE_UP.GetKey())
{
lastThrottle = Mathf.Clamp(lastThrottle + 0.01f, 0, 1);
}
if (GameSettings.THROTTLE_DOWN.GetKey())
{
lastThrottle = Mathf.Clamp(lastThrottle - 0.01f, 0, 1);
}
}
lastThrottle = Mathf.Clamp(lastThrottle + GameSettings.AXIS_THROTTLE_INC.GetAxis() * 0.01f, 0, 1);
s.mainThrottle = lastThrottle;
}
else if (RTUtils.AppFocus)
{
LastAxisThrottle = GameSettings.AXIS_THROTTLE.GetAxis();
s.mainThrottle = lastThrottle = Mathf.Clamp((LastAxisThrottle + 1) / 2, 0, 1);
}
if (GameSettings.THROTTLE_CUTOFF.GetKey())
{
s.mainThrottle = lastThrottle = 0;
}
delayedBuffer.push(s, Planetarium.GetUniversalTime() + path.ControlDelay);
delayedBuffer.pop(s, Planetarium.GetUniversalTime());
}
}
s.killRot = flightComputerGUI.attitudeButtons[0].state.Active;
vessel.ActionGroups.SetGroup(KSPActionGroup.SAS, flightComputerGUI.attitudeButtons[0].state.Active);
if (powered)
{
computer.drive(s);
}
//this makes sure that the navball readout shows the delayed throttle. Since it reads directly from the FlightInputHandlers throttle state.
if (vessel.isActiveVessel)
{
FlightInputHandler.state.mainThrottle = s.mainThrottle;
}
}