public static bool AlertsReadoutUpdate(AlertsReadout __instance)
        {
            if (runonce && RimThreadedMod.Settings.showModConflictsAlert)
            {
                RimThreadedMod.getPotentialModConflicts_2(); //Not sure where to put this, making it run on the main menu without black screen will have been perfect.
                runonce = false;
            }
            if (Mathf.Max(Find.TickManager.TicksGame, Find.TutorialState.endTick) < 600)
            {
                return(false);
            }

            if (Find.Storyteller.def != null && Find.Storyteller.def.disableAlerts)
            {
                activeAlerts(__instance).Clear();
                return(false);
            }

            if (TickManager_Patch.curTimeSpeed(Find.TickManager) == TimeSpeed.Ultrafast && RimThreadedMod.Settings.disablesomealerts)
            {
                //this will disable alert checks on ultrafast speed for an added speed boost
                return(false);
            }

            curAlertIndex(__instance)++;
            if (curAlertIndex(__instance) >= 24)
            {
                curAlertIndex(__instance) = 0;
            }

            for (int i = curAlertIndex(__instance); i < AllAlerts(__instance).Count; i += 24)
            {
                //CheckAddOrRemoveAlert2(__instance, AllAlerts(__instance)[i]);
                actionCheckAddOrRemoveAlert(__instance, AllAlerts(__instance)[i], false);
            }

            if (Time.frameCount % 20 == 0)
            {
                List <Quest> questsListForReading = Find.QuestManager.QuestsListForReading;
                for (int j = 0; j < questsListForReading.Count; j++)
                {
                    List <QuestPart> partsListForReading = questsListForReading[j].PartsListForReading;
                    for (int k = 0; k < partsListForReading.Count; k++)
                    {
                        QuestPartActivable questPartActivable = partsListForReading[k] as QuestPartActivable;
                        if (questPartActivable == null)
                        {
                            continue;
                        }

                        Alert cachedAlert = questPartActivable.CachedAlert;
                        if (cachedAlert != null)
                        {
                            bool flag       = questsListForReading[j].State != QuestState.Ongoing || questPartActivable.State != QuestPartState.Enabled;
                            bool alertDirty = questPartActivable.AlertDirty;
                            //CheckAddOrRemoveAlert(__instance, cachedAlert, flag || alertDirty);
                            actionCheckAddOrRemoveAlert(__instance, cachedAlert, flag || alertDirty);
                            if (alertDirty)
                            {
                                questPartActivable.ClearCachedAlert();
                            }
                        }
                    }
                }
            }

            for (int num = activeAlerts(__instance).Count - 1; num >= 0; num--)
            {
                Alert alert = activeAlerts(__instance)[num];
                try
                {
                    activeAlerts(__instance)[num].AlertActiveUpdate();
                }
                catch (Exception ex)
                {
                    Log.ErrorOnce("Exception updating alert " + alert.ToString() + ": " + ex.ToString(), 743575);
                    activeAlerts(__instance).RemoveAt(num);
                }
            }

            if (mouseoverAlertIndex(__instance) >= 0 && mouseoverAlertIndex(__instance) < activeAlerts(__instance).Count)
            {
                IEnumerable <GlobalTargetInfo> allCulprits = activeAlerts(__instance)[mouseoverAlertIndex(__instance)].GetReport().AllCulprits;
                if (allCulprits != null)
                {
                    foreach (GlobalTargetInfo item in allCulprits)
                    {
                        TargetHighlighter.Highlight(item);
                    }
                }
            }

            mouseoverAlertIndex(__instance) = -1;
            return(false);
        }
