void markDirty() { var width = (int)Math.Floor(info.Width / 2f); var width2 = info.Width - width; foreach (var point in points) { for (int x = point.X - width; x < point.X + width2; x++) { if (x >= 0 && x < Bounds.X) { for (int y = point.Y - width; y < point.Y + width2; y++) { if (y >= 0 && y < Bounds.Y) { if (Loader.AcquireCell(new MPos(x, y), info.ID, denyPatrols: false)) { UsedCells[x, y] = true; } } } } } } }
void markDirty() { for (int x = 0; x < Bounds.X; x++) { for (int y = 0; y < Bounds.Y; y++) { var value = noise[x, y]; var randomValue = Random.NextDouble(); var limit = GeneratorUtils.Multiplier(info.ProbabilitySteps, info.RangeSteps, value); if (randomValue > limit) { continue; } if (Loader.AcquireCell(new MPos(x, y), info.ID, denyPatrols: info.DenyPatrols)) { UsedCells[x, y] = true; } } } }
public override void Generate() { var spawn = info.FillMap ? MPos.Zero : Center - new MPos(info.MinimumDimensions, info.MinimumDimensions); if (spawn.X < 0) { spawn = new MPos(0, spawn.Y); } if (spawn.Y < 0) { spawn = new MPos(spawn.X, 0); } var bounds = info.FillMap ? Bounds : new MPos(Random.Next(info.MaximumDimensions - info.MinimumDimensions) + info.MinimumDimensions, Random.Next(info.MaximumDimensions - info.MinimumDimensions) + info.MinimumDimensions); if (spawn.X + bounds.X >= Bounds.X) { bounds = new MPos(Bounds.X - spawn.X, bounds.Y); } if (spawn.Y + bounds.Y >= Bounds.Y) { bounds = new MPos(bounds.X, Bounds.Y - spawn.Y); } // If smaller than map bounds, abort if (bounds.X < info.MinimumDimensions || bounds.Y < info.MinimumDimensions) { return; } var baseCell = new Cell(16, spawn, bounds, info); cells = cellLoop(baseCell, 16); for (int x = spawn.X; x < spawn.X + bounds.X; x++) { for (int y = spawn.Y; y < spawn.Y + bounds.Y; y++) { road[x, y] = true; } } pieceCells = new List <PieceCell>(); foreach (var cell in cells) { var piece = new PieceCell(cell.Position, cell.Size, info); pieceCells.AddRange(pieceLoop(piece)); } foreach (var cell in cells) { if (!Loader.CanAcquireArea(cell.Position, cell.Size, info.ID)) { continue; } for (int x = cell.Position.X; x < cell.Position.X + cell.Size.X; x++) { for (int y = cell.Position.Y; y < cell.Position.Y + cell.Size.Y; y++) { if (Loader.AcquireCell(new MPos(x, y), info.ID)) { UsedCells[x, y] = true; } road[x, y] = false; } } } // Roads var type = Loader.Infos.FirstOrDefault(i => i.ID == info.PathGeneratorID && i is PathGeneratorInfo); if (type != null) { for (int x = 0; x < Bounds.X; x++) { for (int y = 0; y < Bounds.Y; y++) { if (!(road[x, y] && Loader.AcquireCell(new MPos(x, y), info.PathGeneratorID))) { road[x, y] = false; } } } var generator = new PathGenerator(Random, Loader, type as PathGeneratorInfo); generator.Generate(road); } // Pieces foreach (var piece in pieceCells) { var size = piece.Size / new MPos(info.CellSize, info.CellSize); var fitting = info.Pieces.FirstOrDefault(p => p.Size == size); if (fitting == null) { continue; } Loader.GeneratePiece(getPiece(fitting.Pieces), piece.Position, info.ID, idInclusive: true); } MapPrinter.PrintGeneratorMap(Bounds, NoiseMap.Empty, UsedCells, info.ID); }