/// <summary> /// Unhook from events we previously hooked up to. /// </summary> private void UnHookEvents() { ConnectivityManager.RemoveAutopilotHook(parentVessel, UpdateAutopilot); if (Vessel.vesselType != VesselType.Unknown && Vessel.vesselType != VesselType.SpaceObject) { TimingManager.FixedUpdateRemove(TimingManager.TimingStage.ObscenelyEarly, cacheControllable); TimingManager.FixedUpdateRemove(TimingManager.TimingStage.BetterLateThanNever, resetControllable); } }
/// <summary> /// Unhook from events we previously hooked up to. /// </summary> private void UnHookEvents() { ConnectivityManager.RemoveAutopilotHook(Vessel, UpdateAutopilot); if (workAroundEventsEnabled) { TimingManager.FixedUpdateRemove(TimingManager.TimingStage.ObscenelyEarly, CacheControllable); TimingManager.FixedUpdateRemove(TimingManager.TimingStage.BetterLateThanNever, resetControllable); workAroundEventsEnabled = false; } }
public void Unbind() { SafeHouse.Logger.Log("FlightControl Unbinding"); if (!bound) { return; } ConnectivityManager.RemoveAutopilotHook(Vessel, OnFlyByWire); bound = false; SafeHouse.Logger.Log("FlightControl Unbound"); }
public override void Update() { UnbindUnloaded(); // Why the "currentVessel != null checks? // Because of a timing issue where it can still be set to null during the span of one single // update if the new vessel isn't valid and set up yet when the old vessel connection got // broken off. // if (currentVessel != null && currentVessel.id == Shared.Vessel.id) { if (ConnectivityManager.NeedAutopilotResubscribe) { if (++counterRemoteTechRefresh > RemoteTechRehookPeriod) { ConnectivityManager.AddAutopilotHook(currentVessel, OnFlyByWire); } } else { counterRemoteTechRefresh = RemoteTechRehookPeriod - 2; } return; } // If it gets this far, that means the part the kOSProcessor module is inside of // got disconnected from its original vessel and became a member // of a new child vessel, either due to undocking, decoupling, or breakage. // currentVessel is now a stale reference to the vessel this manager used to be a member of, // while Shared.Vessel is the new vessel it is now contained in. // Before updating currentVessel, use it to break connection from the old vessel, // so this this stops trying to pilot the vessel it's not attached to anymore: if (currentVessel != null && VesselIsValid(currentVessel)) { ConnectivityManager.RemoveAutopilotHook(currentVessel, OnFlyByWire); currentVessel = null; } // If the new vessel isn't ready for it, then don't attach to it yet (wait for a future update): if (!VesselIsValid(Shared.Vessel)) { return; } // Now attach to the new vessel: currentVessel = Shared.Vessel; ConnectivityManager.AddAutopilotHook(currentVessel, OnFlyByWire); foreach (var param in flightParameters.Values) { param.UpdateFlightControl(currentVessel); } // If any paramers were removed in UnbindUnloaded, add them back here AddMissingFlightParam("throttle", Shared); AddMissingFlightParam("steering", Shared); AddMissingFlightParam("wheelthrottle", Shared); AddMissingFlightParam("wheelsteering", Shared); }