Пример #2
0
        public static bool AlertsReadoutUpdate(AlertsReadout __instance)
        {
            if (!Analyzer.Settings.OverrideAlerts && !AnalyzerState.CurrentlyRunning)
            {
                return(true);
            }

            if (!Active)
            {
                return(true);
            }

            if (Mathf.Max(Find.TickManager.TicksGame, Find.TutorialState.endTick) < 600)
            {
                return(false);
            }
            if (Find.Storyteller.def.disableAlerts)
            {
                __instance.activeAlerts.Clear();
                return(false);
            }
            __instance.curAlertIndex++;
            if (__instance.curAlertIndex >= 24)
            {
                __instance.curAlertIndex = 0;
            }
            for (int i = __instance.curAlertIndex; i < __instance.AllAlerts.Count; i += 24)
            {
                __instance.CheckAddOrRemoveAlert(__instance.AllAlerts[i], false);
            }
            if (Time.frameCount % 20 == 0)
            {
                List <Quest> questsListForReading = Find.QuestManager.QuestsListForReading;
                for (int j = 0; j < questsListForReading.Count; j++)
                {
                    List <QuestPart> partsListForReading = questsListForReading[j].PartsListForReading;
                    for (int k = 0; k < partsListForReading.Count; k++)
                    {
                        QuestPartActivable questPartActivable = partsListForReading[k] as QuestPartActivable;
                        Alert cachedAlert = questPartActivable?.CachedAlert;
                        if (cachedAlert != null)
                        {
                            bool flag       = questsListForReading[j].State != QuestState.Ongoing || questPartActivable.State != QuestPartState.Enabled;
                            bool alertDirty = questPartActivable.AlertDirty;
                            __instance.CheckAddOrRemoveAlert(cachedAlert, flag || alertDirty);
                            if (alertDirty)
                            {
                                questPartActivable.ClearCachedAlert();
                            }
                        }
                    }
                }
            }

            for (int l = __instance.activeAlerts.Count - 1; l >= 0; l--)
            {
                Alert alert = __instance.activeAlerts[l];

                try
                {
                    var prof = Analyzer.Start(__instance.activeAlerts[l].GetHashCode().ToString(), () => __instance.activeAlerts[l] + " Update", __instance.activeAlerts[l].GetType());
                    __instance.activeAlerts[l].AlertActiveUpdate();
                    prof.Stop();
                }
                catch (Exception ex)
                {
                    Log.ErrorOnce($"Analyzer: Exception updating alert {alert.ToString()}, errored with the message {ex.ToString()}", 743575, false);
                    __instance.activeAlerts.RemoveAt(l);
                }
            }

            if (__instance.mouseoverAlertIndex >= 0 && __instance.mouseoverAlertIndex < __instance.activeAlerts.Count)
            {
                IEnumerable <GlobalTargetInfo> allCulprits = __instance.activeAlerts[__instance.mouseoverAlertIndex].GetReport().AllCulprits;
                if (allCulprits != null)
                {
                    foreach (GlobalTargetInfo target in allCulprits)
                    {
                        TargetHighlighter.Highlight(target, true, true, false);
                    }
                }
            }
            __instance.mouseoverAlertIndex = -1;

            return(false);
        }
Пример #3
0
        public static bool AlertsReadoutUpdate(AlertsReadout __instance)
        {
            if (Mathf.Max(Find.TickManager.TicksGame, Find.TutorialState.endTick) < 600)
            {
                return(false);
            }

            if (Find.Storyteller.def != null && Find.Storyteller.def.disableAlerts)
            {
                activeAlerts(__instance).Clear();
                return(false);
            }

            curAlertIndex(__instance)++;
            if (curAlertIndex(__instance) >= 24)
            {
                curAlertIndex(__instance) = 0;
            }

            for (int i = curAlertIndex(__instance); i < AllAlerts(__instance).Count; i += 24)
            {
                CheckAddOrRemoveAlert2(__instance, AllAlerts(__instance)[i]);
            }

            if (Time.frameCount % 20 == 0)
            {
                List <Quest> questsListForReading = Find.QuestManager.QuestsListForReading;
                for (int j = 0; j < questsListForReading.Count; j++)
                {
                    List <QuestPart> partsListForReading = questsListForReading[j].PartsListForReading;
                    for (int k = 0; k < partsListForReading.Count; k++)
                    {
                        QuestPartActivable questPartActivable = partsListForReading[k] as QuestPartActivable;
                        if (questPartActivable == null)
                        {
                            continue;
                        }

                        Alert cachedAlert = questPartActivable.CachedAlert;
                        if (cachedAlert != null)
                        {
                            bool flag       = questsListForReading[j].State != QuestState.Ongoing || questPartActivable.State != QuestPartState.Enabled;
                            bool alertDirty = questPartActivable.AlertDirty;
                            CheckAddOrRemoveAlert2(__instance, cachedAlert, flag || alertDirty);
                            if (alertDirty)
                            {
                                questPartActivable.ClearCachedAlert();
                            }
                        }
                    }
                }
            }

            for (int num = activeAlerts(__instance).Count - 1; num >= 0; num--)
            {
                Alert alert = activeAlerts(__instance)[num];
                try
                {
                    activeAlerts(__instance)[num].AlertActiveUpdate();
                }
                catch (Exception ex)
                {
                    Log.ErrorOnce("Exception updating alert " + alert.ToString() + ": " + ex.ToString(), 743575);
                    activeAlerts(__instance).RemoveAt(num);
                }
            }

            if (mouseoverAlertIndex(__instance) >= 0 && mouseoverAlertIndex(__instance) < activeAlerts(__instance).Count)
            {
                IEnumerable <GlobalTargetInfo> allCulprits = activeAlerts(__instance)[mouseoverAlertIndex(__instance)].GetReport().AllCulprits;
                if (allCulprits != null)
                {
                    foreach (GlobalTargetInfo item in allCulprits)
                    {
                        TargetHighlighter.Highlight(item);
                    }
                }
            }

            mouseoverAlertIndex(__instance) = -1;
            return(false);
        }