Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/maps/random/rmgen/library.js
Show First 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | else | ||||
placer.z = randInt(g_Map.size); | placer.z = randInt(g_Map.size); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Helper function for randomly placing areas and groups in the given areas. | * Helper function for randomly placing areas and groups in the given areas. | ||||
*/ | */ | ||||
function randomizePlacerCoordinatesFromAreas(placer, areas) | function randomizePlacerCoordinatesFromAreas(placer, areas) | ||||
{ | { | ||||
let i = randInt(areas.length); | placer = pickRandom(pickRandom(areas).points); | ||||
elexis: ✓ | |||||
elexisUnsubmitted Not Done Inline ActionsNOPE, destructor Destructuring assignment https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment only works with arrays, not objects with other properties would have to be [placer.x, placer.z] = ... elexis: NOPE, destructor Destructuring assignment https://developer.mozilla.org/en… | |||||
Not Done Inline ActionsThis doesn't work, test cycladic and see the crash, placer = pickRandom(pickRandom(areas).points) does work. (pickRandom returns an object right...) bb: This doesn't work, test cycladic and see the crash, `placer = pickRandom(pickRandom(areas). | |||||
Not Done Inline Actionsright, fail while failing. /** * Helper function for randomly placing areas and groups in the given areas. */ function randomizePlacerCoordinatesFromAreas(placer, areas) { warn("BEFORE"); for (let prop in placer) warn(prop); placer = pickRandom(pickRandom(areas).points); warn("AFTER"); for (let prop in placer) warn(prop); } yields: WARNING: BEFORE WARNING: elements WARNING: tileClass WARNING: avoidSelf WARNING: x WARNING: z WARNING: place WARNING: AFTER WARNING: x WARNING: z elexis: right, fail while failing.
I'm not convinced though that this is a good change. The returned… | |||||
let pt = areas[i].points[randInt(areas[i].points.length)]; | |||||
placer.x = pt.x; | |||||
placer.z = pt.z; | |||||
} | } | ||||
/** | /** | ||||
* Attempts to place the given number of areas in random places of the map. | * Attempts to place the given number of areas in random places of the map. | ||||
* Returns actually placed areas. | * Returns actually placed areas. | ||||
*/ | */ | ||||
function createAreas(centeredPlacer, painter, constraint, amount, retryFactor = 10) | function createAreas(centeredPlacer, painter, constraint, amount, retryFactor = 10) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 381 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
✓