ChartStatic CarveEntrancesIntoChart(RawChart chart, Maze maze, Coord coord) { IEnumerable<MapEntrance> entrances = GetEntrances(maze, coord); chart.Seed = seed; var staticModule = MapGenStaticMap.Construct(chart.Map); var carvedModule = MapGenEntranceCarver.Construct(staticModule, entrances); return ChartStatic.ReplaceMap(carvedModule.Generate(seed), chart); }
/// <summary> /// Replaces the map in the chart, creating a new static chart with the same markers and metadata as the original. /// Note that the copy may be shallow. /// </summary> public static ChartStatic ReplaceMap(Map map, RawChart chart) { ChartStatic newChart = Construct(map); newChart.name = chart.name; newChart.markers = chart.Markers.ToList(); newChart.metaData = chart.MetaData; return(newChart); }
public override Dictionary <Coord, RawChart> GetCharts(Maze maze) { ValidateCharts(); random = new System.Random(seed); Coord[] cells = maze.GetCells(); var chartsByCoord = new Dictionary <Coord, RawChart>(); for (int i = 0; i < cells.Length; i++) { Coord cell = cells[i]; ChartStatic[] candidateCharts = DetermineChartCandidates(maze, cell); RawChart chart = candidateCharts[random.Next(0, candidateCharts.Length)]; ChartStatic carvedChart = CarveEntrancesIntoChart(chart, maze, cell); chartsByCoord[cell] = carvedChart; } return(chartsByCoord); }
public Chart(RawChart chart, Coord offset) { if (chart == null) { throw new ArgumentNullException("chart"); } if (chart.Map == null) { throw new ArgumentException("Chart has invalid (null) map"); } map = chart.Map; name = chart.name; markers = chart.Markers.Select(m => new Marker(m, offset)).ToArray(); this.offset = offset; metaData = chart.MetaData.Unpack(); }