예제 #1
0
        public void Update()
        {
            //a hack to detect when the user hides the GUI
            if (renderingManager == null)
            {
                renderingManager = (RenderingManager)GameObject.FindObjectOfType(typeof(RenderingManager));
            }
            if (HighLogic.LoadedSceneIsFlight && renderingManager != null)
            {
                if (renderingManager.uiElementsToDisable.Length >= 1)
                {
                    showGui = renderingManager.uiElementsToDisable[0].activeSelf;
                }
            }

            if (this != vessel.GetMasterMechJeb())
            {
                return;
            }

            if (modulesUpdated)
            {
                computerModules.Sort();
                modulesUpdated = false;
            }

            if (Input.GetKeyDown(KeyCode.V) && (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)))
            {
                MechJebModuleCustomWindowEditor windowEditor = GetComputerModule <MechJebModuleCustomWindowEditor>();
                if (windowEditor != null)
                {
                    windowEditor.CreateWindowFromSharingString(MuUtils.SystemClipboard);
                }
            }

            //periodically save settings in case we quit unexpectedly
            if (HighLogic.LoadedSceneIsEditor || vessel.isActiveVessel)
            {
                if (Time.time > lastSettingsSaveTime + 5)
                {
                    //Debug.Log("MechJeb doing periodic settings save");
                    OnSave(null);
                    lastSettingsSaveTime = Time.time;
                }
            }

            if (vessel == null)
            {
                return;                 //don't run ComputerModules' OnUpdate in editor
            }
            foreach (ComputerModule module in computerModules)
            {
                if (module.enabled)
                {
                    module.OnUpdate();
                }
            }
        }
예제 #2
0
        public void Update()
        {
            if (this != vessel.GetMasterMechJeb())
            {
                return;
            }

            if (Input.GetKeyDown(KeyCode.V) && (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)))
            {
                MechJebModuleCustomWindowEditor windowEditor = GetComputerModule <MechJebModuleCustomWindowEditor>();
                if (windowEditor != null)
                {
                    windowEditor.CreateWindowFromSharingString(MuUtils.SystemClipboard);
                }
            }

            //periodically save settings in case we quit unexpectedly
            if (HighLogic.LoadedSceneIsEditor || vessel.isActiveVessel)
            {
                if (Time.time > lastSettingsSaveTime + 5)
                {
                    //Debug.Log("MechJeb doing periodic settings save");
                    OnSave(null);
                    lastSettingsSaveTime = Time.time;
                }
            }

            if (ResearchAndDevelopment.Instance != null && unorderedComputerModules.Any(a => !a.unlockChecked))
            {
                foreach (ComputerModule module in GetComputerModules <ComputerModule>())
                {
                    try
                    {
                        module.UnlockCheck();
                    }
                    catch (Exception e)
                    {
                        Debug.LogError("MechJeb module " + module.GetType().Name + " threw an exception in UnlockCheck: " + e);
                    }
                }
            }

            GetComputerModule <MechJebModuleMenu>().OnMenuUpdate(); // Allow the menu movement, even while in Editor

            if (vessel == null)
            {
                return;                 //don't run ComputerModules' OnUpdate in editor
            }
            foreach (ComputerModule module in GetComputerModules <ComputerModule>())
            {
                try
                {
                    if (module.enabled)
                    {
                        module.OnUpdate();
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("MechJeb module " + module.GetType().Name + " threw an exception in OnUpdate: " + e);
                }
            }
        }
