KLF.KLFManager.updateStep C# (CSharp) Method

updateStep() public method

public updateStep ( ) : void
return void
        public void updateStep()
        {
            if (HighLogic.LoadedScene == GameScenes.LOADING)
                return; //Don't do anything while the game is loading

            if (planetariumCam != null && planetariumCam.gameObject.GetComponent<KLFCameraScript>() == null)
            {
                Debug.Log("Added KLF Camera Script");
                KLFCameraScript script = planetariumCam.gameObject.AddComponent<KLFCameraScript>();
                script.manager = this;
            }

            //Handle all queued vessel updates
            while (vesselUpdateQueue.Count > 0)
            {
                handleVesselUpdate(vesselUpdateQueue.Dequeue());
            }

            readClientInterop();

            if ((UnityEngine.Time.realtimeSinceStartup - lastPluginUpdateWriteTime) > updateInterval
                && (Time.realtimeSinceStartup - lastInteropWriteTime) < INTEROP_WRITE_TIMEOUT)
            {
                writePluginUpdate();
                lastPluginUpdateWriteTime = UnityEngine.Time.realtimeSinceStartup;
            }

            if ((UnityEngine.Time.realtimeSinceStartup - lastPluginDataWriteTime) > PLUGIN_DATA_WRITE_INTERVAL)
            {
                writePluginData();
                writeScreenshotWatchUpdate();
                lastPluginDataWriteTime = UnityEngine.Time.realtimeSinceStartup;
            }

            //Write interop
            if ((UnityEngine.Time.realtimeSinceStartup - lastInteropWriteTime) > INTEROP_WRITE_INTERVAL)
            {
                if (writePluginInterop())
                    lastInteropWriteTime = UnityEngine.Time.realtimeSinceStartup;
            }

            //Save global settings periodically

            if ((UnityEngine.Time.realtimeSinceStartup - lastGlobalSettingSaveTime) > GLOBAL_SETTINGS_SAVE_INTERVAL)
            {
                saveGlobalSettings();

                //Keep track of when the name was last read so we don't read it every time
                lastGlobalSettingSaveTime = UnityEngine.Time.realtimeSinceStartup;
            }

            //Update the positions of all the vessels
            List<String> delete_list = new List<String>();

            foreach (KeyValuePair<String, VesselEntry> pair in vessels) {

                VesselEntry entry = pair.Value;

                if ((UnityEngine.Time.realtimeSinceStartup-entry.lastUpdateTime) <= VESSEL_TIMEOUT_DELAY
                    && entry.vessel != null && entry.vessel.gameObj != null)
                {
                    entry.vessel.updateRenderProperties(
                        !KLFGlobalSettings.instance.showOtherShips ||
                        (!KLFGlobalSettings.instance.showInactiveShips && entry.vessel.info.state != State.ACTIVE)
                        );
                    entry.vessel.updatePosition();
                }
                else
                {
                    delete_list.Add(pair.Key); //Mark the vessel for deletion

                    if (entry.vessel != null && entry.vessel.gameObj != null)
                        GameObject.Destroy(entry.vessel.gameObj);
                }
            }

            //Delete what needs deletin'
            foreach (String key in delete_list)
                vessels.Remove(key);

            delete_list.Clear();

            //Delete outdated player status entries
            foreach (KeyValuePair<String, VesselStatusInfo> pair in playerStatus)
            {
                if ((UnityEngine.Time.realtimeSinceStartup - pair.Value.lastUpdateTime) > VESSEL_TIMEOUT_DELAY)
                    delete_list.Add(pair.Key);
            }

            foreach (String key in delete_list)
                playerStatus.Remove(key);
        }