private static void CalculateExpectedListers(Map map) { Autotests_RegionListers.expectedListers.Clear(); List <Thing> allThings = map.listerThings.AllThings; for (int i = 0; i < allThings.Count; i++) { Thing thing = allThings[i]; if (ListerThings.EverListable(thing.def, ListerThingsUse.Region)) { RegionListersUpdater.GetTouchableRegions(thing, map, Autotests_RegionListers.tmpTouchableRegions, false); for (int j = 0; j < Autotests_RegionListers.tmpTouchableRegions.Count; j++) { Region key = Autotests_RegionListers.tmpTouchableRegions[j]; List <Thing> list = default(List <Thing>); if (!Autotests_RegionListers.expectedListers.TryGetValue(key, out list)) { list = new List <Thing>(); Autotests_RegionListers.expectedListers.Add(key, list); } list.Add(allThings[i]); } } } }
private static void CalculateExpectedListers(Map map) { expectedListers.Clear(); List <Thing> allThings = map.listerThings.AllThings; for (int i = 0; i < allThings.Count; i++) { Thing thing = allThings[i]; if (!ListerThings.EverListable(thing.def, ListerThingsUse.Region)) { continue; } RegionListersUpdater.GetTouchableRegions(thing, map, tmpTouchableRegions); for (int j = 0; j < tmpTouchableRegions.Count; j++) { Region key = tmpTouchableRegions[j]; if (!expectedListers.TryGetValue(key, out var value)) { value = new List <Thing>(); expectedListers.Add(key, value); } value.Add(allThings[i]); } } }
public void Add(Thing t) { if (ListerThings.EverListable(t.def, this.use)) { List <Thing> list = default(List <Thing>); if (!this.listsByDef.TryGetValue(t.def, out list)) { list = new List <Thing>(); this.listsByDef.Add(t.def, list); } list.Add(t); ThingRequestGroup[] allGroups = ThingListGroupHelper.AllGroups; foreach (ThingRequestGroup thingRequestGroup in allGroups) { if ((this.use != ListerThingsUse.Region || thingRequestGroup.StoreInRegion()) && thingRequestGroup.Includes(t.def)) { List <Thing> list2 = this.listsByGroup[(uint)thingRequestGroup]; if (list2 == null) { list2 = new List <Thing>(); this.listsByGroup[(uint)thingRequestGroup] = list2; } list2.Add(t); } } } }
public void Add(Thing t) { if (!ListerThings.EverListable(t.def, this.use)) { return; } List <Thing> list; if (!this.listsByDef.TryGetValue(t.def, out list)) { list = new List <Thing>(); this.listsByDef.Add(t.def, list); } list.Add(t); ThingRequestGroup[] allGroups = ThingListGroupHelper.AllGroups; for (int i = 0; i < allGroups.Length; i++) { ThingRequestGroup thingRequestGroup = allGroups[i]; if (this.use != ListerThingsUse.Region || thingRequestGroup.StoreInRegion()) { if (thingRequestGroup.Includes(t.def)) { List <Thing> list2 = this.listsByGroup[(int)thingRequestGroup]; if (list2 == null) { list2 = new List <Thing>(); this.listsByGroup[(int)thingRequestGroup] = list2; } list2.Add(t); } } } }
public static void BestThingRequestGroup() { DebugTables.MakeTablesDialog(from x in DefDatabase <ThingDef> .AllDefs where ListerThings.EverListable(x, ListerThingsUse.Global) || ListerThings.EverListable(x, ListerThingsUse.Region) orderby x.label select x, new TableDataGetter <ThingDef>("defName", (ThingDef d) => d.defName), new TableDataGetter <ThingDef>("best local", delegate(ThingDef d) { IEnumerable <ThingRequestGroup> source2 = ListerThings.EverListable(d, ListerThingsUse.Region) ? ((ThingRequestGroup[])Enum.GetValues(typeof(ThingRequestGroup))).Where((ThingRequestGroup x) => x.StoreInRegion() && x.Includes(d)) : Enumerable.Empty <ThingRequestGroup>(); if (!source2.Any()) { return("-"); } ThingRequestGroup best2 = source2.MinBy((ThingRequestGroup x) => DefDatabase <ThingDef> .AllDefs.Count((ThingDef y) => ListerThings.EverListable(y, ListerThingsUse.Region) && x.Includes(y))); return(best2 + " (defs: " + DefDatabase <ThingDef> .AllDefs.Count((ThingDef x) => ListerThings.EverListable(x, ListerThingsUse.Region) && best2.Includes(x)) + ")"); }), new TableDataGetter <ThingDef>("best global", delegate(ThingDef d) { IEnumerable <ThingRequestGroup> source = ListerThings.EverListable(d, ListerThingsUse.Global) ? ((ThingRequestGroup[])Enum.GetValues(typeof(ThingRequestGroup))).Where((ThingRequestGroup x) => x.Includes(d)) : Enumerable.Empty <ThingRequestGroup>(); if (!source.Any()) { return("-"); } ThingRequestGroup best = source.MinBy((ThingRequestGroup x) => DefDatabase <ThingDef> .AllDefs.Count((ThingDef y) => ListerThings.EverListable(y, ListerThingsUse.Global) && x.Includes(y))); return(best + " (defs: " + DefDatabase <ThingDef> .AllDefs.Count((ThingDef x) => ListerThings.EverListable(x, ListerThingsUse.Global) && best.Includes(x)) + ")"); })); }
public void Remove(Thing t) { if (ListerThings.EverListable(t.def, this.use)) { this.listsByDef[t.def].Remove(t); ThingRequestGroup[] allGroups = ThingListGroupHelper.AllGroups; for (int i = 0; i < allGroups.Length; i++) { ThingRequestGroup group = allGroups[i]; if ((this.use != ListerThingsUse.Region || group.StoreInRegion()) && group.Includes(t.def)) { this.listsByGroup[i].Remove(t); } } } }
public static void DeregisterInRegions(Thing thing, Map map) { if (!ListerThings.EverListable(thing.def, ListerThingsUse.Region)) { return; } GetTouchableRegions(thing, map, tmpRegions, allowAdjacentEvenIfCantTouch: true); for (int i = 0; i < tmpRegions.Count; i++) { ListerThings listerThings = tmpRegions[i].ListerThings; if (listerThings.Contains(thing)) { listerThings.Remove(thing); } } tmpRegions.Clear(); }
public static void RegisterInRegions(Thing thing, Map map) { if (!ListerThings.EverListable(thing.def, ListerThingsUse.Region)) { return; } GetTouchableRegions(thing, map, tmpRegions); for (int i = 0; i < tmpRegions.Count; i++) { ListerThings listerThings = tmpRegions[i].ListerThings; if (!listerThings.Contains(thing)) { listerThings.Add(thing); } } tmpRegions.Clear(); }
public static void RegisterInRegions(Thing thing, Map map) { ThingDef def = thing.def; if (ListerThings.EverListable(def, ListerThingsUse.Region)) { RegionListersUpdater.GetTouchableRegions(thing, map, RegionListersUpdater.tmpRegions, false); for (int i = 0; i < RegionListersUpdater.tmpRegions.Count; i++) { ListerThings listerThings = RegionListersUpdater.tmpRegions[i].ListerThings; if (!listerThings.Contains(thing)) { listerThings.Add(thing); } } } }
public static void DeregisterInRegions(Thing thing, Map map) { ThingDef def = thing.def; if (!ListerThings.EverListable(def, ListerThingsUse.Region)) { return; } RegionListersUpdater.GetTouchableRegions(thing, map, RegionListersUpdater.tmpRegions, true); for (int i = 0; i < RegionListersUpdater.tmpRegions.Count; i++) { ListerThings listerThings = RegionListersUpdater.tmpRegions[i].ListerThings; if (listerThings.Contains(thing)) { listerThings.Remove(thing); } } RegionListersUpdater.tmpRegions.Clear(); }
public void ConstructComponents() { this.spawnedThings = new ThingOwner <Thing>(this); this.cellIndices = new CellIndices(this); this.listerThings = new ListerThings(ListerThingsUse.Global); this.listerBuildings = new ListerBuildings(); this.mapPawns = new MapPawns(this); this.dynamicDrawManager = new DynamicDrawManager(this); this.mapDrawer = new MapDrawer(this); this.tooltipGiverList = new TooltipGiverList(); this.pawnDestinationReservationManager = new PawnDestinationReservationManager(); this.reservationManager = new ReservationManager(this); this.physicalInteractionReservationManager = new PhysicalInteractionReservationManager(); this.designationManager = new DesignationManager(this); this.lordManager = new LordManager(this); this.debugDrawer = new DebugCellDrawer(); this.passingShipManager = new PassingShipManager(this); this.haulDestinationManager = new HaulDestinationManager(this); this.gameConditionManager = new GameConditionManager(this); this.weatherManager = new WeatherManager(this); this.zoneManager = new ZoneManager(this); this.resourceCounter = new ResourceCounter(this); this.mapTemperature = new MapTemperature(this); this.temperatureCache = new TemperatureCache(this); this.areaManager = new AreaManager(this); this.attackTargetsCache = new AttackTargetsCache(this); this.attackTargetReservationManager = new AttackTargetReservationManager(this); this.lordsStarter = new VoluntarilyJoinableLordsStarter(this); this.thingGrid = new ThingGrid(this); this.coverGrid = new CoverGrid(this); this.edificeGrid = new EdificeGrid(this); this.blueprintGrid = new BlueprintGrid(this); this.fogGrid = new FogGrid(this); this.glowGrid = new GlowGrid(this); this.regionGrid = new RegionGrid(this); this.terrainGrid = new TerrainGrid(this); this.pathGrid = new PathGrid(this); this.roofGrid = new RoofGrid(this); this.fertilityGrid = new FertilityGrid(this); this.snowGrid = new SnowGrid(this); this.deepResourceGrid = new DeepResourceGrid(this); this.exitMapGrid = new ExitMapGrid(this); this.linkGrid = new LinkGrid(this); this.glowFlooder = new GlowFlooder(this); this.powerNetManager = new PowerNetManager(this); this.powerNetGrid = new PowerNetGrid(this); this.regionMaker = new RegionMaker(this); this.pathFinder = new PathFinder(this); this.pawnPathPool = new PawnPathPool(this); this.regionAndRoomUpdater = new RegionAndRoomUpdater(this); this.regionLinkDatabase = new RegionLinkDatabase(); this.moteCounter = new MoteCounter(); this.gatherSpotLister = new GatherSpotLister(); this.windManager = new WindManager(this); this.listerBuildingsRepairable = new ListerBuildingsRepairable(); this.listerHaulables = new ListerHaulables(this); this.listerMergeables = new ListerMergeables(this); this.listerFilthInHomeArea = new ListerFilthInHomeArea(this); this.reachability = new Reachability(this); this.itemAvailability = new ItemAvailability(this); this.autoBuildRoofAreaSetter = new AutoBuildRoofAreaSetter(this); this.roofCollapseBufferResolver = new RoofCollapseBufferResolver(this); this.roofCollapseBuffer = new RoofCollapseBuffer(); this.wildAnimalSpawner = new WildAnimalSpawner(this); this.wildPlantSpawner = new WildPlantSpawner(this); this.steadyEnvironmentEffects = new SteadyEnvironmentEffects(this); this.skyManager = new SkyManager(this); this.overlayDrawer = new OverlayDrawer(); this.floodFiller = new FloodFiller(this); this.weatherDecider = new WeatherDecider(this); this.fireWatcher = new FireWatcher(this); this.dangerWatcher = new DangerWatcher(this); this.damageWatcher = new DamageWatcher(); this.strengthWatcher = new StrengthWatcher(this); this.wealthWatcher = new WealthWatcher(this); this.regionDirtyer = new RegionDirtyer(this); this.cellsInRandomOrder = new MapCellsInRandomOrder(this); this.rememberedCameraPos = new RememberedCameraPos(this); this.mineStrikeManager = new MineStrikeManager(); this.storyState = new StoryState(this); this.retainedCaravanData = new RetainedCaravanData(this); this.components.Clear(); this.FillComponents(); }