protected void brushStroke(Map map, Map.Coordinate center, int brushSize, Map.CellState state) { Vector3 pos = map.GetRelativePosition(center); List<Map.Coordinate> coords = new List<Map.Coordinate>(); for (Map.Coordinate x = center.Move(Direction.NegativeX, this.BrushSize - 1); x.X < center.X + this.BrushSize; x.X++) { for (Map.Coordinate y = x.Move(Direction.NegativeY, this.BrushSize - 1); y.Y < center.Y + this.BrushSize; y.Y++) { for (Map.Coordinate z = y.Move(Direction.NegativeZ, this.BrushSize - 1); z.Z < center.Z + this.BrushSize; z.Z++) { if ((pos - map.GetRelativePosition(z)).Length() <= this.BrushSize) coords.Add(z); } } } if (state.ID == 0) map.Empty(coords); else { foreach (Map.Coordinate coord in coords) map.Fill(coord, state); } }
protected void brushStroke(Map map, Map.Coordinate center, int brushSize, Func<Map.Coordinate, Map.CellState> function, bool fill = true, bool empty = true) { Vector3 pos = map.GetRelativePosition(center); List<Map.Coordinate> coords = new List<Map.Coordinate>(); for (Map.Coordinate x = center.Move(Direction.NegativeX, this.BrushSize - 1); x.X < center.X + this.BrushSize; x.X++) { for (Map.Coordinate y = x.Move(Direction.NegativeY, this.BrushSize - 1); y.Y < center.Y + this.BrushSize; y.Y++) { for (Map.Coordinate z = y.Move(Direction.NegativeZ, this.BrushSize - 1); z.Z < center.Z + this.BrushSize; z.Z++) { if ((pos - map.GetRelativePosition(z)).Length() <= this.BrushSize) coords.Add(new Map.Coordinate { X = z.X, Y = z.Y, Z = z.Z, Data = function(z) }); } } } if (empty) map.Empty(coords.Where(x => x.Data.ID == 0)); if (fill) { foreach (Map.Coordinate coord in coords) map.Fill(coord, coord.Data); } }