private void Rebuild() { this.dirty = false; if (this.exitMapGrid == null) { this.exitMapGrid = new BoolGrid(this.map); } else { this.exitMapGrid.Clear(); } CellRect cellRect = CellRect.WholeMap(this.map); for (int i = cellRect.minZ; i <= cellRect.maxZ; i++) { for (int j = cellRect.minX; j <= cellRect.maxX; j++) { if (i > 1 && i < cellRect.maxZ - 2 + 1 && j > 1 && j < cellRect.maxX - 2 + 1) { j = cellRect.maxX - 2 + 1; } IntVec3 intVec = new IntVec3(j, 0, i); if (this.IsGoodExitCell(intVec)) { this.exitMapGrid[intVec] = true; } } } if (this.drawerInt != null) { this.drawerInt.SetDirty(); } }
public static void DrawFieldEdges(List <IntVec3> cells, Color color) { Map currentMap = Find.CurrentMap; MaterialRequest req = default(MaterialRequest); req.shader = ShaderDatabase.Transparent; req.color = color; req.BaseTexPath = "UI/Overlays/TargetHighlight_Side"; Material material = MaterialPool.MatFrom(req); material.GetTexture("_MainTex").wrapMode = TextureWrapMode.Clamp; if (fieldGrid == null) { fieldGrid = new BoolGrid(currentMap); } else { fieldGrid.ClearAndResizeTo(currentMap); } IntVec3 size = currentMap.Size; int x = size.x; IntVec3 size2 = currentMap.Size; int z = size2.z; int count = cells.Count; for (int i = 0; i < count; i++) { if (cells[i].InBounds(currentMap)) { BoolGrid boolGrid = fieldGrid; IntVec3 intVec = cells[i]; int x2 = intVec.x; IntVec3 intVec2 = cells[i]; boolGrid[x2, intVec2.z] = true; } } for (int j = 0; j < count; j++) { IntVec3 c = cells[j]; if (c.InBounds(currentMap)) { rotNeeded[0] = (c.z < z - 1 && !fieldGrid[c.x, c.z + 1]); rotNeeded[1] = (c.x < x - 1 && !fieldGrid[c.x + 1, c.z]); rotNeeded[2] = (c.z > 0 && !fieldGrid[c.x, c.z - 1]); rotNeeded[3] = (c.x > 0 && !fieldGrid[c.x - 1, c.z]); for (int k = 0; k < 4; k++) { if (rotNeeded[k]) { Graphics.DrawMesh(MeshPool.plane10, c.ToVector3ShiftedWithAltitude(AltitudeLayer.MetaOverlays), new Rot4(k).AsQuat, material, 0); } } } } }
public void CheckContiguous() { if (cells.Count != 0) { if (extantGrid == null) { extantGrid = new BoolGrid(Map); } else { extantGrid.ClearAndResizeTo(Map); } if (foundGrid == null) { foundGrid = new BoolGrid(Map); } else { foundGrid.ClearAndResizeTo(Map); } for (int i = 0; i < cells.Count; i++) { extantGrid.Set(cells[i], value: true); } Predicate <IntVec3> passCheck = delegate(IntVec3 c) { if (!extantGrid[c]) { return(false); } if (foundGrid[c]) { return(false); } return(true); }; int numFound = 0; Action <IntVec3> processor = delegate(IntVec3 c) { foundGrid.Set(c, value: true); numFound++; }; Map.floodFiller.FloodFill(cells[0], passCheck, processor); if (numFound < cells.Count) { foreach (IntVec3 allCell in Map.AllCells) { if (extantGrid[allCell] && !foundGrid[allCell]) { RemoveCell(allCell); } } } } }
public void CheckContiguous() { if (this.cells.Count != 0) { if (Zone.extantGrid == null) { Zone.extantGrid = new BoolGrid(this.Map); } else { Zone.extantGrid.ClearAndResizeTo(this.Map); } if (Zone.foundGrid == null) { Zone.foundGrid = new BoolGrid(this.Map); } else { Zone.foundGrid.ClearAndResizeTo(this.Map); } for (int i = 0; i < this.cells.Count; i++) { Zone.extantGrid.Set(this.cells[i], true); } Predicate <IntVec3> passCheck = delegate(IntVec3 c) { if (!Zone.extantGrid[c]) { return(false); } if (Zone.foundGrid[c]) { return(false); } return(true); }; int numFound = 0; Action <IntVec3> processor = delegate(IntVec3 c) { Zone.foundGrid.Set(c, true); numFound++; }; this.Map.floodFiller.FloodFill(this.cells[0], passCheck, processor, 2147483647, false, null); if (numFound < this.cells.Count) { foreach (IntVec3 allCell in this.Map.AllCells) { if (Zone.extantGrid[allCell] && !Zone.foundGrid[allCell]) { this.RemoveCell(allCell); } } } } }
public static void DrawFieldEdges(List <IntVec3> cells, Color color) { Map visibleMap = Find.VisibleMap; Material material = MaterialPool.MatFrom(new MaterialRequest { shader = ShaderDatabase.Transparent, color = color, BaseTexPath = "UI/Overlays/TargetHighlight_Side" }); material.GetTexture("_MainTex").wrapMode = TextureWrapMode.Clamp; if (GenDraw.fieldGrid == null) { GenDraw.fieldGrid = new BoolGrid(visibleMap); } else { GenDraw.fieldGrid.ClearAndResizeTo(visibleMap); } int x = visibleMap.Size.x; int z = visibleMap.Size.z; int count = cells.Count; for (int i = 0; i < count; i++) { if (cells[i].InBounds(visibleMap)) { GenDraw.fieldGrid[cells[i].x, cells[i].z] = true; } } for (int j = 0; j < count; j++) { IntVec3 c = cells[j]; if (c.InBounds(visibleMap)) { GenDraw.rotNeeded[0] = (c.z < z - 1 && !GenDraw.fieldGrid[c.x, c.z + 1]); GenDraw.rotNeeded[1] = (c.x < x - 1 && !GenDraw.fieldGrid[c.x + 1, c.z]); GenDraw.rotNeeded[2] = (c.z > 0 && !GenDraw.fieldGrid[c.x, c.z - 1]); GenDraw.rotNeeded[3] = (c.x > 0 && !GenDraw.fieldGrid[c.x - 1, c.z]); for (int k = 0; k < 4; k++) { if (GenDraw.rotNeeded[k]) { Mesh arg_219_0 = MeshPool.plane10; Vector3 arg_219_1 = c.ToVector3ShiftedWithAltitude(AltitudeLayer.MetaOverlays); Rot4 rot = new Rot4(k); Graphics.DrawMesh(arg_219_0, arg_219_1, rot.AsQuat, material, 0); } } } } }
public static CellRect FindLargestRect(Map map, Predicate <IntVec3> predicate, int breakEarlyOn = -1) { if (visited == null) { visited = new BoolGrid(map); } visited.ClearAndResizeTo(map); Rand.PushState(map.uniqueID ^ 0x1CDAF373); CellRect largestRect = CellRect.Empty; for (int i = 0; i < 3; i++) { tmpProcessed.Clear(); foreach (IntVec3 item in map.cellsInRandomOrder.GetAll().InRandomOrder(randomOrderWorkingList)) { CellRect cellRect = FindLargestRectAt(item, map, tmpProcessed, predicate); if (cellRect.Area > largestRect.Area) { largestRect = cellRect; if (ShouldBreakEarly()) { break; } } } if (ShouldBreakEarly()) { break; } } Rand.PopState(); return(largestRect); bool ShouldBreakEarly() { if (breakEarlyOn >= 0 && largestRect.Width >= breakEarlyOn) { return(largestRect.Height >= breakEarlyOn); } return(false); } }
public Area(AreaManager areaManager) { this.areaManager = areaManager; this.innerGrid = new BoolGrid(areaManager.map); this.ID = Find.UniqueIDsManager.GetNextAreaID(); }