//Keeps engine running after changing seats IEnumerator WhileHovering(MiniCopter minicopter, Rigidbody rb) { if (_config.Hovering.timedHover) { string position = minicopter.transform.position.ToString(); Timer hovertime = timer.Once(_config.Hovering.hoverDuration, () => { if (minicopter != null) { helicopterHovering[minicopter.GetInstanceID()] = false; minicopter.EngineOff(); rb.constraints = RigidbodyConstraints.None; minicopter.EngineOn(); minicopter.StopAllCoroutines(); } else { PrintError(lang.GetMessage("ErrorFound", this) + $"at {position}"); } }); } while (helicopterHovering[minicopter.GetInstanceID()]) { if (!minicopter.IsEngineOn() && minicopter.HasAnyPassengers() && minicopter.HasFuel() || !_config.Hovering.disableHoverOnDismount && !minicopter.HasAnyPassengers() && !minicopter.IsEngineOn() && minicopter.HasFuel()) { minicopter.EngineStartup(); } if (minicopter.HasDriver() && minicopter.HasFuel()) { minicopter.EngineOn(); } if (_config.Hovering.useFuelOnHover && minicopter.HasFuel()) { if (Time.time - helicopterFuelUseTime[minicopter.GetInstanceID()] > 1) { minicopter.UseFuel(minicopter.fuelPerSec); helicopterFuelUseTime[minicopter.GetInstanceID()] = Time.time; } } if ((!minicopter.HasFuel() && !_config.Hovering.disableHoverOnDismount) || (_config.Hovering.disableHoverOnSeat && minicopter.HasAnyPassengers() && minicopter.HasDriver() == false)) { minicopter.EngineOff(); rb.constraints = RigidbodyConstraints.None; minicopter.StopAllCoroutines(); } yield return(1); } if (!helicopterHovering[minicopter.GetInstanceID()]) { yield break; } }