Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/maps/random/heightmap/heightmap.js
Show First 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | function distributeEntitiesByHeight(heightRange, avoidPoints, minDistance = 30, entityList = [g_Gaia.stoneLarge, g_Gaia.metalLarge], | ||||
if (!validPoints.length) | if (!validPoints.length) | ||||
{ | { | ||||
log("No placement points found for the given arguments (entityList=" + uneval(entityList) + "):\n" + new Error().stack); | log("No placement points found for the given arguments (entityList=" + uneval(entityList) + "):\n" + new Error().stack); | ||||
return placements; | return placements; | ||||
} | } | ||||
for (let tries = 0; tries < maxTries; ++tries) | for (let tries = 0; tries < maxTries; ++tries) | ||||
{ | { | ||||
let checkPointIndex = randInt(validPoints.length); | let checkPointIndex = randIntExclusive(0, validPoints.length); | ||||
let checkPoint = validPoints[checkPointIndex]; | let checkPoint = validPoints[checkPointIndex]; | ||||
if (placements.every(p => getDistance(p.x, p.y, checkPoint.x, checkPoint.y) > minDistance)) | if (placements.every(p => getDistance(p.x, p.y, checkPoint.x, checkPoint.y) > minDistance)) | ||||
{ | { | ||||
placeObject(checkPoint.x, checkPoint.y, pickRandom(entityList), playerID, randFloat(0, 2*PI)); | placeObject(checkPoint.x, checkPoint.y, pickRandom(entityList), playerID, randFloat(0, 2*PI)); | ||||
placements.push(checkPoint); | placements.push(checkPoint); | ||||
} | } | ||||
validPoints.splice(checkPointIndex); | validPoints.splice(checkPointIndex); | ||||
▲ Show 20 Lines • Show All 188 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator