Beispiel #1
0
        public void List()
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            Stellarium.GET(Path, "list", parameters, (result, error) => {
                if (error != null)
                {
                    Debug.LogError(string.Format("[{0}] {1}", Identifier, error)); return;
                }
                JSONObject json = new JSONObject(result);
                ActionGroupList actionGroupList = new ActionGroupList();
                actionGroupList.actionGroups    = new ActionGroup();
                foreach (string actionGroupName in json.keys)
                {
                    int numberOfActions   = json.GetField(actionGroupName).Count;
                    ActionList actionList = new ActionList();
                    actionList.actions    = new Action[numberOfActions];
                    for (int i = 0; i < numberOfActions; i++)
                    {
                        actionList.actions[i] = JsonUtility.FromJson <Action>(json.GetField(actionGroupName)[i].ToString());
                    }
                    actionGroupList.actionGroups.Add(actionGroupName, actionList);
                }
                if (OnGotList != null)
                {
                    OnGotList(actionGroupList);
                }
            });
        }
Beispiel #2
0
        public void memWrite(ushort position, int value)
        {
            lastInput = value;
            ActionGroupList a = this.vessel.ActionGroups;

            switch (value)
            {
            case 1:
                a.ToggleGroup(KSPActionGroup.Custom01);
                break;

            case 2:
                a.ToggleGroup(KSPActionGroup.Custom02);
                break;

            case 3:
                a.ToggleGroup(KSPActionGroup.Custom03);
                break;

            case 4:
                a.ToggleGroup(KSPActionGroup.Custom04);
                break;

            case 5:
                a.ToggleGroup(KSPActionGroup.Custom05);
                break;

            case 6:
                a.ToggleGroup(KSPActionGroup.Custom06);
                break;

            case 7:
                a.ToggleGroup(KSPActionGroup.Custom07);
                break;

            case 8:
                a.ToggleGroup(KSPActionGroup.Custom08);
                break;

            case 9:
                a.ToggleGroup(KSPActionGroup.Custom09);
                break;

            case 10:
                a.ToggleGroup(KSPActionGroup.Custom10);
                break;

            case 11:
                a.ToggleGroup(KSPActionGroup.Abort);
                break;

            case 12:
                if (Staging.CurrentStage > 0)
                {
                    Staging.ActivateNextStage();
                }
                break;
            }
        }
Beispiel #3
0
 private void ActionService_OnGotList(ActionGroupList result)
 {
     foreach (KeyValuePair <string, ActionList> actionList in result.actionGroups)
     {
         StellariumServer.Instance.ActionService.Do(actionList.Value.actions[0].text); //Invalid id
         return;
     }
 }
Beispiel #4
0
 public static bool SetIfNot(this ActionGroupList actions, KSPActionGroup group, bool value)
 {
     if (actions.GetGroup(group) ^ value)
     {
         actions.ToggleGroup(group);
         return(true);
     }
     return(false);
 }
