示例#1
0
        protected override void OnEnterToState(KFSMState kfsmState)
        {
            Log.Info("OnEnterToState: LaunchState");
            base.OnEnterToState(kfsmState);

            _audioSource = _obj.AddComponent <AudioSource>();
            _audioSource.spatialBlend = 0;
            _audioSource.volume       = GameSettings.VOICE_VOLUME;

            if (ConfigInfo.Instance.VesselOptions[ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel)].LaunchSequenceControl)
            {
                FlightGlobals.ActiveVessel.OnFlyByWire = (FlightInputCallback)Delegate.Combine(FlightGlobals.ActiveVessel.OnFlyByWire, (FlightInputCallback)OnFlyByWire);
            }

            GameEvents.onVesselSituationChange.Add(SituationChanged);

            if (!ConfigInfo.Instance.Sequences.ContainsKey(ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel)))
            {
                ConfigInfo.Instance.Sequences.Add(ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel), Enumerable.Repeat(-1, 10).ToArray());
                ConfigInfo.Instance.VesselOptions.Add(ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel), new PerVesselOptions());
            }
            _stages = ConfigInfo.Instance.Sequences[ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel)].Select(x => x < 0 ? new Action(() => { }) : new Action(() => { if (ConfigInfo.Instance.VesselOptions[ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel)].LaunchSequenceControl)
                                                                                                                                                                              {
                                                                                                                                                                                  StageManager.ActivateStage(x);
                                                                                                                                                                              }
                                                                                                                                                                      })).ToList();


            _dummy.StartCoroutine(this.TickLaunch());
        }
示例#2
0
 public void InitNewConfig()
 {
     if (FlightGlobals.ActiveVessel != null && !ConfigInfo.Instance.Sequences.ContainsKey(ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel)))
     {
         Log.Info("InitNewConfig for " + ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel));
         Sequences.Add(ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel), Enumerable.Repeat(-1, 10).ToArray());
         VesselOptions.Add(ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel), new PerVesselOptions());
     }
 }
示例#3
0
 protected override void OnLeaveFromState(KFSMState kfsmState)
 {
     Log.Info("OnLeaveFromState: LaunchState");
     base.OnLeaveFromState(kfsmState);
     if (ConfigInfo.Instance.VesselOptions[ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel)].LaunchSequenceControl)
     {
         Log.Info("Removing OnFlyByWire");
         FlightGlobals.ActiveVessel.OnFlyByWire = (FlightInputCallback)Delegate.Remove(FlightGlobals.ActiveVessel.OnFlyByWire, (FlightInputCallback)OnFlyByWire);
     }
     GameEvents.onVesselSituationChange.Remove(SituationChanged);
 }
示例#4
0
        private void OnFlyByWire(FlightCtrlState st)
        {
            Log.Info("OnFlyByWire, tic: " + _tick);
            switch (_tick)
            {
            case 7:
            case 6:
            case 5:
            case 4:
            case 3:
            case 2:
            case 1:
                st.mainThrottle = ConfigInfo.Instance.VesselOptions[ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel)].defaultInitialThrottle;
                break;

            case 0:
                //st.mainThrottle = 1f;
                Log.Info("OnFlyByWire, before GravityTurnAPI.Launch");
                if (GravityTurnAPI.Launch())      // If GravityTurn is available
                {
                    break;
                }

                st.mainThrottle = ConfigInfo.Instance.VesselOptions[ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel)].defaultThrottle;
                if (ConfigInfo.Instance.VesselOptions[ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel)].enableSAS)
                {
                    FlightGlobals.ActiveVessel.ActionGroups.SetGroup(KSPActionGroup.SAS, true);
                }

                break;

            default:
                if (ConfigInfo.Instance.VesselOptions[ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel)].enableSAS)
                {
                    FlightGlobals.ActiveVessel.ActionGroups.SetGroup(KSPActionGroup.SAS, true);
                }
                //st.mainThrottle = 0f;
                st.mainThrottle = ConfigInfo.Instance.VesselOptions[ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel)].defaultThrottle;
                break;
            }
        }
示例#5
0
        public ConfigNode Load()
        {
            LoadSounds();
            Log.Info("ConfigInfo.Load");
            ConfigNode settingsFile = ConfigNode.Load(PLUGINDATA);
            ConfigNode node         = null;

            if (settingsFile != null)
            {
                node = settingsFile.GetNode(SETTINGSNAME);
                if (node != null)
                {
                    if (node.HasValue("soundEnabled"))
                    {
                        IsSoundEnabled = bool.Parse(node.GetValue("soundEnabled"));
                    }

                    if (node.HasValue("abort"))
                    {
                        AbortExecuted = bool.Parse(node.GetValue("abort"));
                    }

                    if (node.HasValue("scale"))
                    {
                        Scale = float.Parse(node.GetValue("scale"));
                    }

                    if (node.HasValue("soundSet"))
                    {
                        SoundSet = node.GetValue("soundSet");
                    }

                    if (node.HasValue("position"))
                    {
                        WindowPosition = _wrapper.ToRect(node.GetValue("position"));
                        Debug.LogWarning("Position is" + WindowPosition);
                    }

                    if (node.HasNode("sequence"))
                    {
                        var sequences = node.GetNodes("sequence");
                        Sequences.Clear();
                        VesselOptions.Clear();

                        foreach (var sequence in sequences)
                        {
                            PerVesselOptions pvo = new PerVesselOptions();
                            if (sequence.HasValue("LaunchSequenceControl"))
                            {
                                pvo.LaunchSequenceControl = bool.Parse(sequence.GetValue("LaunchSequenceControl"));
                            }

                            if (sequence.HasValue("enableSAS"))
                            {
                                pvo.enableSAS = bool.Parse(sequence.GetValue("enableSAS"));
                            }

                            if (sequence.HasValue("defaultInitialThrottle"))
                            {
                                pvo.defaultInitialThrottle = float.Parse(sequence.GetValue("defaultInitialThrottle"));
                            }
                            if (sequence.HasValue("defaultThrottle"))
                            {
                                pvo.defaultThrottle = float.Parse(sequence.GetValue("defaultThrottle"));
                            }

                            if (sequence.HasValue("useGravityTurn"))
                            {
                                pvo.useGravityTurn = bool.Parse(sequence.GetValue("useGravityTurn"));
                            }
                            VesselOptions.Add(sequence.GetValue("id"), pvo);

                            int[] ar = Enumerable.Repeat(-1, 10).ToArray();
                            var   d  = sequence.GetValue("stages").Split(',').Select(int.Parse).ToArray();
                            for (int i = 0; i < d.Length; i++)
                            {
                                //Log.Info("Load, i: " + i + ", " + d[i]);
                                ar[i] = d[i];
                            }
                            Sequences.Add(sequence.GetValue("id"), ar);
                        }
                    }
                    else
                    {
                        Sequences.Clear();
                        VesselOptions.Clear();
                        if (FlightGlobals.ActiveVessel != null && !ConfigInfo.Instance.Sequences.ContainsKey(ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel)))
                        {
                            Sequences.Add(ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel), Enumerable.Repeat(-1, 10).ToArray());
                            VesselOptions.Add(ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel), new PerVesselOptions());
                        }
                    }

                    IsLoaded = true;
                }
            }
            else
            {
                Sequences.Clear();
                VesselOptions.Clear();
            }
            return(node);
        }