コード例 #1
0
 public void UnregisterGUI(EngineThrustControllerGUI gui)
 {
     EngineThrustControllerGUI.GetInstance().UnregisterGUIItem(this);
 }
コード例 #2
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);
        }