public void AddAutopilotHook(Vessel vessel, FlightInputCallback hook) { // removing the callback if not already added doesn't throw an error // but adding it a 2nd time will result in 2 calls. Remove to be safe. vessel.OnPreAutopilotUpdate -= hook; vessel.OnPreAutopilotUpdate += hook; }
public void RemoveAutopilotHook(Vessel vessel, FlightInputCallback hook) { if (vessel != null) { vessel.OnPreAutopilotUpdate -= hook; } }
public void Update() { Vessel activeVessel = HighLogic.LoadedScene == GameScenes.FLIGHT ? FlightGlobals.ActiveVessel : null; if (attachedVessel != activeVessel) { if (callback != null) { attachedVessel.OnFlyByWire -= callback; callback = null; } attachedVessel = activeVessel; if (attachedVessel != null) { Strength = 5.0f; Enabled = false; TrajectoriesVesselSettings module = attachedVessel.Parts.SelectMany(p => p.Modules.OfType<TrajectoriesVesselSettings>()).FirstOrDefault(); if (module != null) { Enabled = module.AutoPilotEnabled; Strength = module.AutoPilotStrength; if (Strength < 0.5f) Strength = 5.0f; } callback = new FlightInputCallback((controls) => autoPilot(this, controls)); //activeVessel.OnFlyByWire += callback; // this is disabled for now, because it breaks Remote Tech signal delay } } Save(); }
public void Start() { if (m_Callback == null && HighLogic.LoadedSceneIsFlight) { m_Callback = new FlightInputCallback(m_FlightManager.OnFlyByWire); FlightGlobals.ActiveVessel.OnFlyByWire += m_Callback; } }
public void RemoveAutopilotHook(Vessel vessel, FlightInputCallback hook) { Action <FlightCtrlState> action; if (RemoteTechHook.IsAvailable(vessel.id) && callbacks.TryGetValue(hook, out action)) { RemoteTechHook.Instance.RemoveSanctionedPilot(vessel.id, action); callbacks.Remove(hook); } }
public void AddAutopilotHook(Vessel vessel, FlightInputCallback hook) { if (RemoteTechHook.IsAvailable(vessel.id)) { Action<FlightCtrlState> action; if (!callbacks.TryGetValue(hook, out action)) { action = new Action<FlightCtrlState>(hook); callbacks[hook] = action; } RemoteTechHook.Instance.AddSanctionedPilot(vessel.id, action); } }
public void AddAutopilotHook(Vessel vessel, FlightInputCallback hook) { if (RemoteTechHook.IsAvailable(vessel.id)) { Action <FlightCtrlState> action; if (!callbacks.TryGetValue(hook, out action)) { action = new Action <FlightCtrlState>(hook); callbacks[hook] = action; } RemoteTechHook.Instance.AddSanctionedPilot(vessel.id, action); } }
public void RemoveAutopilotHook(Vessel vessel, FlightInputCallback hook) { Action <FlightCtrlState> action; if (RemoteTechHook.IsAvailable(vessel.id) && callbacks.TryGetValue(hook, out action)) { RemoteTechHook.Instance.RemoveSanctionedPilot(vessel.id, action); callbacks.Remove(hook); // removing the callback from stock if not already added doesn't throw an error vessel.OnPreAutopilotUpdate -= hook; } else // remove fallback event hook { vessel.OnPreAutopilotUpdate -= hook; } }
public void AddAutopilotHook(Vessel vessel, FlightInputCallback hook) { if (RemoteTechHook.IsAvailable(vessel.id)) { Action <FlightCtrlState> action; if (!callbacks.TryGetValue(hook, out action)) { action = new Action <FlightCtrlState>(hook); callbacks[hook] = action; } RemoteTechHook.Instance.AddSanctionedPilot(vessel.id, action); } else // fallback to stock events when RT isn't available, this may have unexpected results if RT availability changes { // removing the callback if not already added doesn't throw an error // but adding it a 2nd time will result in 2 calls. Remove to be safe. vessel.OnPreAutopilotUpdate -= hook; vessel.OnPreAutopilotUpdate += hook; } }
public void Update() { Vessel activeVessel = HighLogic.LoadedScene == GameScenes.FLIGHT ? FlightGlobals.ActiveVessel : null; if (attachedVessel != activeVessel) { if (callback != null) { attachedVessel.OnFlyByWire -= callback; callback = null; } attachedVessel = activeVessel; if (attachedVessel != null) { Strength = 5.0f; Enabled = false; TrajectoriesVesselSettings module = attachedVessel.Parts.SelectMany(p => p.Modules.OfType <TrajectoriesVesselSettings>()).FirstOrDefault(); if (module != null) { Enabled = module.AutoPilotEnabled; Strength = module.AutoPilotStrength; if (Strength < 0.5f) { Strength = 5.0f; } } callback = new FlightInputCallback((controls) => autoPilot(this, controls)); //activeVessel.OnFlyByWire += callback; // this is disabled for now, because it breaks Remote Tech signal delay } } Save(); }
public void RemoveAutopilotHook(Vessel vessel, FlightInputCallback hook) { vessel.OnPreAutopilotUpdate -= hook; }
public static void RemoveAutopilotHook(Vessel vessel, FlightInputCallback hook) { Instance.RemoveAutopilotHook(vessel, hook); }
public void UnhookAutopilot(Vessel vessel, FlightInputCallback autopilot) { }
public void RemoveAutopilotHook(Vessel vessel, FlightInputCallback hook) { Action<FlightCtrlState> action; if (RemoteTechHook.IsAvailable(vessel.id) && callbacks.TryGetValue(hook, out action)) { RemoteTechHook.Instance.RemoveSanctionedPilot(vessel.id, action); callbacks.Remove(hook); } }
public static void AddAutopilotHook(Vessel vessel, FlightInputCallback hook) { Instance.AddAutopilotHook(vessel, hook); }