Ejemplo n.º 1
0
        public void Update()
        {
            OnFrameUpdate.Invoke();

            if (FlightGlobals.ActiveVessel == null || FlightGlobals.ActiveVessel.packed)
            {
                return;
            }
            var vs = Satellites[FlightGlobals.ActiveVessel];

            if (vs != null)
            {
                GetLocks();
                if (vs.HasLocalControl)
                {
                    ReleaseLocks();
                }
                else if (vs.FlightComputer != null && vs.FlightComputer.InputAllowed)
                {
                    foreach (KSPActionGroup ag in GetActivatedGroup())
                    {
                        vs.FlightComputer.Enqueue(ActionGroupCommand.WithGroup(ag));
                    }
                }
            }
            else
            {
                ReleaseLocks();
            }
        }
Ejemplo n.º 2
0
        private static void ActivateActionGroup(KSPActionGroup ag)
        {
            var satellite = RTCore.Instance.Satellites[FlightGlobals.ActiveVessel];

            if (satellite != null && satellite.FlightComputer != null)
            {
                satellite.SignalProcessor.FlightComputer.Enqueue(ActionGroupCommand.WithGroup(ag));
            }
            else if (satellite == null || (satellite != null && satellite.HasLocalControl))
            {
                if (FlightGlobals.ActiveVessel.IsControllable)
                {
                    FlightGlobals.ActiveVessel.ActionGroups.ToggleGroup(ag);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Called by the Unity engine during the game logic phase.
        /// This function is called once per frame. It is the main workhorse function for frame updates.
        /// </summary>
        public void Update()
        {
            OnFrameUpdate.Invoke();

            if (FlightGlobals.ActiveVessel == null || FlightGlobals.ActiveVessel.packed)
            {
                return;
            }
            var vs = Satellites[FlightGlobals.ActiveVessel];

            if (vs != null)
            {
                GetLocks();
                if (vs.HasLocalControl)
                {
                    ReleaseLocks();
                }
                else if (vs.FlightComputer != null && vs.FlightComputer.InputAllowed)
                {
#if !KSP131
                    var axisGroups = GetPressedAxisGroup();
                    for (int i = 0; i < axisGroups.Count(); i++)
                    {
                        if (axisGroups.ElementAt(i).Item2 != 0) //skip both - and + keys pressed at same time
                        {
                            vs.FlightComputer.Enqueue(AxisGroupCommand.WithGroup(axisGroups.ElementAt(i).Item1, axisGroups.ElementAt(i).Item2));
                        }
                    }
#endif

                    var actionGroups = GetActivatedActionGroup();
                    for (int i = 0; i < actionGroups.Count(); i++)
                    {
                        vs.FlightComputer.Enqueue(ActionGroupCommand.WithGroup(actionGroups.ElementAt(i)));
                    }
                }
            }
            else
            {
                ReleaseLocks();
            }
        }