public override void FinalizeInit() { base.FinalizeInit(); Tools.UpdateStoryTellerDifficulty(); var grid = map.GetGrid(); grid.IterateCellsQuick(cell => cell.zombieCount = 0); RecalculateVisibleMap(); var destinations = GetterSetters.reservedDestinationsByRef(map.pawnDestinationReservationManager); var zombieFaction = Find.FactionManager.FirstFactionOfDef(ZombieDefOf.Zombies); if (!destinations.ContainsKey(zombieFaction)) { map.pawnDestinationReservationManager.RegisterFaction(zombieFaction); } if (ZombieSettings.Values.betterZombieAvoidance) { var specs = AllZombies().Select(zombie => new ZombieCostSpecs() { position = zombie.Position, radius = Tools.ZombieAvoidRadius(zombie), maxCosts = ZombieMaxCosts(zombie) }).ToList(); avoidGrid = Tools.avoider.UpdateZombiePositionsImmediately(map, specs); } else { avoidGrid = new AvoidGrid(map); } }
public void RecalculateVisibleMap() { Tools.UpdateStoryTellerDifficulty(); if (visibleGridUpdateCounter-- < 0) { visibleGridUpdateCounter = Constants.TICKMANAGER_RECALCULATE_DELAY.SecondsToTicks(); currentColonyPoints = Tools.ColonyPoints(); allZombiesCached = AllZombies().ToList(); var home = map.areaManager.Home; if (home.TrueCount > 0) { var cells = home.ActiveCells.ToArray(); var cellCount = cells.Length; allZombiesCached.Do(zombie => zombie.wanderDestination = cells[Constants.random.Next() % cellCount]); centerOfInterest = new IntVec3( (int)Math.Round(cells.Average(c => c.x)), 0, (int)Math.Round(cells.Average(c => c.z)) ); } else { centerOfInterest = Tools.CenterOfInterest(map); allZombiesCached.Do(zombie => zombie.wanderDestination = centerOfInterest); } } }