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 val = list[i] as T; if (val != null) { outThings.Add(val); } } } tmpMapChildHolders.Clear(); map.GetChildHolders(tmpMapChildHolders); for (int j = 0; j < tmpMapChildHolders.Count; j++) { tmpThings.Clear(); GetAllThingsRecursively(tmpMapChildHolders[j], tmpThings, allowUnreal, passCheck); for (int k = 0; k < tmpThings.Count; k++) { T val2 = tmpThings[k] as T; if (val2 != null && request.Accepts(val2)) { outThings.Add(val2); } } } tmpThings.Clear(); tmpMapChildHolders.Clear(); }
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(); }