Esempio n. 1
0
        public override void Tick(int currentTick)
        {
            base.Tick(currentTick);

            if (Current.ProgramState != ProgramState.Playing)
            {
                return;
            }

            // check every cfg delay
            //if (Prof.RestoreWhenHostileDetected
            //    && !HostileHandler.HostileDetected
            //    && Prof.CheckHostileDelay != 0
            //    && currentTick % (Prof.CheckHostileDelay * 2) == 0)
            //    HostileHandler.UpdateHostilesLong();

            // check every cfg delay or if was signal to force normal speed
            if (Prof.CheckHostileDelay != 0 && (currentTick % Prof.CheckHostileDelay) != 0 && !TimeSlower_Handler_Patch.SignalForceNormal)
            {
                return;
            }

            TimeSlower_Handler_Patch.SignalForceNormal = false;

            // if option off reset to config
            if (!Prof.RestoreWhenHostileDetected)
            {
                if (!SettingsApplied)
                {
                    ApplySettings();
                }
                return;
            }

            HostileHandler.UpdateHostiles();
            if (!SettingsApplied && !HostileHandler.HostileDetected) // detected hostiles rip
            {
                ApplySettings();
                if (DebugLog)
                {
                    Log.Message($"[WorkRebalancer] Apply configured settings");
                }
            }
            else if (SettingsApplied && HostileHandler.HostileDetected) // detected new hostiles
            {
                ApplySettingsDefaults();
                Pawn_PathFollower_Patch.InstantMoving = false;
                if (DebugLog)
                {
                    Log.Message($"[WorkRebalancer] Apply default 100% settings");
                }
            }
        }
Esempio n. 2
0
        public static Pawn AnyHostileActive()
        {
            var maps = Find.Maps;

            if (maps != null)
            {
                foreach (var map in maps)
                {
                    if (HostileHandler.AnyHostileActiveThreatTo(map, Faction.OfPlayer, out var threat, false))
                    {
                        if (threat.Thing is Pawn p)
                        {
                            return(p);
                        }
                    }
                }
            }

            return(null);
        }
Esempio n. 3
0
        public static void UpdateHostilesLong()
        {
            var maps = Find.Maps;

            if (maps == null)
            {
                return;
            }

            foreach (var map in maps)
            {
                if (HostileHandler.AnyHostileActiveThreatTo(map, Faction.OfPlayer, out var threat))
                {
                    if (threat.Thing is Pawn p)
                    {
                        _hostilePawnsCached.Add(p);
                    }
                }
            }
        }