public void MapMeshDrawerUpdate_First() { CellRect visibleSections = this.VisibleSections; bool flag = false; CellRect.CellRectIterator iterator = visibleSections.GetIterator(); while (!iterator.Done()) { IntVec3 intVec = iterator.Current; Section sect = this.sections[intVec.x, intVec.z]; if (this.TryUpdateSection(sect)) { flag = true; } iterator.MoveNext(); } if (!flag) { for (int i = 0; i < this.SectionCount.x; i++) { for (int j = 0; j < this.SectionCount.z; j++) { if (this.TryUpdateSection(this.sections[i, j])) { return; } } } } }
public static void GetTouchableRegions(Thing thing, Map map, List <Region> outRegions, bool allowAdjacentEvenIfCantTouch = false) { outRegions.Clear(); CellRect cellRect = thing.OccupiedRect(); CellRect cellRect2 = cellRect; if (RegionListersUpdater.CanRegisterInAdjacentRegions(thing)) { cellRect2 = cellRect2.ExpandedBy(1); } CellRect.CellRectIterator iterator = cellRect2.GetIterator(); while (!iterator.Done()) { IntVec3 current = iterator.Current; if (current.InBounds(map)) { Region validRegionAt_NoRebuild = map.regionGrid.GetValidRegionAt_NoRebuild(current); if (validRegionAt_NoRebuild != null && validRegionAt_NoRebuild.type.Passable() && !outRegions.Contains(validRegionAt_NoRebuild)) { if (cellRect.Contains(current)) { outRegions.Add(validRegionAt_NoRebuild); } else if (allowAdjacentEvenIfCantTouch || ReachabilityImmediate.CanReachImmediate(current, thing, map, PathEndMode.Touch, null)) { outRegions.Add(validRegionAt_NoRebuild); } } } iterator.MoveNext(); } }
public static bool TryFindRandomCellInsideWith(CellRect cellRect, Predicate <IntVec3> predicate, out IntVec3 result) { int area = cellRect.Area; int num = Mathf.Max(Mathf.RoundToInt(Mathf.Sqrt((float)area)), 5); for (int i = 0; i < num; i++) { IntVec3 randomCell = cellRect.RandomCell; if (predicate(randomCell)) { result = randomCell; return(true); } } tmpCells.Clear(); CellRect.CellRectIterator iterator = cellRect.GetIterator(); while (!iterator.Done()) { tmpCells.Add(iterator.Current); iterator.MoveNext(); } tmpCells.Shuffle(); int j = 0; for (int count = tmpCells.Count; j < count; j++) { if (predicate(tmpCells[j])) { result = tmpCells[j]; return(true); } } result = IntVec3.Invalid; return(false); }
public static void CalcShootableCellsOf(List <IntVec3> outCells, Thing t) { outCells.Clear(); if (t is Pawn) { outCells.Add(t.Position); for (int i = 0; i < 4; i++) { IntVec3 intVec = t.Position + GenAdj.CardinalDirections[i]; if (intVec.CanBeSeenOver(t.Map)) { outCells.Add(intVec); } } } else { outCells.Add(t.Position); if (t.def.size.x != 1 || t.def.size.z != 1) { CellRect.CellRectIterator iterator = t.OccupiedRect().GetIterator(); while (!iterator.Done()) { if (iterator.Current != t.Position) { outCells.Add(iterator.Current); } iterator.MoveNext(); } } } }
private void RegisterThingsInRegionListers() { CellRect cellRect = this.newReg.extentsClose; cellRect = cellRect.ExpandedBy(1); cellRect.ClipInsideMap(this.map); RegionMaker.tmpProcessedThings.Clear(); CellRect.CellRectIterator iterator = cellRect.GetIterator(); while (!iterator.Done()) { IntVec3 current = iterator.Current; bool flag = false; for (int i = 0; i < 9; i++) { IntVec3 c = current + GenAdj.AdjacentCellsAndInside[i]; if (c.InBounds(this.map) && this.regionGrid.GetValidRegionAt(c) == this.newReg) { flag = true; break; } } if (flag) { RegionListersUpdater.RegisterAllAt(current, this.map, RegionMaker.tmpProcessedThings); } iterator.MoveNext(); } RegionMaker.tmpProcessedThings.Clear(); }
private static bool CanGoDirectlyToNextCell(Pawn pawn) { IntVec3 nextCell = pawn.pather.nextCell; CellRect.CellRectIterator iterator = CellRect.FromLimits(nextCell, pawn.Position).ExpandedBy(1).GetIterator(); while (!iterator.Done()) { IntVec3 current = iterator.Current; if (current.InBounds(pawn.Map)) { List <Thing> thingList = current.GetThingList(pawn.Map); for (int i = 0; i < thingList.Count; i++) { Pawn pawn2 = thingList[i] as Pawn; if (pawn2 != null && pawn2 != pawn && pawn2.GetPosture() == PawnPosture.Standing) { if (pawn2.pather.MovingNow) { if (((pawn2.Position == nextCell && WillBeFasterOnNextCell(pawn, pawn2)) || pawn2.pather.nextCell == nextCell || pawn2.Position == pawn.Position || (pawn2.pather.nextCell == pawn.Position && WillBeFasterOnNextCell(pawn2, pawn))) && pawn2.thingIDNumber < pawn.thingIDNumber) { return(false); } } else if (pawn2.Position == pawn.Position || pawn2.Position == nextCell) { return(false); } } } } iterator.MoveNext(); } return(true); }
protected bool CanHit(Thing thing) { if (!thing.Spawned) { return(false); } if (thing == this.launcher) { return(false); } bool flag = false; CellRect.CellRectIterator iterator = thing.OccupiedRect().GetIterator(); while (!iterator.Done()) { List <Thing> thingList = iterator.Current.GetThingList(base.Map); bool flag2 = false; for (int i = 0; i < thingList.Count; i++) { if (thingList[i] != thing && thingList[i].def.Fillage == FillCategory.Full && thingList[i].def.Altitude >= thing.def.Altitude) { flag2 = true; break; } } if (!flag2) { flag = true; break; } iterator.MoveNext(); } if (!flag) { return(false); } ProjectileHitFlags hitFlags = this.HitFlags; if (thing == this.intendedTarget && (hitFlags & ProjectileHitFlags.IntendedTarget) != ProjectileHitFlags.None) { return(true); } if (thing != this.intendedTarget) { if (thing is Pawn) { if ((hitFlags & ProjectileHitFlags.NonTargetPawns) != ProjectileHitFlags.None) { return(true); } } else if ((hitFlags & ProjectileHitFlags.NonTargetWorld) != ProjectileHitFlags.None) { return(true); } } return(thing == this.intendedTarget && thing.def.Fillage == FillCategory.Full); }
public static bool TryFindSkyfallerCell(ThingDef skyfaller, Map map, out IntVec3 cell, int minDistToEdge = 10, IntVec3 nearLoc = default(IntVec3), int nearLocMaxDist = -1, bool allowRoofedCells = true, bool allowCellsWithItems = false, bool allowCellsWithBuildings = false, bool colonyReachable = false, bool avoidColonistsIfExplosive = true, bool alwaysAvoidColonists = false, Predicate <IntVec3> extraValidator = null) { bool avoidColonists = (avoidColonistsIfExplosive && skyfaller.skyfaller.CausesExplosion) || alwaysAvoidColonists; Predicate <IntVec3> validator = delegate(IntVec3 x) { CellRect.CellRectIterator iterator = GenAdj.OccupiedRect(x, Rot4.North, skyfaller.size).GetIterator(); while (!iterator.Done()) { IntVec3 current = iterator.Current; if (!current.InBounds(map) || current.Fogged(map) || !current.Standable(map) || (current.Roofed(map) && current.GetRoof(map).isThickRoof)) { return(false); } if (!allowRoofedCells && current.Roofed(map)) { return(false); } if (!allowCellsWithItems && current.GetFirstItem(map) != null) { return(false); } if (!allowCellsWithBuildings && current.GetFirstBuilding(map) != null) { return(false); } if (current.GetFirstSkyfaller(map) != null) { return(false); } iterator.MoveNext(); } if (avoidColonists && SkyfallerUtility.CanPossiblyFallOnColonist(skyfaller, x, map)) { return(false); } if (minDistToEdge > 0 && x.DistanceToEdge(map) < minDistToEdge) { return(false); } if (colonyReachable && !map.reachability.CanReachColony(x)) { return(false); } if (extraValidator != null && !extraValidator(x)) { return(false); } return(true); }; if (nearLocMaxDist > 0) { return(CellFinder.TryFindRandomCellNear(nearLoc, map, nearLocMaxDist, validator, out cell)); } return(TryFindRandomNotEdgeCellWith(minDistToEdge, validator, map, out cell)); }
public static void CheckCollapseFlyingRoofs(CellRect nearRect, Map map) { RoofCollapseCellsFinder.visitedCells.Clear(); CellRect.CellRectIterator iterator = nearRect.GetIterator(); while (!iterator.Done()) { RoofCollapseCellsFinder.CheckCollapseFlyingRoofAtAndAdjInternal(iterator.Current, map, false); iterator.MoveNext(); } RoofCollapseCellsFinder.visitedCells.Clear(); }
public static void CheckCollapseFlyingRoofs(CellRect nearRect, Map map, bool removalMode = false, bool canRemoveThickRoof = false) { visitedCells.Clear(); CellRect.CellRectIterator iterator = nearRect.GetIterator(); while (!iterator.Done()) { CheckCollapseFlyingRoofAtAndAdjInternal(iterator.Current, map, removalMode, canRemoveThickRoof); iterator.MoveNext(); } visitedCells.Clear(); }
public void DirtyMapMesh(Map map) { if (this.def.drawerType != DrawerType.RealtimeOnly) { CellRect.CellRectIterator iterator = this.OccupiedRect().GetIterator(); while (!iterator.Done()) { map.mapDrawer.MapMeshDirty(iterator.Current, MapMeshFlag.Things); iterator.MoveNext(); } } }
public static bool TryFindSkyfallerCell(ThingDef skyfaller, Map map, out IntVec3 cell, int minDistToEdge = 10, IntVec3 nearLoc = default(IntVec3), int nearLocMaxDist = -1, bool allowRoofedCells = true, bool allowCellsWithItems = false, bool allowCellsWithBuildings = false, bool colonyReachable = false, bool avoidColonistsIfExplosive = true, bool alwaysAvoidColonists = false, Predicate <IntVec3> extraValidator = null) { bool avoidColonists = (avoidColonistsIfExplosive && skyfaller.skyfaller.CausesExplosion) || alwaysAvoidColonists; Predicate <IntVec3> validator = delegate(IntVec3 x) { CellRect.CellRectIterator iterator = GenAdj.OccupiedRect(x, Rot4.North, skyfaller.size).GetIterator(); while (!iterator.Done()) { IntVec3 c = iterator.Current; bool result2; if (!c.InBounds(map) || c.Fogged(map) || !c.Standable(map) || (c.Roofed(map) && c.GetRoof(map).isThickRoof)) { result2 = false; } else if (!allowRoofedCells && c.Roofed(map)) { result2 = false; } else if (!allowCellsWithItems && c.GetFirstItem(map) != null) { result2 = false; } else if (!allowCellsWithBuildings && c.GetFirstBuilding(map) != null) { result2 = false; } else { if (c.GetFirstSkyfaller(map) == null) { iterator.MoveNext(); continue; } result2 = false; } return(result2); } return((!avoidColonists || !SkyfallerUtility.CanPossiblyFallOnColonist(skyfaller, x, map)) && (minDistToEdge <= 0 || x.DistanceToEdge(map) >= minDistToEdge) && (!colonyReachable || map.reachability.CanReachColony(x)) && (extraValidator == null || extraValidator(x))); }; bool result; if (nearLocMaxDist > 0) { result = CellFinder.TryFindRandomCellNear(nearLoc, map, nearLocMaxDist, validator, out cell, -1); } else { result = CellFinderLoose.TryFindRandomNotEdgeCellWith(minDistToEdge, validator, map, out cell); } return(result); }
public static bool ThingFromRegionListerReachable(Thing thing, Region region, PathEndMode peMode, Pawn traveler) { Map map = region.Map; if (peMode == PathEndMode.ClosestTouch) { peMode = GenPath.ResolveClosestTouchPathMode(traveler, map, thing.Position); } switch (peMode) { case PathEndMode.None: return(false); case PathEndMode.Touch: return(true); case PathEndMode.OnCell: if (thing.def.size.x == 1 && thing.def.size.z == 1) { if (thing.Position.GetRegion(map) == region) { return(true); } } else { CellRect.CellRectIterator iterator = thing.OccupiedRect().GetIterator(); while (!iterator.Done()) { if (iterator.Current.GetRegion(map) == region) { return(true); } iterator.MoveNext(); } } return(false); case PathEndMode.InteractionCell: if (thing.InteractionCell.GetRegion(map) == region) { return(true); } return(false); default: Log.Error("Unsupported PathEndMode: " + peMode); return(false); } }
public void DrawMapMesh() { CellRect currentViewRect = Find.CameraDriver.CurrentViewRect; currentViewRect.minX -= 17; currentViewRect.minZ -= 17; CellRect.CellRectIterator iterator = this.VisibleSections.GetIterator(); while (!iterator.Done()) { IntVec3 intVec = iterator.Current; Section section = this.sections[intVec.x, intVec.z]; section.DrawSection(!currentViewRect.Contains(section.botLeft)); iterator.MoveNext(); } }
public void MapMeshDrawerUpdate_First() { CellRect visibleSections = this.VisibleSections; bool flag = false; CellRect.CellRectIterator iterator = visibleSections.GetIterator(); while (!iterator.Done()) { IntVec3 current = iterator.Current; Section sect = this.sections[current.x, current.z]; if (this.TryUpdateSection(sect)) { flag = true; } iterator.MoveNext(); } if (!flag) { int num = 0; while (true) { int num2 = num; IntVec2 sectionCount = this.SectionCount; if (num2 < sectionCount.x) { int num3 = 0; while (true) { int num4 = num3; IntVec2 sectionCount2 = this.SectionCount; if (num4 < sectionCount2.z) { if (!this.TryUpdateSection(this.sections[num, num3])) { num3++; continue; } return; } break; } num++; continue; } break; } } }
private static void GetPawnsStandingAtOrAboutToStandAt(IntVec3 at, Map map, out int pawnsCount, out int pawnsWithLowerIdCount, out bool forPawnFound, Pawn forPawn) { pawnsCount = 0; pawnsWithLowerIdCount = 0; forPawnFound = false; CellRect.CellRectIterator iterator = CellRect.SingleCell(at).ExpandedBy(1).GetIterator(); while (!iterator.Done()) { IntVec3 current = iterator.Current; if (current.InBounds(map)) { List <Thing> thingList = current.GetThingList(map); for (int i = 0; i < thingList.Count; i++) { Pawn pawn = thingList[i] as Pawn; if (pawn != null) { if (pawn.GetPosture() == PawnPosture.Standing) { if (current != at) { if (!pawn.pather.MovingNow || pawn.pather.nextCell != pawn.pather.Destination.Cell || pawn.pather.Destination.Cell != at) { goto IL_132; } } else if (pawn.pather.MovingNow) { goto IL_132; } if (pawn == forPawn) { forPawnFound = true; } pawnsCount++; if (pawn.thingIDNumber < forPawn.thingIDNumber) { pawnsWithLowerIdCount++; } } } IL_132 :; } } iterator.MoveNext(); } }
public void Notify_LinkerCreatedOrDestroyed(Thing linker) { CellIndices cellIndices = map.cellIndices; CellRect.CellRectIterator iterator = linker.OccupiedRect().GetIterator(); while (!iterator.Done()) { IntVec3 current = iterator.Current; LinkFlags linkFlags = LinkFlags.None; List <Thing> list = map.thingGrid.ThingsListAt(current); for (int i = 0; i < list.Count; i++) { if (list[i].def.graphicData != null) { linkFlags |= list[i].def.graphicData.linkFlags; } } linkGrid[cellIndices.CellToIndex(current)] = linkFlags; iterator.MoveNext(); } }
internal void Notify_ThingAffectingRegionsSpawned(Thing b) { this.regionsToDirty.Clear(); CellRect.CellRectIterator iterator = b.OccupiedRect().ExpandedBy(1).ClipInsideMap(b.Map).GetIterator(); while (!iterator.Done()) { IntVec3 current = iterator.Current; Region validRegionAt_NoRebuild = b.Map.regionGrid.GetValidRegionAt_NoRebuild(current); if (validRegionAt_NoRebuild != null) { b.Map.temperatureCache.TryCacheRegionTempInfo(current, validRegionAt_NoRebuild); this.regionsToDirty.Add(validRegionAt_NoRebuild); } iterator.MoveNext(); } for (int i = 0; i < this.regionsToDirty.Count; i++) { this.SetRegionDirty(this.regionsToDirty[i], true); } this.regionsToDirty.Clear(); }
public static bool TryFindSkyfallerCell(ThingDef skyfaller, Map map, out IntVec3 cell, int minDistToEdge = 10, IntVec3 nearLoc = default(IntVec3), int nearLocMaxDist = -1, bool allowRoofedCells = true, bool allowCellsWithItems = false, bool allowCellsWithBuildings = false, bool colonyReachable = false, Predicate <IntVec3> extraValidator = null) { Predicate <IntVec3> validator = delegate(IntVec3 x) { CellRect.CellRectIterator iterator = GenAdj.OccupiedRect(x, Rot4.North, skyfaller.size).GetIterator(); while (!iterator.Done()) { IntVec3 current = iterator.Current; if (!current.InBounds(map) || current.Fogged(map) || !current.Standable(map) || (current.Roofed(map) && current.GetRoof(map).isThickRoof)) { return(false); } if (!allowRoofedCells && current.Roofed(map)) { return(false); } if (!allowCellsWithItems && current.GetFirstItem(map) != null) { return(false); } if (!allowCellsWithBuildings && current.GetFirstBuilding(map) != null) { return(false); } if (current.GetFirstSkyfaller(map) != null) { return(false); } iterator.MoveNext(); } return((minDistToEdge <= 0 || x.DistanceToEdge(map) >= minDistToEdge) && (!colonyReachable || map.reachability.CanReachColony(x)) && (extraValidator == null || extraValidator(x))); }; if (nearLocMaxDist > 0) { return(CellFinder.TryFindRandomCellNear(nearLoc, map, nearLocMaxDist, validator, out cell)); } return(CellFinderLoose.TryFindRandomNotEdgeCellWith(minDistToEdge, validator, map, out cell)); }
public override void DeSpawn() { Map map = base.Map; base.DeSpawn(); if (this.def.IsEdifice()) { map.edificeGrid.DeRegister(this); } if (this.def.MakeFog) { map.fogGrid.Notify_FogBlockerRemoved(base.Position); } if (this.def.holdsRoof) { RoofCollapseCellsFinder.Notify_RoofHolderDespawned(this, map); } if (this.sustainerAmbient != null) { this.sustainerAmbient.End(); } CellRect cellRect = this.OccupiedRect(); for (int i = cellRect.minZ; i <= cellRect.maxZ; i++) { for (int j = cellRect.minX; j <= cellRect.maxX; j++) { IntVec3 loc = new IntVec3(j, 0, i); MapMeshFlag mapMeshFlag = MapMeshFlag.Buildings; if (this.def.coversFloor) { mapMeshFlag |= MapMeshFlag.Terrain; } if (this.def.Fillage == FillCategory.Full) { mapMeshFlag |= MapMeshFlag.Roofs; mapMeshFlag |= MapMeshFlag.Snow; } map.mapDrawer.MapMeshDirty(loc, mapMeshFlag); map.glowGrid.MarkGlowGridDirty(loc); } } map.listerBuildings.Remove(this); map.listerBuildingsRepairable.Notify_BuildingDeSpawned(this); if (this.def.leaveTerrain != null && Current.ProgramState == ProgramState.Playing) { CellRect.CellRectIterator iterator = this.OccupiedRect().GetIterator(); while (!iterator.Done()) { map.terrainGrid.SetTerrain(iterator.Current, this.def.leaveTerrain); iterator.MoveNext(); } } map.designationManager.Notify_BuildingDespawned(this); if (!this.CanBeSeenOver()) { map.exitMapGrid.Notify_LOSBlockerDespawned(); } if (this.def.building.hasFuelingPort) { IntVec3 fuelingPortCell = FuelingPortUtility.GetFuelingPortCell(base.Position, base.Rotation); CompLaunchable compLaunchable = FuelingPortUtility.LaunchableAt(fuelingPortCell, map); if (compLaunchable != null) { compLaunchable.Notify_FuelingPortSourceDeSpawned(); } } if (this.def.building.ai_combatDangerous) { AvoidGridMaker.Notify_CombatDangerousBuildingDespawned(this, map); } }
public bool TryFindShootLineFromTo(IntVec3 root, LocalTargetInfo targ, out ShootLine resultingLine) { if (targ.HasThing && targ.Thing.Map != this.caster.Map) { resultingLine = default(ShootLine); return(false); } if (this.verbProps.IsMeleeAttack || this.verbProps.range <= 1.42f) { resultingLine = new ShootLine(root, targ.Cell); return(ReachabilityImmediate.CanReachImmediate(root, targ, this.caster.Map, PathEndMode.Touch, null)); } CellRect cellRect = (!targ.HasThing) ? CellRect.SingleCell(targ.Cell) : targ.Thing.OccupiedRect(); float num = this.verbProps.EffectiveMinRange(targ, this.caster); float num2 = cellRect.ClosestDistSquaredTo(root); if (num2 > this.verbProps.range * this.verbProps.range || num2 < num * num) { resultingLine = new ShootLine(root, targ.Cell); return(false); } if (!this.verbProps.requireLineOfSight) { resultingLine = new ShootLine(root, targ.Cell); return(true); } if (this.CasterIsPawn) { IntVec3 dest; if (this.CanHitFromCellIgnoringRange(root, targ, out dest)) { resultingLine = new ShootLine(root, dest); return(true); } ShootLeanUtility.LeanShootingSourcesFromTo(root, cellRect.ClosestCellTo(root), this.caster.Map, Verb.tempLeanShootSources); for (int i = 0; i < Verb.tempLeanShootSources.Count; i++) { IntVec3 intVec = Verb.tempLeanShootSources[i]; if (this.CanHitFromCellIgnoringRange(intVec, targ, out dest)) { resultingLine = new ShootLine(intVec, dest); return(true); } } } else { CellRect.CellRectIterator iterator = this.caster.OccupiedRect().GetIterator(); while (!iterator.Done()) { IntVec3 intVec2 = iterator.Current; IntVec3 dest; if (this.CanHitFromCellIgnoringRange(intVec2, targ, out dest)) { resultingLine = new ShootLine(intVec2, dest); return(true); } iterator.MoveNext(); } } resultingLine = new ShootLine(root, targ.Cell); return(false); }
public static IntVec3 FindNoWipeSpawnLocNear(IntVec3 near, Map map, ThingDef thingToSpawn, Rot4 rot, int maxDist = 2, Predicate <IntVec3> extraValidator = null) { int num = GenRadial.NumCellsInRadius((float)maxDist); IntVec3 intVec = IntVec3.Invalid; float num2 = 0f; for (int i = 0; i < num; i++) { IntVec3 intVec2 = near + GenRadial.RadialPattern[i]; if (intVec2.InBounds(map)) { CellRect cellRect = GenAdj.OccupiedRect(intVec2, rot, thingToSpawn.size); if (cellRect.InBounds(map)) { if (GenSight.LineOfSight(near, intVec2, map, true, null, 0, 0)) { if (extraValidator == null || extraValidator(intVec2)) { if (thingToSpawn.category != ThingCategory.Building || GenConstruct.CanBuildOnTerrain(thingToSpawn, intVec2, map, rot, null)) { bool flag = false; bool flag2 = false; CellFinder.tmpUniqueWipedThings.Clear(); CellRect.CellRectIterator iterator = cellRect.GetIterator(); while (!iterator.Done()) { if (iterator.Current.Impassable(map)) { flag2 = true; } List <Thing> thingList = iterator.Current.GetThingList(map); for (int j = 0; j < thingList.Count; j++) { if (thingList[j] is Pawn) { flag = true; } else if (GenSpawn.SpawningWipes(thingToSpawn, thingList[j].def) && !CellFinder.tmpUniqueWipedThings.Contains(thingList[j])) { CellFinder.tmpUniqueWipedThings.Add(thingList[j]); } } iterator.MoveNext(); } if (flag && thingToSpawn.passability == Traversability.Impassable) { CellFinder.tmpUniqueWipedThings.Clear(); } else if (flag2 && thingToSpawn.category == ThingCategory.Item) { CellFinder.tmpUniqueWipedThings.Clear(); } else { float num3 = 0f; for (int k = 0; k < CellFinder.tmpUniqueWipedThings.Count; k++) { if (CellFinder.tmpUniqueWipedThings[k].def.category == ThingCategory.Building && !CellFinder.tmpUniqueWipedThings[k].def.costList.NullOrEmpty <ThingDefCountClass>() && CellFinder.tmpUniqueWipedThings[k].def.costStuffCount == 0) { List <ThingDefCountClass> list = CellFinder.tmpUniqueWipedThings[k].CostListAdjusted(); for (int l = 0; l < list.Count; l++) { num3 += list[l].thingDef.GetStatValueAbstract(StatDefOf.MarketValue, null) * (float)list[l].count * (float)CellFinder.tmpUniqueWipedThings[k].stackCount; } } else { num3 += CellFinder.tmpUniqueWipedThings[k].MarketValue * (float)CellFinder.tmpUniqueWipedThings[k].stackCount; } if (CellFinder.tmpUniqueWipedThings[k].def.category == ThingCategory.Building || CellFinder.tmpUniqueWipedThings[k].def.category == ThingCategory.Item) { num3 = Mathf.Max(num3, 0.001f); } } CellFinder.tmpUniqueWipedThings.Clear(); if (!intVec.IsValid || num3 < num2) { if (num3 == 0f) { return(intVec2); } intVec = intVec2; num2 = num3; } } } } } } } } return((!intVec.IsValid) ? near : intVec); }