예제 #3
0
        public void Update()
        {
            if (this != vessel.GetMasterMechJeb() || (!FlightGlobals.ready && HighLogic.LoadedSceneIsFlight) || !ready)
            {
                return;
            }
            Profiler.BeginSample("MechJebCore.Update");

            if (Input.GetKeyDown(KeyCode.V) && (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)))
            {
                MechJebModuleCustomWindowEditor windowEditor = GetComputerModule <MechJebModuleCustomWindowEditor>();
                if (windowEditor != null)
                {
                    windowEditor.CreateWindowFromSharingString(MuUtils.SystemClipboard);
                }
            }

            //periodically save settings in case we quit unexpectedly
            Profiler.BeginSample("MechJebCore.Update.OnSave");
            if (HighLogic.LoadedSceneIsEditor || (vessel != null && vessel.isActiveVessel))
            {
                if (Time.time > lastSettingsSaveTime + 5)
                {
                    if (NeedToSave())
                    {
                        Log.dbg("Periodic settings save");
                        OnSave(null);
                    }
                    lastSettingsSaveTime = Time.time;
                }
            }
            Profiler.EndSample();

            if (ResearchAndDevelopment.Instance != null && unorderedComputerModules.Any(a => !a.unlockChecked))
            {
                foreach (ComputerModule module in GetComputerModules <ComputerModule>())
                {
                    try
                    {
                        module.UnlockCheck();
                    }
                    catch (Exception e)
                    {
                        Log.err(e, "module {0} threw an exception in UnlockCheck: {1}", module.GetType().Name, e);
                    }
                }
            }

            Profiler.BeginSample("OnMenuUpdate");
            GetComputerModule <MechJebModuleMenu>().OnMenuUpdate(); // Allow the menu movement, even while in Editor
            Profiler.EndSample();

            if (vessel == null)
            {
                Profiler.EndSample();
                return; //don't run ComputerModules' OnUpdate in editor
            }

            foreach (ComputerModule module in GetComputerModules <ComputerModule>())
            {
                Profiler.BeginSample(module.profilerName);
                try
                {
                    if (module.enabled)
                    {
                        module.OnUpdate();
                    }
                }
                catch (Exception e)
                {
                    Log.err(e, "module {0} threw an exception in OnUpdate: {1}", module.GetType().Name, e);
                }
                Profiler.EndSample();
            }
            Profiler.EndSample();
        }
예제 #4
0
        public void Update()
        {
            if (renderingManager == null)
            {
                renderingManager = (RenderingManager)GameObject.FindObjectOfType(typeof(RenderingManager));
            }
            if (HighLogic.LoadedSceneIsFlight && renderingManager != null)
            {
                if (renderingManager.uiElementsToDisable.Length >= 1)
                {
                    showGui = renderingManager.uiElementsToDisable[0].activeSelf;
                }
            }

            if (this != vessel.GetMasterMechJeb())
            {
                return;
            }

            if (modulesUpdated)
            {
                computerModules.Sort();
                modulesUpdated = false;
            }

            if (Input.GetKeyDown(KeyCode.V) && (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)))
            {
                MechJebModuleCustomWindowEditor windowEditor = GetComputerModule <MechJebModuleCustomWindowEditor>();
                if (windowEditor != null)
                {
                    windowEditor.CreateWindowFromSharingString(MuUtils.SystemClipboard);
                }
            }

            //periodically save settings in case we quit unexpectedly
            if (HighLogic.LoadedSceneIsEditor || vessel.isActiveVessel)
            {
                if (Time.time > lastSettingsSaveTime + 5)
                {
                    //Debug.Log("MechJeb doing periodic settings save");
                    OnSave(null);
                    lastSettingsSaveTime = Time.time;
                }
            }

            if (ResearchAndDevelopment.Instance != null && computerModules.Any(a => !a.unlockChecked))
            {
                foreach (ComputerModule module in computerModules)
                {
                    try
                    {
                        module.UnlockCheck();
                    }
                    catch (Exception e)
                    {
                        Debug.LogError("MechJeb module " + module.GetType().Name + " threw an exception in UnlockCheck: " + e);
                    }
                }
            }

            if (vessel == null)
            {
                return;                 //don't run ComputerModules' OnUpdate in editor
            }
            foreach (ComputerModule module in computerModules)
            {
                try
                {
                    if (module.enabled)
                    {
                        module.OnUpdate();
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("MechJeb module " + module.GetType().Name + " threw an exception in OnUpdate: " + e);
                }
            }
        }