Пример #1
0
        private void CreateFactory()
        {
            SafeHouse.Logger.LogWarning("Starting Factory Building");
            bool isAvailable;

            try
            {
                isAvailable = RemoteTechHook.IsAvailable(vessel.id);
            }
            catch
            {
                isAvailable = false;
            }

            if (isAvailable)
            {
                SafeHouse.Logger.LogWarning("RemoteTech Factory Building");
                shared.Factory = new RemoteTechFactory();
            }
            else
            {
                SafeHouse.Logger.LogWarning("Standard Factory Building");
                shared.Factory = new StandardFactory();
            }
        }
Пример #2
0
        public static double GetTotalWaitTime(Vessel vessel)
        {
            double waitTotal = 0;

            if (RemoteTechHook.IsAvailable(vessel.id) && vessel.GetVesselCrew().Count == 0)
            {
                waitTotal = RemoteTechHook.Instance.GetShortestSignalDelay(vessel.id);
            }

            return(waitTotal);
        }
Пример #3
0
 /// <summary>
 /// Hook up to any vessel/game events that might be needed.
 /// </summary>
 private void HookEvents()
 {
     if (RemoteTechHook.IsAvailable(parentVessel.id))
     {
         HookRemoteTechPilot();
     }
     else
     {
         HookStockPilot();
     }
 }
Пример #4
0
 /// <summary>
 /// Unhook from events we previously hooked up to.
 /// </summary>
 private void UnHookEvents()
 {
     if (RemoteTechHook.IsAvailable(parentVessel.id))
     {
         RemoteTechHook.Instance.RemoveSanctionedPilot(parentVessel.id, UpdateAutopilot);
     }
     else
     {
         parentVessel.OnPreAutopilotUpdate -= UpdateAutopilot;
     }
     GameEvents.onPartCouple.Remove(OnDocking);
 }
Пример #5
0
 /// <summary>
 /// A race condition exists where KSP can load the kOS module onto the vessel
 /// before it loaded the RemoteTech module.  That makes it so that kOS may not
 /// see the existence of RT yet when kOS is first initialized.<br/>
 /// <br/>
 /// This fixes that case by continually re-querying for RT post-loading, and
 /// re-initializing kOS's RT-related behaviors if it seems that the RT module
 /// now exists when it didn't before (or visa versa).
 /// </summary>
 private void CheckSwapEvents()
 {
     if (RemoteTechHook.IsAvailable(parentVessel.id) != hasRemoteTech)
     {
         if (hasRemoteTech)
         {
             UnHookRemoteTechPilot();
             HookStockPilot();
         }
         else
         {
             UnHookStockPilot();
             HookRemoteTechPilot();
         }
     }
 }
Пример #6
0
        /// <summary>
        /// Trigger whatever code the PartModule has attached to this Event, given the kOS name for the suffix.
        /// </summary>
        /// <param name="suffixName"></param>
        private void CallKSPEvent(StringValue suffixName)
        {
            ThrowIfNotCPUVessel();
            BaseEvent evt = GetEvent(suffixName);
            if (evt == null)
                throw new KOSLookupFailException("EVENT", suffixName, this);
            if (!EventIsVisible(evt))
                throw new KOSLookupFailException("EVENT", suffixName, this, true);

            if (RemoteTechHook.IsAvailable())
            {
                RemoteTechHook.Instance.InvokeOriginalEvent(evt);
            }
            else
            {
                evt.Invoke();
            }
        }
Пример #7
0
        public void Unbind()
        {
            UnityEngine.Debug.Log("kOS: FlightControl Unbinding");
            if (!bound)
            {
                return;
            }

            if (RemoteTechHook.IsAvailable())
            {
                RemoteTechHook.Instance.RemoveSanctionedPilot(Vessel.id, OnFlyByWire);
            }
            else
            {
                Vessel.OnFlyByWire -= OnFlyByWire;
            }
            bound = false;
            UnityEngine.Debug.Log("kOS: FlightControl Unbound");
        }
