private static void CalculateLocationCandidates(Map map, ThingDef thingDef) { InfestationLikeCellFinder.locationCandidates.Clear(); InfestationLikeCellFinder.CalculateTraversalDistancesToUnroofed(map); InfestationLikeCellFinder.CalculateClosedAreaSizeGrid(map); InfestationLikeCellFinder.CalculateDistanceToColonyBuildingGrid(map); for (int i = 0; i < map.Size.z; i++) { for (int j = 0; j < map.Size.x; j++) { IntVec3 cell = new IntVec3(j, 0, i); float scoreAt = InfestationLikeCellFinder.GetScoreAt(cell, map, thingDef); if (scoreAt > 0f) { InfestationLikeCellFinder.locationCandidates.Add(new InfestationLikeCellFinder.LocationCandidate(cell, scoreAt)); } } } }
// Token: 0x0600368B RID: 13963 RVA: 0x001A0E1C File Offset: 0x0019F21C public static bool TryFindCell(out IntVec3 cell, Map map, ThingDef thingDef, FactionDef factionDef = null) { //Log.Message(string.Format("Tick: 1")); InfestationLikeCellFinder.CalculateLocationCandidates(map, thingDef); InfestationLikeCellFinder.LocationCandidate locationCandidate; if (!InfestationLikeCellFinder.locationCandidates.TryRandomElementByWeight((InfestationLikeCellFinder.LocationCandidate x) => x.score, out locationCandidate)) { cell = IntVec3.Invalid; //Log.Message(string.Format("TryFindCell: {0} From !InfestationLikeCellFinder.TryFindCell(out loc, map)", cell)); return(false); } cell = CellFinder.FindNoWipeSpawnLocNear(locationCandidate.cell, map, thingDef, Rot4.North, 2, (IntVec3 x) => InfestationLikeCellFinder.GetScoreAt(x, map, thingDef) > 0f && x.GetFirstThing(map, thingDef) == null && x.GetFirstThing(map, ((ThingDef_HiveLike)thingDef).TunnelDef) == null); return(true); }