public static List <Thing> GetAllThingsRecursively(IThingHolder holder, bool allowUnreal = true) { List <Thing> list = new List <Thing>(); ThingOwnerUtility.GetAllThingsRecursively(holder, list, allowUnreal); return(list); }
private static void NotifyEverythingWhichUsesMapReference(Map map) { List <Map> maps = Find.Maps; int num = maps.IndexOf(map); ThingOwnerUtility.GetAllThingsRecursively(map, MapDeiniter.tmpThings, true, null); for (int i = 0; i < MapDeiniter.tmpThings.Count; i++) { MapDeiniter.tmpThings[i].Notify_MyMapRemoved(); } MapDeiniter.tmpThings.Clear(); for (int j = num; j < maps.Count; j++) { ThingOwner spawnedThings = maps[j].spawnedThings; for (int k = 0; k < spawnedThings.Count; k++) { if (j != num) { spawnedThings[k].DecrementMapIndex(); } } List <Room> allRooms = maps[j].regionGrid.allRooms; for (int l = 0; l < allRooms.Count; l++) { if (j == num) { allRooms[l].Notify_MyMapRemoved(); } else { allRooms[l].DecrementMapIndex(); } } foreach (Region current in maps[j].regionGrid.AllRegions_NoRebuild_InvalidAllowed) { if (j == num) { current.Notify_MyMapRemoved(); } else { current.DecrementMapIndex(); } } } }
public static void GetAllThingsRecursively <T>(Map map, ThingRequest request, List <T> outThings, bool allowUnreal = true, Predicate <IThingHolder> passCheck = null, bool alsoGetSpawnedThings = true) where T : Thing { outThings.Clear(); if (alsoGetSpawnedThings) { List <Thing> list = map.listerThings.ThingsMatching(request); for (int i = 0; i < list.Count; i++) { T t = list[i] as T; if (t != null) { outThings.Add(t); } } } ThingOwnerUtility.tmpMapChildHolders.Clear(); map.GetChildHolders(ThingOwnerUtility.tmpMapChildHolders); for (int j = 0; j < ThingOwnerUtility.tmpMapChildHolders.Count; j++) { ThingOwnerUtility.tmpThings.Clear(); ThingOwnerUtility.GetAllThingsRecursively(ThingOwnerUtility.tmpMapChildHolders[j], ThingOwnerUtility.tmpThings, allowUnreal, passCheck); for (int k = 0; k < ThingOwnerUtility.tmpThings.Count; k++) { if (request.Accepts(ThingOwnerUtility.tmpThings[k])) { T t2 = ThingOwnerUtility.tmpThings[k] as T; if (t2 != null) { outThings.Add(t2); } } } } ThingOwnerUtility.tmpThings.Clear(); ThingOwnerUtility.tmpMapChildHolders.Clear(); }