Пример #8
0
        private void Bind()
        {
            UnityEngine.Debug.Log("kOS: FlightControl Binding");
            if (bound)
            {
                return;
            }

            if (RemoteTechHook.IsAvailable(Vessel.id))
            {
                RemoteTechHook.Instance.AddSanctionedPilot(Vessel.id, OnFlyByWire);
            }
            else
            {
                Vessel.OnFlyByWire += OnFlyByWire;
            }
            bound = true;
            UnityEngine.Debug.Log("kOS: FlightControl Bound");
        }
Пример #9
0
        private void Bind()
        {
            if (bound)
            {
                return;
            }
            SafeHouse.Logger.Log("FlightControl Binding");

            if (RemoteTechHook.IsAvailable(Vessel.id))
            {
                RemoteTechHook.Instance.AddSanctionedPilot(Vessel.id, OnFlyByWire);
            }
            else
            {
                Vessel.OnPreAutopilotUpdate += OnFlyByWire;
            }
            bound = true;
            SafeHouse.Logger.Log("FlightControl Bound");
        }
Пример #10
0
        public void Unbind()
        {
            SafeHouse.Logger.Log("FlightControl Unbinding");
            if (!bound)
            {
                return;
            }

            if (RemoteTechHook.IsAvailable())
            {
                RemoteTechHook.Instance.RemoveSanctionedPilot(Vessel.id, OnFlyByWire);
            }
            else
            {
                Vessel.OnPreAutopilotUpdate -= OnFlyByWire;
            }
            bound = false;
            SafeHouse.Logger.Log("FlightControl Unbound");
        }
Пример #11
0
            public void OnFlyByWire(ref FlightCtrlState c)
            {
                if (value == null || !Enabled)
                {
                    return;
                }

                var action = ChooseAction();

                if (action == null)
                {
                    return;
                }

                if (!RemoteTechHook.IsAvailable(control.Vessel.id))
                {
                    action.Invoke(c);
                }
            }
Пример #12
0
 public void SelectAutopilotMode(VesselAutopilot.AutopilotMode autopilotMode)
 {
     if (currentVessel.Autopilot.Mode != autopilotMode)
     {
         if (!currentVessel.Autopilot.CanSetMode(autopilotMode))
         {
             // throw an exception if the mode is not available
             throw new Safe.Exceptions.KOSException(
                       string.Format("Cannot set autopilot value, pilot/probe does not support {0}, or there is no node/target", autopilotMode));
         }
         currentVessel.Autopilot.SetMode(autopilotMode);
         //currentVessel.Autopilot.Enable();
         // change the autopilot indicator
         ((Module.kOSProcessor)Shared.Processor).SetAutopilotMode((int)autopilotMode);
         if (RemoteTechHook.IsAvailable(currentVessel.id))
         {
             Debug.Log(string.Format("kOS: Adding RemoteTechPilot: autopilot For : " + currentVessel.id));
             // TODO: figure out how to make RemoteTech allow the built in autopilot control.  This may require modification to RemoteTech itself.
         }
     }
 }
Пример #13
0
 /// <summary>
 /// A race condition exists where KSP can load the kOS module onto the vessel
 /// before it loaded the RemoteTech module.  That makes it so that kOS may not
 /// see the existence of RT yet when kOS is first initialized.<br/>
 /// <br/>
 /// This fixes that case by continually re-querying for RT post-loading, and
 /// re-initializing kOS's RT-related behaviors if it seems that the RT module
 /// now exists when it didn't before (or visa versa).
 /// </summary>
 private void CheckSwapEvents()
 {
     if (RemoteTechHook.IsAvailable(parentVessel.id) != hasRemoteTech)
     {
         if (hasRemoteTech)
         {
             UnHookRemoteTechPilot();
             HookStockPilot();
         }
         else
         {
             UnHookStockPilot();
             HookRemoteTechPilot();
         }
     }
     if (hasRemoteTech)
     {
         if (++counterRemoteTechRefresh > RemoteTechRehookPeriod)
         {
             counterRemoteTechRefresh = 0;
             HookRemoteTechPilot();
         }
     }
 }