Exemplo n.º 1
0
        private void OnFlyByWire(FlightCtrlState st)
        {
            switch (_tick)
            {
            case 7:
            case 6:
            case 5:
            case 4:
            case 3:
            case 2:
            case 1:
                st.mainThrottle = HighLogic.CurrentGame.Parameters.CustomParams <NC>().defaultInitialThrottle;
                break;

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

                st.mainThrottle = HighLogic.CurrentGame.Parameters.CustomParams <NC>().defaultThrottle;
                FlightGlobals.ActiveVessel.ActionGroups.SetGroup(KSPActionGroup.SAS, true);

                break;

            default:
                //st.mainThrottle = 0f;
                st.mainThrottle = HighLogic.CurrentGame.Parameters.CustomParams <NC>().defaultThrottle;
                break;
            }
        }
Exemplo n.º 2
0
        private IEnumerator Abort()
        {
            TimeWarp.SetRate(0, false);
            var clip = ConfigInfo.Instance.CurrentAudio.Abort;

            if (GravityTurnAPI.GravityTurnActive)
            {
                GravityTurnAPI.Kill();
            }
            holdPlayed = true;


            if (clip != null)
            {
                CountDownMain.instance.PlaySound(clip);
            }

            if (ConfigInfo.Instance.AbortExecuted)
            {
                FlightGlobals.ActiveVessel.ActionGroups.SetGroup(KSPActionGroup.Abort, true);
                // FireAction added a new parameter, overridegroup with no idea what it's for
                //BaseAction.FireAction(FlightGlobals.ActiveVessel.Parts, KSPActionGroup.Abort,0, KSPActionType.Activate);
            }

            Machine.RunEvent("Init");
            yield return(null);
        }
Exemplo n.º 3
0
        private IEnumerator TickLaunch()
        {
            Log.Info("TickLaunch");
            countdownStartTime = Planetarium.GetUniversalTime();
            paused             = false;
            holdPlayed         = false;
            int count = 10;

            if (ConfigInfo.Instance != null)
            {
                if (ConfigInfo.Instance.CurrentAudio != null)
                {
                    count = ConfigInfo.Instance.IsSoundEnabled && ConfigInfo.Instance.CurrentAudio.TimerSounds.Any() ? ConfigInfo.Instance.CurrentAudio.TimerSounds.Count - 1 : 15;
                }
            }


            for (var i = count; i >= 0; i--)
            {
                while (paused)
                {
                    yield return(new WaitForSeconds(1f));
                }
//                while (paused && (_audioSource == null || (_audioSource != null && !_audioSource.isPlaying)))
//                        yield return new WaitForSeconds(1f);
                _tick = i;
                var oneShotStartTime = Planetarium.GetUniversalTime();

                if (_audioSource != null && ConfigInfo.Instance != null && ConfigInfo.Instance.CurrentAudio != null)
                {
                    _audioSource.PlayOneShot(ConfigInfo.Instance.CurrentAudio.TimerSounds.FirstOrDefault(x => x.name.EndsWith($"/{i}")));
                }

                if (_stages != null && _stages.Count > i)
                {
                    _stages[i]();
                }
                var oneShotEndTime = Planetarium.GetUniversalTime();
                Log.Info("tick: " + _tick.ToString() + ",  starttime/endtime: " + oneShotStartTime.ToString("n4") + "/" + oneShotEndTime.ToString("n4"));
                var oneShotElapsedTime = oneShotEndTime - oneShotStartTime;
                if (oneShotElapsedTime < 1.0f && _tick > 0)
                {
                    yield return(new WaitForSeconds(1.0f - (float)oneShotElapsedTime));
                }
            }
            Log.Info("final _tic: " + _tick);
            GravityTurnAPI.Launch();
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 5
0
        private IEnumerator Abort()
        {
            TimeWarp.SetRate(0, false);
            var clip = ConfigInfo.Instance.CurrentAudio.Abort;

            if (GravityTurnAPI.GravityTurnActive)
            {
                GravityTurnAPI.Kill();
            }
            holdPlayed = true;
            if (clip != null)
            {
                _audioSource.PlayOneShot(clip);
                yield return(new WaitForSeconds(clip.length));
            }

            if (ConfigInfo.Instance.AbortExecuted)
            {
                BaseAction.FireAction(FlightGlobals.ActiveVessel.Parts, KSPActionGroup.Abort, KSPActionType.Activate);
            }

            Machine.RunEvent("Init");
        }
Exemplo n.º 6
0
        private void DrawSequenceWindow(int id)
        {
            GUILayout.BeginVertical();
            GUILayout.FlexibleSpace();

            ConfigInfo.Instance.EngineControl = GUILayout.Toggle(ConfigInfo.Instance.EngineControl, "Engine control", StyleFactory.ToggleStyle);

            if (GravityTurnAPI.VerifyGTVersion())
            {
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.Label("Use Gravity Turn", StyleFactory.LabelStyle);
                GUILayout.FlexibleSpace();
                ConfigInfo.Instance.useGravityTurn = GUILayout.Toggle(ConfigInfo.Instance.useGravityTurn, "");
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("Elapsed time", StyleFactory.LabelStyle);
            GUILayout.FlexibleSpace();
            GUILayout.Label("Stage number", StyleFactory.LabelStyle);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();



            for (int i = 0; i < 10; i++)
            {
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();


                GUILayout.Label($"{i + 1} second", StyleFactory.LabelStyle);
                GUILayout.FlexibleSpace();
                GUILayout.Label(ConfigInfo.Instance.Sequences[FlightGlobals.ActiveVessel.id][i] < 0 ? "none" : ConfigInfo.Instance.Sequences[FlightGlobals.ActiveVessel.id][i].ToString(), StyleFactory.LabelStyle, GUILayout.MinWidth(40));

                bool   flag  = _isEditorState && i != _stageIndex;
                string label = _isEditorState && i == _stageIndex ? "Done" : "Set";

                GUI.enabled = !flag;

                if (GUILayout.Button(label))
                {
                    _isEditorState = !_isEditorState;
                    _stageIndex    = i;
                }
                GUI.enabled = true;

                if (GUILayout.Button("Clear"))
                {
                    _isEditorState = false;
                    _stageIndex    = -1;
                    ConfigInfo.Instance.Sequences[FlightGlobals.ActiveVessel.id][i] = -1;
                }


                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button(new GUIContent(), StyleFactory.ButtonBackStyle))
            {
                Machine.RunEvent("Init");
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();

            GUI.DragWindow();
        }