private static ThingsTracker GetCachedTracker(Map map, bool fallbackMode = false) { int index = map.Index; if (index >= 0 && index < comps.Length) { ThingsTracker tracker = comps[index]; if (maps[index] != map) { maps[index] = map; comps[index] = tracker = map.GetComponent <ThingsTracker>(); } return(tracker); } else if (fallbackMode) { throw new Exception($"GetTracker has failed twice for index {index}"); } Map[] tempMaps = new Map[Math.Max(maps.Length * 2, index + 1)]; ThingsTracker[] tempComps = new ThingsTracker[Math.Max(comps.Length * 2, index + 1)]; Array.Copy(maps, 0, tempMaps, 0, maps.Length); maps = tempMaps; Array.Copy(comps, 0, tempComps, 0, comps.Length); comps = tempComps; return(GetCachedTracker(map, fallbackMode: true)); }
public static IEnumerable <Pawn> PawnsInRange(this IntVec3 cell, Map map, float range, PathEndMode pathEndMode = PathEndMode.None, TraverseMode traverseMode = TraverseMode.ByPawn, Danger danger = Danger.Unspecified) { ThingsTracker tracker = map.GetThingTracker(); return(ThingsReachableFrom(map, tracker.ThingsInRangeOf(TrackedThingsRequestCategory.Pawns, cell, range), cell, pathEndMode, traverseMode, danger).Select(t => t as Pawn)); }
public static IEnumerable <Thing> ThingsByDefInRange(this IntVec3 cell, Map map, ThingDef thingDef, float range, PathEndMode pathEndMode = PathEndMode.None, TraverseMode traverseMode = TraverseMode.ByPawn, Danger danger = Danger.Unspecified) { ThingsTracker tracker = map.GetThingTracker(); return(ThingsReachableFrom(map, tracker.ThingsInRangeOf(thingDef, cell, range), cell, pathEndMode, traverseMode, danger)); }
public static IEnumerable <Thing> SimilarInRange(this Thing thing, float range, PathEndMode pathEndMode = PathEndMode.None, TraverseMode traverseMode = TraverseMode.ByPawn, Danger danger = Danger.Unspecified) { ThingsTracker tracker = thing.Map.GetThingTracker(); return(ThingsReachableFrom(thing.Map, tracker.SimilarInRangeOf(thing, range), thing, pathEndMode, traverseMode, danger)); }
public static IEnumerable <Apparel> ApparelInRange(this IntVec3 cell, Map map, float range) { ThingsTracker tracker = map.GetThingTracker(); return(tracker.ThingsInRangeOf(TrackedThingsRequestCategory.Apparel, cell, range).Select(t => t as Apparel)); }
public static IEnumerable <ThingWithComps> MedicineInRange(this IntVec3 cell, Map map, float range) { ThingsTracker tracker = map.GetThingTracker(); return(tracker.ThingsInRangeOf(TrackedThingsRequestCategory.Medicine, cell, range).Select(t => t as ThingWithComps)); }
public static IEnumerable <Pawn> HostilesInRange(this IntVec3 cell, Map map, Faction faction, float range) { ThingsTracker tracker = map.GetThingTracker(); return(tracker.ThingsInRangeOf(TrackedThingsRequestCategory.Pawns, cell, range).Where(t => t.Faction?.HostileTo(faction) ?? false).Select(t => t as Pawn)); }
public static IEnumerable <Pawn> PawnsInRange(this IntVec3 cell, Map map, float range) { ThingsTracker tracker = map.GetThingTracker(); return(tracker.ThingsInRangeOf(TrackedThingsRequestCategory.Pawns, cell, range).Select(t => t as Pawn)); }
public static IEnumerable <Thing> ThingsByDefInRange(this IntVec3 cell, Map map, ThingDef thingDef, float range) { ThingsTracker tracker = map.GetThingTracker(); return(tracker.ThingsInRangeOf(thingDef, cell, range)); }
public static IEnumerable <Thing> SimilarInRange(this Thing thing, float range) { ThingsTracker tracker = thing.Map.GetThingTracker(); return(tracker.SimilarInRangeOf(thing, range)); }
public static ThingsTracker GetThingTracker(this Map map) { return(ThingsTracker.GetTracker(map)); }