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 override void FinalizeInit() { base.FinalizeInit(); var grid = map.GetGrid(); grid.IterateCellsQuick(cell => cell.zombieCount = 0); var destinations = Traverse.Create(map.pawnDestinationManager).Field("reservedDestinations").GetValue <Dictionary <Faction, Dictionary <Pawn, IntVec3> > >(); var zombieFaction = Find.FactionManager.FirstFactionOfDef(ZombieDefOf.Zombies); if (!destinations.ContainsKey(zombieFaction)) { map.pawnDestinationManager.RegisterFaction(zombieFaction); } if (ZombieSettings.Values.betterZombieAvoidance) { var specs = AllZombies().Select(zombie => new ZombieCostSpecs() { position = zombie.Position, radius = ZombieAvoidRadius(zombie), maxCosts = ZombieMaxCosts(zombie) }).ToList(); avoidGrid = Tools.avoider.UpdateZombiePositionsImmediately(map, specs); } else { avoidGrid = new AvoidGrid(map); } }
AvoidGrid GetAvoidGrid(Map map) { if (grids.TryGetValue(map, out var result) == false) { result = new AvoidGrid(map); grids[map] = result; } return(result); }
void FetchAvoidGrid() { if (ZombieSettings.Values.betterZombieAvoidance == false) { if (emptyAvoidGrid == null) { emptyAvoidGrid = new AvoidGrid(map); } avoidGrid = emptyAvoidGrid; return; } if (avoidGridCounter-- < 0) { avoidGridCounter = Constants.TICKMANAGER_AVOIDGRID_DELAY.SecondsToTicks(); var result = Tools.avoider.GetCostsGrid(map); if (result != null) { avoidGrid = result; } } }