Beispiel #5
0
        private void ActivateActionGroup(int i)
        {
            ActionGroupList a = mSignalProcessor.Vessel.ActionGroups;

            switch (i)
            {
            case 1:
                a.ToggleGroup(KSPActionGroup.Custom01);
                break;

            case 2:
                a.ToggleGroup(KSPActionGroup.Custom02);
                break;

            case 3:
                a.ToggleGroup(KSPActionGroup.Custom03);
                break;

            case 4:
                a.ToggleGroup(KSPActionGroup.Custom04);
                break;

            case 5:
                a.ToggleGroup(KSPActionGroup.Custom05);
                break;

            case 6:
                a.ToggleGroup(KSPActionGroup.Custom06);
                break;

            case 7:
                a.ToggleGroup(KSPActionGroup.Custom07);
                break;

            case 8:
                a.ToggleGroup(KSPActionGroup.Custom08);
                break;

            case 9:
                a.ToggleGroup(KSPActionGroup.Custom09);
                break;

            case 10:
                a.ToggleGroup(KSPActionGroup.Custom10);
                break;

            case 11:
                a.ToggleGroup(KSPActionGroup.Abort);
                break;

            case 12:
                Staging.ActivateNextStage();
                break;
            }
        }
        void Activate(VesselSettings vessel)
        {
            Debug.Log($"[{nameof(AutoAction)}] flight: Activate");

            // Loading facility default settings
            FacilitySettings facility = GetFacilitySettings();

            // Selecting action set
            if (vessel.ActionSet is int set)
            {
                Static.Vessel.SetGroupOverride(FlightGlobals.ActiveVessel, set);
            }

            // Activating standard action groups
            ActionGroupList actionGroups = FlightGlobals.ActiveVessel.ActionGroups;

            actionGroups.SetGroup(KSPActionGroup.SAS, vessel.ActivateSAS ?? facility.ActivateSAS);
            actionGroups.SetGroup(KSPActionGroup.RCS, vessel.ActivateRCS ?? facility.ActivateRCS);
            actionGroups.SetGroup(KSPActionGroup.Brakes, vessel.ActivateBrakes ?? facility.ActivateBrakes);
            actionGroups.SetGroup(KSPActionGroup.Abort, vessel.ActivateAbort ?? facility.ActivateAbort);
            // Special treatment for the groups with the initial state determined by the part state
            SetAutoInitializingGroup(KSPActionGroup.Gear, vessel.ActivateGear);
            SetAutoInitializingGroup(KSPActionGroup.Light, vessel.ActivateLights);

            // Activating custom action groups
            foreach (int customGroup in vessel.CustomGroups.OfType <int>())
            {
                ActivateCustomActionGroup(customGroup);
            }

            // Setting precision control
            SetPrecisionMode(vessel.SetPrecCtrl ?? facility.SetPrecCtrl);

            // Setting throttle
            FlightInputHandler.state.mainThrottle = Mathf.Max(0, Mathf.Min(1, (vessel.SetThrottle ?? facility.SetThrottle) / 100F));

            // Setting trim
            FlightInputHandler.state.pitchTrim         = TrimStep * vessel.SetPitchTrim;
            FlightInputHandler.state.yawTrim           = TrimStep * vessel.SetYawTrim;
            FlightInputHandler.state.rollTrim          = TrimStep * vessel.SetRollTrim;
            FlightInputHandler.state.wheelThrottleTrim = TrimStep * vessel.SetWheelMotorTrim;
            FlightInputHandler.state.wheelSteerTrim    = -TrimStep * vessel.SetWheelSteerTrim;              // inverted

            // Staging
            if (vessel.Stage ?? facility.Stage)
            {
                StageManager.ActivateNextStage();
            }
        }
Beispiel #7
0
        // executes the abort action group and write event to log
        public void executeAbort()
        {
            if (auto_destruct_active)
            {
                return;
            }

            string log_entry = Localizer.GetStringByTag("#autoLOC_OCTO_RED_SELF_DESTRUCT_ACTIVATED");

            FlightLogger.eventLog.Add(log_entry);

            ActionGroupList groups = vessel.ActionGroups;

            groups.SetGroup(KSPActionGroup.Abort, true);
        }
        private static void PostFixToggleGroup(ActionGroupList __instance, KSPActionGroup group)
        {
            if (MainSystem.NetworkState < ClientState.Connected)
            {
                return;
            }

            var groupIndex = BaseAction.GetGroupIndex(group);

            if (Planetarium.GetUniversalTime() < __instance.cooldownTimes[groupIndex])
            {
                //This action group has a cooldown time and it wasn't triggered so ignore the event.
                return;
            }

            ActionGroupEvent.onActionGroupFired.Fire(__instance.v, group, __instance.groups[groupIndex]);
        }
Beispiel #9
0
 public static bool GetGroup(this ActionGroupList actions, KSPActionGroup group)
 {
     return(actions.groups[BaseAction.GetGroupIndex(group)]);
 }