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 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; } } }
public void DrawMapMesh() { CellRect currentViewRect = Find.CameraDriver.CurrentViewRect; currentViewRect.minX -= 17; currentViewRect.minZ -= 17; CellRect visibleSections = this.VisibleSections; Profiler.BeginSample("Draw sections"); CellRect.CellRectIterator iterator = 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(); } Profiler.EndSample(); }
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); } } CellFinder.tmpCells.Clear(); CellRect.CellRectIterator iterator = cellRect.GetIterator(); while (!iterator.Done()) { CellFinder.tmpCells.Add(iterator.Current); iterator.MoveNext(); } CellFinder.tmpCells.Shuffle <IntVec3>(); int j = 0; int count = CellFinder.tmpCells.Count; while (j < count) { if (predicate(CellFinder.tmpCells[j])) { result = CellFinder.tmpCells[j]; return(true); } j++; } result = IntVec3.Invalid; 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); }