Example #1
0
        private void EVEOnFrame(object sender, EventArgs e)
        {
            if (!OnframeProcessEveryPulse())
            {
                return;
            }
            if (Settings.Instance.DebugOnframe)
            {
                Logging.Log("Questor", "OnFrame: this is Questor.cs [" + DateTime.UtcNow + "] by default the next pulse will be in [" + Time.Instance.QuestorPulse_milliseconds + "]milliseconds", Logging.Teal);
            }

            RunOnceAfterStartup();
            RunOnceInStationAfterStartup();

            if (!Cache.Instance.Paused)
            {
                if (DateTime.UtcNow.Subtract(Cache.Instance.LastWalletCheck).TotalMinutes > Time.Instance.WalletCheck_minutes && !Settings.Instance.DefaultSettingsLoaded)
                {
                    WalletCheck();
                }
            }

            // We always check our defense state if we're in space, regardless of questor state
            // We also always check panic
            if ((Cache.Instance.LastInSpace.AddSeconds(2) > DateTime.UtcNow) && Cache.Instance.InSpace)
            {
                DebugPerformanceClearandStartTimer();
                if (!Cache.Instance.DoNotBreakInvul)
                {
                    _defense.ProcessState();
                }
                DebugPerformanceStopandDisplayTimer("Defense.ProcessState");
            }

            if (Cache.Instance.Paused || DateTime.UtcNow < _nextQuestorAction)
            {
                Cache.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow;
                Cache.Instance.MyWalletBalance            = Cache.Instance.DirectEve.Me.Wealth;
                Cache.Instance.GotoBaseNow  = false;
                Cache.Instance.SessionState = string.Empty;
                return;
            }

            if (Cache.Instance.SessionState == "Quitting")
            {
                if (_States.CurrentQuestorState != QuestorState.CloseQuestor)
                {
                    Cleanup.BeginClosingQuestor();
                }
            }

            // When in warp there's nothing we can do, so ignore everything
            if (Cache.Instance.InSpace && Cache.Instance.InWarp)
            {
                return;
            }

            switch (_States.CurrentQuestorState)
            {
            case QuestorState.Idle:
                if (TimeCheck())
                {
                    return;                  //Should we close questor due to stoptime or runtime?
                }
                if (!SkillQueueCheck())
                {
                    return;                         //if we need to train skills we return here, on the next pass we will be _States.CurrentQuestorState = QuestorSate.SkillTrainer
                }
                if (Cache.Instance.StopBot)
                {
                    if (Settings.Instance.DebugIdle)
                    {
                        Logging.Log("Questor", "Cache.Instance.StopBot = true - this is set by the LocalWatch code so that we stay in station when local is unsafe", Logging.Orange);
                    }
                    return;
                }

                if (_States.CurrentQuestorState == QuestorState.Idle && Settings.Instance.CharacterMode != "none" && Settings.Instance.CharacterName != null)
                {
                    _States.CurrentQuestorState = QuestorState.Start;
                    return;
                }

                Logging.Log("Questor", "Settings.Instance.CharacterMode = [" + Settings.Instance.CharacterMode + "]", Logging.Orange);
                _States.CurrentQuestorState = QuestorState.Error;
                break;

            case QuestorState.CombatMissionsBehavior:

                //
                // QuestorState will stay here until changed externally by the behavior we just kicked into starting
                //
                _combatMissionsBehavior.ProcessState();
                break;

            case QuestorState.SkillTrainer:

                //
                // QuestorState will stay here until changed externally by the behavior we just kicked into starting
                //
                SkillTrainerClass.ProcessState();
                break;

            case QuestorState.CombatHelperBehavior:

                //
                // QuestorState will stay here until changed externally by the behavior we just kicked into starting
                //
                _combatHelperBehavior.ProcessState();
                break;

            case QuestorState.DedicatedBookmarkSalvagerBehavior:

                //
                // QuestorState will stay here until changed externally by the behavior we just kicked into starting
                //
                _dedicatedBookmarkSalvagerBehavior.ProcessState();
                break;

            case QuestorState.DirectionalScannerBehavior:

                //
                // QuestorState will stay here until changed externally by the behavior we just kicked into starting
                //
                _directionalScannerBehavior.ProcessState();
                break;

            case QuestorState.DebugHangarsBehavior:

                //
                // QuestorState will stay here until changed externally by the behavior we just kicked into starting
                //
                _debugHangarsBehavior.ProcessState();
                break;

            case QuestorState.DebugReloadAll:
                if (!Combat.ReloadAll(Cache.Instance.EntitiesNotSelf.OrderBy(t => t.Distance).FirstOrDefault(t => t.Distance < (double)Distances.OnGridWithMe)))
                {
                    return;
                }
                _States.CurrentQuestorState = QuestorState.Start;
                break;

            case QuestorState.Mining:
                _miningBehavior.ProcessState();
                break;

            case QuestorState.Start:
                switch (Settings.Instance.CharacterMode.ToLower())
                {
                case "combat missions":
                case "combat_missions":
                case "dps":
                    Logging.Log("Questor", "Start Mission Behavior", Logging.White);
                    _States.CurrentQuestorState = QuestorState.CombatMissionsBehavior;
                    break;

                case "salvage":
                    Logging.Log("Questor", "Start Salvaging Behavior", Logging.White);
                    _States.CurrentQuestorState = QuestorState.DedicatedBookmarkSalvagerBehavior;
                    break;

                case "mining":
                    Logging.Log("Questor", "Start Mining Behavior", Logging.White);
                    _States.CurrentQuestorState = QuestorState.Mining;
                    _States.CurrentMiningState  = MiningState.Start;
                    break;

                case "combat helper":
                case "combat_helper":
                case "combathelper":
                    Logging.Log("Questor", "Start CombatHelper Behavior", Logging.White);
                    _States.CurrentQuestorState = QuestorState.CombatHelperBehavior;
                    break;

                case "custom":
                    Logging.Log("Questor", "Start Custom Behavior", Logging.White);
                    //_States.CurrentQuestorState = QuestorState.BackgroundBehavior;
                    break;

                case "directionalscanner":
                    Logging.Log("Questor", "Start DirectionalScanner Behavior", Logging.White);
                    _States.CurrentQuestorState = QuestorState.DirectionalScannerBehavior;
                    break;
                }
                break;

            case QuestorState.CloseQuestor:
                if (Cache.Instance.ReasonToStopQuestor == string.Empty)
                {
                    Cache.Instance.ReasonToStopQuestor = "case QuestorState.CloseQuestor:";
                }

                Cleanup.CloseQuestor(Cache.Instance.ReasonToStopQuestor);
                return;

            case QuestorState.DebugCloseQuestor:

                //Logging.Log("ISBoxerCharacterSet: " + Settings.Instance.Lavish_ISBoxerCharacterSet);
                //Logging.Log("Profile: " + Settings.Instance.Lavish_InnerspaceProfile);
                //Logging.Log("Game: " + Settings.Instance.Lavish_Game);
                Logging.Log("Questor", "CloseQuestorCMDUplinkInnerspaceProfile: " + Settings.Instance.CloseQuestorCMDUplinkInnerspaceProfile, Logging.White);
                Logging.Log("Questor", "CloseQuestorCMDUplinkISboxerCharacterSet: " + Settings.Instance.CloseQuestorCMDUplinkIsboxerCharacterSet, Logging.White);
                Logging.Log("Questor", "CloseQuestorArbitraryOSCmd" + Settings.Instance.CloseQuestorArbitraryOSCmd, Logging.White);
                Logging.Log("Questor", "CloseQuestorOSCmdContents" + Settings.Instance.CloseQuestorOSCmdContents, Logging.White);
                Logging.Log("Questor", "WalletBalanceChangeLogOffDelay: " + Settings.Instance.WalletBalanceChangeLogOffDelay, Logging.White);
                Logging.Log("Questor", "WalletBalanceChangeLogOffDelayLogoffOrExit: " + Settings.Instance.WalletBalanceChangeLogOffDelayLogoffOrExit, Logging.White);
                Logging.Log("Questor", "EVEProcessMemoryCeiling: " + Settings.Instance.EVEProcessMemoryCeiling, Logging.White);
                Logging.Log("Questor", "EVEProcessMemoryCeilingLogofforExit: " + Settings.Instance.EVEProcessMemoryCeilingLogofforExit, Logging.White);
                Logging.Log("Questor", "Cache.Instance.CloseQuestorCMDExitGame: " + Cache.Instance.CloseQuestorCMDExitGame, Logging.White);
                Logging.Log("Questor", "Cache.Instance.CloseQuestorCMDLogoff: " + Cache.Instance.CloseQuestorCMDLogoff, Logging.White);
                Logging.Log("Questor", "Cache.Instance.CloseQuestorEndProcess: " + Cache.Instance.CloseQuestorEndProcess, Logging.White);
                Logging.Log("Questor", "Cache.Instance.EnteredCloseQuestor_DateTime: " + Cache.Instance.EnteredCloseQuestor_DateTime.ToShortTimeString(), Logging.White);
                _States.CurrentQuestorState = QuestorState.Error;
                return;

            case QuestorState.DebugWindows:
                List <DirectWindow> windows = Cache.Instance.Windows;

                if (windows != null && windows.Any())
                {
                    foreach (DirectWindow window in windows)
                    {
                        Logging.Log("Questor", "--------------------------------------------------", Logging.Orange);
                        Logging.Log("Questor", "Debug_Window.Name: [" + window.Name + "]", Logging.White);
                        Logging.Log("Questor", "Debug_Window.Caption: [" + window.Caption + "]", Logging.White);
                        Logging.Log("Questor", "Debug_Window.Type: [" + window.Type + "]", Logging.White);
                        Logging.Log("Questor", "Debug_Window.IsModal: [" + window.IsModal + "]", Logging.White);
                        Logging.Log("Questor", "Debug_Window.IsDialog: [" + window.IsDialog + "]", Logging.White);
                        Logging.Log("Questor", "Debug_Window.Id: [" + window.Id + "]", Logging.White);
                        Logging.Log("Questor", "Debug_Window.IsKillable: [" + window.IsKillable + "]", Logging.White);
                        Logging.Log("Questor", "Debug_Window.Html: [" + window.Html + "]", Logging.White);
                    }

                    //Logging.Log("Questor", "Debug_InventoryWindows", Logging.White);
                    //foreach (DirectWindow window in windows)
                    //{
                    //    if (window.Type.Contains("inventory"))
                    //    {
                    //        Logging.Log("Questor", "Debug_Window.Name: [" + window.Name + "]", Logging.White);
                    //        Logging.Log("Questor", "Debug_Window.Type: [" + window.Type + "]", Logging.White);
                    //        Logging.Log("Questor", "Debug_Window.Caption: [" + window.Caption + "]", Logging.White);
                    //        //Logging.Log("Questor", "Debug_Window.Type: [" + window. + "]", Logging.White);
                    //    }
                    //}
                }
                else
                {
                    Logging.Log("Questor", "DebugWindows: No Windows Found", Logging.White);
                }
                _States.CurrentQuestorState = QuestorState.Error;
                return;

            case QuestorState.DebugInventoryTree:

                if (Cache.Instance.PrimaryInventoryWindow.ExpandCorpHangarView())
                {
                    Logging.Log("DebugInventoryTree", "ExpandCorpHangar executed", Logging.Teal);
                }
                Logging.Log("DebugInventoryTree", "--------------------------------------------------", Logging.Orange);
                Logging.Log("DebugInventoryTree", "InventoryWindow.Name: [" + Cache.Instance.PrimaryInventoryWindow.Name + "]", Logging.White);
                Logging.Log("DebugInventoryTree", "InventoryWindow.Caption: [" + Cache.Instance.PrimaryInventoryWindow.Caption + "]", Logging.White);
                Logging.Log("DebugInventoryTree", "InventoryWindow.Type: [" + Cache.Instance.PrimaryInventoryWindow.Type + "]", Logging.White);
                Logging.Log("DebugInventoryTree", "InventoryWindow.IsModal: [" + Cache.Instance.PrimaryInventoryWindow.IsModal + "]", Logging.White);
                Logging.Log("DebugInventoryTree", "InventoryWindow.IsDialog: [" + Cache.Instance.PrimaryInventoryWindow.IsDialog + "]", Logging.White);
                Logging.Log("DebugInventoryTree", "InventoryWindow.Id: [" + Cache.Instance.PrimaryInventoryWindow.Id + "]", Logging.White);
                Logging.Log("DebugInventoryTree", "InventoryWindow.IsKillable: [" + Cache.Instance.PrimaryInventoryWindow.IsKillable + "]", Logging.White);
                Logging.Log("DebugInventoryTree", "InventoryWindow.IsReady: [" + Cache.Instance.PrimaryInventoryWindow.IsReady + "]", Logging.White);
                Logging.Log("DebugInventoryTree", "InventoryWindow.LocationFlag: [" + Cache.Instance.PrimaryInventoryWindow.LocationFlag + "]", Logging.White);
                Logging.Log("DebugInventoryTree", "InventoryWindow.currInvIdName: " + Cache.Instance.PrimaryInventoryWindow.currInvIdName, Logging.Red);
                Logging.Log("DebugInventoryTree", "InventoryWindow.currInvIdName: " + Cache.Instance.PrimaryInventoryWindow.currInvIdItem, Logging.Red);

                foreach (Int64 itemInTree in Cache.Instance.IDsinInventoryTree)
                {
                    if (Cache.Instance.PrimaryInventoryWindow.GetIdsFromTree(false).Contains(itemInTree))
                    {
                        Cache.Instance.PrimaryInventoryWindow.SelectTreeEntryByID(itemInTree);
                        Cache.Instance.IDsinInventoryTree.Remove(itemInTree);
                        break;
                    }
                }
                break;

                //case QuestorState.BackgroundBehavior:

                //
                // QuestorState will stay here until changed externally by the behavior we just kicked into starting
                //
                //_backgroundbehavior.ProcessState();
                //break;
            }
        }