public EngineThrustControllerGUIItem(EngineThrustControllerGUI gui, ModuleEngineThrustController controller)
        {
            m_gui        = gui;
            m_controller = controller;

            RegisterGUI(gui);
        }
 private static EngineThrustControllerGUI CreateInstance()
 {
     if (s_singleton == null)
     {
         s_singleton = new EngineThrustControllerGUI();
     }
     return(s_singleton);
 }
 public void UnregisterGUI(EngineThrustControllerGUI gui)
 {
     EngineThrustControllerGUI.GetInstance().UnregisterGUIItem(this);
 }
 public void UnregisterGUI(EngineThrustControllerGUI gui)
 {
     EngineThrustControllerGUI.GetInstance().UnregisterGUIItem(this);
 }
        public EngineThrustControllerGUIItem(EngineThrustControllerGUI gui, ModuleEngineThrustController controller)
        {
            m_gui = gui;
            m_controller = controller;

            RegisterGUI(gui);
        }
 private static EngineThrustControllerGUI CreateInstance()
 {
     if (s_singleton == null) s_singleton = new EngineThrustControllerGUI(); return s_singleton;
 }
Ejemplo n.º 7
0
        public override void OnStart(StartState state)
        {
            Debug.Log("ModuleEngineThrustController OnStart(" + state.ToString() + ")");
            m_state = state;

            if (state == StartState.None)
            {
                return;
            }

            BindEngine();

            if (minimumThrustPercent < 0.0f)
            {
                minimumThrustPercent = 0.0f;
            }
            if (minimumThrustPercent > 1.0f)
            {
                minimumThrustPercent = 1.0f;
            }

            if (maximumThrustPercent < 0.0f)
            {
                maximumThrustPercent = 0.0f;
            }
            if (maximumThrustPercent > 1.0f)
            {
                maximumThrustPercent = 1.0f;
            }

            if (minimumThrustPercent > maximumThrustPercent)
            {
                minimumThrustPercent = maximumThrustPercent;
            }

            if (initialThrust < minimumThrustPercent)
            {
                initialThrust = minimumThrustPercent;
            }
            if (initialThrust > maximumThrustPercent)
            {
                initialThrust = maximumThrustPercent;
            }

            // Save original engine data.
            if (engine != null)
            {
                originalMaxThrust      = engine.maxThrust;
                originalHeatProduction = engine.heatProduction;
                if (((int)state & (int)StartState.PreLaunch) > 0)
                {
                    thrustPercent = initialThrust;
                }
                else if (state == StartState.Editor)
                {
                    thrustPercent = initialThrust;
                }

                engine.maxThrust      = originalMaxThrust * thrustPercent;
                engine.heatProduction = originalHeatProduction * thrustPercent;
            }
            else if (engineFX != null)
            {
                originalMaxThrust      = engineFX.maxThrust;
                originalHeatProduction = engineFX.heatProduction;
                if (((int)state & (int)StartState.PreLaunch) > 0)
                {
                    thrustPercent = initialThrust;
                }
                else if (state == StartState.Editor)
                {
                    thrustPercent = initialThrust;
                }

                engineFX.maxThrust      = originalMaxThrust * thrustPercent;
                engineFX.heatProduction = originalHeatProduction * thrustPercent;
            }
            Debug.Log("Data saved:" + originalMaxThrust.ToString() + " " + thrustPercent.ToString("0%"));

            if (state == StartState.Editor)
            {
                EngineThrustControllerGUI.GetInstance().CheckClear();
                if (showItemInList == true)
                {
                    EngineThrustControllerGUIItem item = new EngineThrustControllerGUIItem(EngineThrustControllerGUI.GetInstance(), this);
                }
                return;
            }
            else
            {
                EngineThrustControllerGUI.GetInstance().ClearGUIItem();
            }

            if (canAdjustAtAnytime == true)
            {
                Events["ContextMenuIncreaseThrust"].guiName = "Increase Thrust by " + percentAdjustmentStep.ToString("0%");
                Events["ContextMenuDecreaseThrust"].guiName = "Decrease Thrust by " + percentAdjustmentStep.ToString("0%");
            }
            else
            {
                Events["ContextMenuIncreaseThrust"].guiActive = false;
                Events["ContextMenuIncreaseThrust"].active    = false;
                Events["ContextMenuDecreaseThrust"].guiActive = false;
                Events["ContextMenuDecreaseThrust"].active    = false;
            }
            Events["Group1"].guiName   = "Set Group 1";
            Events["Group2"].guiName   = "Set Group 2";
            Events["Group1"].guiActive = false;
            Events["Group2"].guiActive = false;
            base.OnStart(state);
        }