internal bool <> m__0(Region x) { FacilitiesUtility.visited.Add(x); List <Thing> list = x.ListerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial); for (int i = 0; i < list.Count; i++) { if (!FacilitiesUtility.processed.Contains(list[i])) { FacilitiesUtility.processed.Add(list[i]); CompFacility compFacility = list[i].TryGetComp <CompFacility>(); CompAffectedByFacilities compAffectedByFacilities = list[i].TryGetComp <CompAffectedByFacilities>(); if (compFacility != null) { compFacility.Notify_LOSBlockerSpawnedOrDespawned(); this.facilitiesProcessed++; } if (compAffectedByFacilities != null) { compAffectedByFacilities.Notify_LOSBlockerSpawnedOrDespawned(); this.affectedByFacilitiesProcessed++; } } } return(this.facilitiesProcessed >= this.facilitiesToProcess && this.affectedByFacilitiesProcessed >= this.affectedByFacilitiesToProcess); }
public static void NotifyFacilitiesAboutChangedLOSBlockers(List <Region> affectedRegions) { if (FacilitiesUtility.working) { Log.Warning("Tried to update facilities while already updating."); } else { FacilitiesUtility.working = true; try { FacilitiesUtility.visited.Clear(); for (int i = 0; i < affectedRegions.Count; i++) { if (!FacilitiesUtility.visited.Contains(affectedRegions[i])) { RegionTraverser.BreadthFirstTraverse(affectedRegions[i], (Region from, Region r) => !FacilitiesUtility.visited.Contains(r), delegate(Region x) { FacilitiesUtility.visited.Add(x); List <Thing> list = x.ListerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial); for (int j = 0; j < list.Count; j++) { CompFacility compFacility = list[j].TryGetComp <CompFacility>(); CompAffectedByFacilities compAffectedByFacilities = list[j].TryGetComp <CompAffectedByFacilities>(); if (compFacility != null) { compFacility.Notify_LOSBlockerSpawnedOrDespawned(); } if (compAffectedByFacilities != null) { compAffectedByFacilities.Notify_LOSBlockerSpawnedOrDespawned(); } } return(false); }, FacilitiesUtility.RegionsToSearch, RegionType.Set_Passable); } } } finally { FacilitiesUtility.working = false; FacilitiesUtility.visited.Clear(); } } }
public static void NotifyFacilitiesAboutChangedLOSBlockers(List <Region> affectedRegions) { if (affectedRegions.Any()) { if (working) { Log.Warning("Tried to update facilities while already updating."); } else { working = true; try { visited.Clear(); processed.Clear(); int facilitiesToProcess = affectedRegions[0].Map.listerThings.ThingsInGroup(ThingRequestGroup.Facility).Count; int affectedByFacilitiesToProcess = affectedRegions[0].Map.listerThings.ThingsInGroup(ThingRequestGroup.AffectedByFacilities).Count; int facilitiesProcessed = 0; int affectedByFacilitiesProcessed = 0; if (facilitiesToProcess > 0 && affectedByFacilitiesToProcess > 0) { for (int i = 0; i < affectedRegions.Count; i++) { if (!visited.Contains(affectedRegions[i])) { RegionTraverser.BreadthFirstTraverse(affectedRegions[i], (Region from, Region r) => !visited.Contains(r), delegate(Region x) { visited.Add(x); List <Thing> list = x.ListerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial); for (int j = 0; j < list.Count; j++) { if (!processed.Contains(list[j])) { processed.Add(list[j]); CompFacility compFacility = list[j].TryGetComp <CompFacility>(); CompAffectedByFacilities compAffectedByFacilities = list[j].TryGetComp <CompAffectedByFacilities>(); if (compFacility != null) { compFacility.Notify_LOSBlockerSpawnedOrDespawned(); facilitiesProcessed++; } if (compAffectedByFacilities != null) { compAffectedByFacilities.Notify_LOSBlockerSpawnedOrDespawned(); affectedByFacilitiesProcessed++; } } } return(facilitiesProcessed >= facilitiesToProcess && affectedByFacilitiesProcessed >= affectedByFacilitiesToProcess); }, RegionsToSearch); if (facilitiesProcessed >= facilitiesToProcess && affectedByFacilitiesProcessed >= affectedByFacilitiesToProcess) { break; } } } } } finally { working = false; visited.Clear(); processed.Clear(); } } } }