Ejemplo n.º 1
0
        public bool OnframeProcessEveryPulse()
        {
            if (Cache.Instance.DirectEve.Login.AtLogin)
            {
                return(false);
            }

            // New frame, invalidate old cache
            Cache.Instance.InvalidateCache();

            //if (Cache.Instance.EntitiesthatHaveExploded.Any())
            //{
            //    if (Settings.Instance.DebugKillTargets && Cache.Instance.EntitiesthatHaveExploded.Count() > 5) Logging.Log("Questor", "EntitiesthatHaveExploded Count is currently [" + Cache.Instance.EntitiesthatHaveExploded.Count() + "]", Logging.Debug);
            //}

            Cache.Instance.LastFrame = DateTime.UtcNow;

            // Only pulse state changes every 1.5s
            if (DateTime.UtcNow.Subtract(_lastQuestorPulse).TotalMilliseconds < Time.Instance.QuestorPulse_milliseconds) //default: 1000ms
            {
                return(false);
            }

            _lastQuestorPulse = DateTime.UtcNow;

            if (Cache.Instance.SessionState != "Quitting")
            {
                // Update settings (settings only load if character name changed)
                if (!Settings.Instance.DefaultSettingsLoaded)
                {
                    Settings.Instance.LoadSettings();
                }
            }

            if (DateTime.UtcNow < Cache.Instance.QuestorStarted_DateTime.AddSeconds(30))
            {
                Cache.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow;
            }

            // Start _cleanup.ProcessState
            // Description: Closes Windows, and eventually other things considered 'cleanup' useful to more than just Questor(Missions) but also Anomalies, Mining, etc
            //
            DebugPerformanceClearandStartTimer();
            _cleanup.ProcessState();
            DebugPerformanceStopandDisplayTimer("Cleanup.ProcessState");

            _statistics.ProcessState();
            _innerspaceCommands.ProcessState();

            if (Settings.Instance.DebugStates)
            {
                Logging.Log("Cleanup.State is", _States.CurrentCleanupState.ToString(), Logging.White);
            }

            // Done
            // Cleanup State: ProcessState

            // Session is not ready yet, do not continue
            if (!Cache.Instance.DirectEve.Session.IsReady)
            {
                Cache.Instance.ClearPerPocketCache();
                return(false);
            }

            if (Cache.Instance.DirectEve.Session.IsReady)
            {
                Cache.Instance.LastSessionIsReady = DateTime.UtcNow;
            }

            // We are not in space or station, don't do shit yet!
            if (!Cache.Instance.InSpace && !Cache.Instance.InStation)
            {
                Cache.Instance.ClearPerPocketCache();
                Cache.Instance.NextInSpaceorInStation = DateTime.UtcNow.AddSeconds(12);
                Cache.Instance.LastSessionChange      = DateTime.UtcNow;
                return(false);
            }

            if (DateTime.UtcNow < Cache.Instance.NextInSpaceorInStation)
            {
                if (Cache.Instance.ActiveShip.GroupId == (int)Group.Capsule)
                {
                    Logging.Log("Panic", "We are in a pod. Don't wait for the session wait timer to expire!", Logging.Red);
                    Cache.Instance.NextInSpaceorInStation = DateTime.UtcNow;
                    return(true);
                }
                return(false);
            }

            // Check 3D rendering
            if (Cache.Instance.DirectEve.Session.IsInSpace && Cache.Instance.DirectEve.Rendering3D != !Settings.Instance.Disable3D)
            {
                Cache.Instance.DirectEve.Rendering3D = !Settings.Instance.Disable3D;
            }

            if (DateTime.UtcNow.Subtract(Cache.Instance.LastUpdateOfSessionRunningTime).TotalSeconds < Time.Instance.SessionRunningTimeUpdate_seconds)
            {
                Cache.Instance.SessionRunningTime             = (int)DateTime.UtcNow.Subtract(Cache.Instance.QuestorStarted_DateTime).TotalMinutes;
                Cache.Instance.LastUpdateOfSessionRunningTime = DateTime.UtcNow;
            }
            return(true);
        }