Exemplo n.º 1
0
        public void OnUpdateFixed()
        {
            //The logic below doesn't apply unless we're flying
            if (!HighLogic.LoadedSceneIsFlight)
            {
                return;
            }

            if (reactorState == EReactorStates.None || reactorState == EReactorStates.Off)
            {
                return;
            }

            //If we are charging up, request electric charge and then exit.
            if (ReactorNeedsCharge())
            {
                return;
            }

            //Set status
            if (primaryEngine.currentThrottle > 0f || secondaryEngine.currentThrottle > 0f)
            {
                reactorState = EReactorStates.Running;
            }
            else
            {
                reactorState = EReactorStates.Idling;
            }
            reactorStatus = reactorState.ToString();

            //Consume a small amount of fusion pellets to represent the fusion reactor's operation in NTR mode.
            ConsumeFuel();
        }
Exemplo n.º 2
0
        public void SetEngineStateOnStart()
        {
            if (reactorIsOn)
            {
                reactorState  = EReactorStates.Idling;
                reactorStatus = reactorState.ToString();
                Events["ToggleReactor"].guiName = kShutdownEngine;

                //Start your engine
                StartEngine();
            }

            else if (reactorState == EReactorStates.None)
            {
                currentElectricCharge = 0f;
                reactorState          = EReactorStates.Off;
                reactorStatus         = EReactorStates.Off + string.Format(" Needs {0:F2} EC", ecNeededToStart);
            }
        }
Exemplo n.º 3
0
        protected void setupEngines()
        {
            //See if we have multiple engines that we need to support
            engineSwitcher = this.part.FindModuleImplementing <MultiModeEngine>();
            List <ModuleEngines> engines      = this.part.FindModulesImplementing <ModuleEngines>();
            ModuleEngines        moduleEngine = null;

            //Hide GUI on the switcher
            engineSwitcher.autoSwitch = false;
            engineSwitcher.Events["DisableAutoSwitch"].guiActive       = false;
            engineSwitcher.Events["DisableAutoSwitch"].guiActiveEditor = false;
            engineSwitcher.Events["EnableAutoSwitch"].guiActive        = false;
            engineSwitcher.Events["EnableAutoSwitch"].guiActiveEditor  = false;

            //Find all the engines in the part and record their properties.
            for (int index = 0; index < engines.Count; index++)
            {
                moduleEngine = engines[index];
                multiModeEngines.Add(moduleEngine.engineID, moduleEngine);

                //Hide the GUI
                moduleEngine.Events["Activate"].guiActive       = false;
                moduleEngine.Events["Shutdown"].guiActive       = false;
                moduleEngine.Events["Activate"].guiActiveEditor = false;
                moduleEngine.Events["Shutdown"].guiActiveEditor = false;
            }

            //Get whichever multimode engine is the active one.
            if (engineSwitcher != null)
            {
                if (engineSwitcher.runningPrimary)
                {
                    engine = multiModeEngines[engineSwitcher.primaryEngineID];
                }
                else
                {
                    engine = multiModeEngines[engineSwitcher.secondaryEngineID];
                }
            }

            //Just get the first engine in the list.
            else if (engines.Count > 0)
            {
                engine = multiModeEngines.Values.ToArray()[0];
            }

            //Setup engine state
            if (reactorState == EReactorStates.Charged)
            {
                capacitorStatus = reactorState.ToString();
                Events["ChargeCapacitor"].guiName = kShutdownEngine;

                //Start your engine
                StartEngine();
            }

            else if (reactorState == EReactorStates.None)
            {
                currentElectricCharge = 0f;
                reactorState          = EReactorStates.Off;
                capacitorStatus       = EReactorStates.Off + string.Format(" Needs {0:F2} EC", ecNeededToStart);
            }
        }