コード例 #1
0
 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;
 }
コード例 #2
0
 public void RemoveAutopilotHook(Vessel vessel, FlightInputCallback hook)
 {
     if (vessel != null)
     {
         vessel.OnPreAutopilotUpdate -= hook;
     }
 }
コード例 #3
0
 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;
 }
コード例 #4
0
ファイル: AutoPilot.cs プロジェクト: se5a/KSPTrajectories
        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();
        }
コード例 #5
0
 public void Start()
 {
     if (m_Callback == null && HighLogic.LoadedSceneIsFlight)
     {
         m_Callback = new FlightInputCallback(m_FlightManager.OnFlyByWire);
         FlightGlobals.ActiveVessel.OnFlyByWire += m_Callback;
     }
 }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
 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);
     }
 }
コード例 #8
0
 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);
     }
 }
コード例 #9
0
        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;
            }
        }
コード例 #10
0
 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;
     }
 }
コード例 #11
0
        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();
        }
コード例 #12
0
 public void RemoveAutopilotHook(Vessel vessel, FlightInputCallback hook)
 {
     vessel.OnPreAutopilotUpdate -= hook;
 }
コード例 #13
0
 public static void RemoveAutopilotHook(Vessel vessel, FlightInputCallback hook)
 {
     Instance.RemoveAutopilotHook(vessel, hook);
 }
コード例 #14
0
 public void UnhookAutopilot(Vessel vessel, FlightInputCallback autopilot)
 {
 }
コード例 #15
0
 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);
     }
 }
コード例 #16
0
ファイル: ConnectivityManager.cs プロジェクト: KSP-KOS/KOS
 public static void AddAutopilotHook(Vessel vessel, FlightInputCallback hook)
 {
     Instance.AddAutopilotHook(vessel, hook);
 }