Exemple #1
0
        void activate_next_stage()
        {
            var next_stage = vessel.currentStage;

            while (next_stage >= 0 && stage_is_empty(next_stage))
            {
                next_stage--;
            }
            if (next_stage < 0)
            {
                return;
            }
//			Log(vessel.parts.Aggregate("\n", (s, p) => s+Utils.Format("{}: {}, stage {}\n", p.Title(), p.State, p.inverseStage)));//debug
//			LogF("current stage {}, next stage {}, next engines {}", vessel.currentStage, next_stage, Engines.NearestEnginedStage);//debug
            if (IsActiveVessel)
            {
                StageManager.ActivateStage(next_stage);
                vessel.ActionGroups.ToggleGroup(KSPActionGroup.Stage);
                if (ResourceDisplay.Instance != null)
                {
                    ResourceDisplay.Instance.isDirty = true;
                }
            }
            else
            {
                GameEvents.onStageActivate.Fire(next_stage);
                vessel.parts.ForEach(p => p.activate(next_stage, vessel));
                vessel.currentStage = next_stage;
                vessel.ActionGroups.ToggleGroup(KSPActionGroup.Stage);
            }
        }
Exemple #2
0
 override public void activateAction()
 {
     base.activateAction();
     if (nextStage)
     {
         StageManager.ActivateNextStage();
     }
     else if (stage < StageManager.StageCount)
     {
         StageManager.ActivateStage(stage);
     }
     this.endAction();
 }
        public void recursiveDecouple()
        {
            int minStage = StageManager.LastStage;

            for (int i = 0; i < part.vessel.parts.Count; i++)
            {
                Part child = part.vessel.parts[i];
                // TODO Sarbian : Cleanup - not sure if any mod still use those and they are not supported in other part of the code
                if (child.HasModule <ModuleEngines>())
                {
                    if (child.inverseStage < minStage)
                    {
                        minStage = child.inverseStage;
                    }
                }
            }
            List <Part> decouplers = new List <Part>();

            for (int i = 0; i < part.vessel.parts.Count; i++)
            {
                Part child = part.vessel.parts[i];
                if ((child.inverseStage > minStage) &&
                    (child.HasModule <ModuleDecouple>() || child.HasModule <ModuleAnchoredDecoupler>()))
                {
                    decouplers.Add(child);
                }
            }
            for (int i = 0; i < decouplers.Count; i++)
            {
                decouplers[i].force_activate();
            }
            if (part.vessel == FlightGlobals.ActiveVessel)
            {
                StageManager.ActivateStage(minStage);
            }
        }
Exemple #4
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.EngineControl)
            {
                FlightGlobals.ActiveVessel.OnFlyByWire = (FlightInputCallback)Delegate.Combine(FlightGlobals.ActiveVessel.OnFlyByWire, (FlightInputCallback)OnFlyByWire);
            }

            GameEvents.onVesselSituationChange.Add(SituationChanged);

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


            _dummy.StartCoroutine(this.TickLaunch());
        }