Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/maps/random/rmgen/painter/CityPainter.js
Context not available. | |||||
let mapCenter = g_Map.getCenter(); | let mapCenter = g_Map.getCenter(); | ||||
let mapSize = g_Map.getSize(); | let mapSize = g_Map.getSize(); | ||||
// TODO: Due to the rounding, this is wasting a lot of space. | |||||
// The city would be much denser if it would test for actual shape intersection or | |||||
// if it would use a custom, more fine-grained obstruction grid | |||||
let tileClass = g_Map.createTileClass(); | let tileClass = g_Map.createTileClass(); | ||||
let processed = new Array(mapSize).fill(0).map(() => new Uint8Array(mapSize)); | for (let point of area.getPoints()) | ||||
{ | |||||
for (let x = 0; x < mapSize; x += 0.5) | |||||
for (let y = 0; y < mapSize; y += 0.5) | |||||
{ | |||||
let point = new Vector2D(x, y).rotateAround(this.angle, mapCenter).round(); | |||||
if (!area.contains(point) || processed[point.x][point.y] || !g_Map.validTilePassable(point)) | |||||
continue; | |||||
processed[point.x][point.y] = 1; | |||||
for (let template of shuffleArray(templates)) | for (let template of shuffleArray(templates)) | ||||
{ | { | ||||
if (template.constraint && !template.constraint.allows(point)) | if (template.constraint && !template.constraint.allows(point)) | ||||
Context not available. | |||||
templates = templates.filter(template => templateCounts[template.templateName] < template.maxCount); | templates = templates.filter(template => templateCounts[template.templateName] < template.maxCount); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
Context not available. |
Wildfire Games · Phabricator