Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/maps/random/rmgen/gaia_entities.js
Show All 9 Lines | function getTreeCounts(minTrees, maxTrees, forestRatio) | ||||
return [forestRatio, 1 - forestRatio].map(p => p * scaleByMapSize(minTrees, maxTrees)); | return [forestRatio, 1 - forestRatio].map(p => p * scaleByMapSize(minTrees, maxTrees)); | ||||
} | } | ||||
/** | /** | ||||
* Places uniformly sized forests at random locations. | * Places uniformly sized forests at random locations. | ||||
* Generates two variants of forests from the given terrain textures and tree templates. | * Generates two variants of forests from the given terrain textures and tree templates. | ||||
* The forest border has less trees than the inside. | * The forest border has less trees than the inside. | ||||
*/ | */ | ||||
function createForests(terrainSet, constraint, tileClass, treeCount) | function createForests(terrainSet, constraint, tileClass, treeCount, retryFactor) | ||||
{ | { | ||||
if (!treeCount) | if (!treeCount) | ||||
return; | return; | ||||
// Construct different forest types from the terrain textures and template names. | // Construct different forest types from the terrain textures and template names. | ||||
let [mainTerrain, terrainForestFloor1, terrainForestFloor2, terrainForestTree1, terrainForestTree2] = terrainSet; | let [mainTerrain, terrainForestFloor1, terrainForestFloor2, terrainForestTree1, terrainForestTree2] = terrainSet; | ||||
// The painter will pick a random Terrain for each part of the forest. | // The painter will pick a random Terrain for each part of the forest. | ||||
Show All 13 Lines | function createForests(terrainSet, constraint, tileClass, treeCount, retryFactor) | ||||
for (let forestVariant of forestVariants) | for (let forestVariant of forestVariants) | ||||
createAreas( | createAreas( | ||||
new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), treeCount / numberOfForests, 0.5), | new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), treeCount / numberOfForests, 0.5), | ||||
[ | [ | ||||
new LayeredPainter([forestVariant.borderTerrains, forestVariant.interiorTerrains], [2]), | new LayeredPainter([forestVariant.borderTerrains, forestVariant.interiorTerrains], [2]), | ||||
new TileClassPainter(tileClass) | new TileClassPainter(tileClass) | ||||
], | ], | ||||
constraint, | constraint, | ||||
numberOfForests); | numberOfForests, | ||||
retryFactor); | |||||
} | } | ||||
/** | /** | ||||
* Places the given amount of Entities at random places meeting the given Constraint, chosing a different template for each. | * Places the given amount of Entities at random places meeting the given Constraint, chosing a different template for each. | ||||
*/ | */ | ||||
function createStragglerTrees(templateNames, constraint, tileClass, treeCount) | function createStragglerTrees(templateNames, constraint, tileClass, treeCount, retryFactor) | ||||
{ | { | ||||
g_Map.log("Creating straggler trees"); | g_Map.log("Creating straggler trees"); | ||||
for (let templateName of templateNames) | for (let templateName of templateNames) | ||||
createObjectGroupsDeprecated( | createObjectGroupsDeprecated( | ||||
new SimpleGroup([new SimpleObject(templateName, 1, 1, 0, 3)], true, tileClass), | new SimpleGroup([new SimpleObject(templateName, 1, 1, 0, 3)], true, tileClass), | ||||
0, | 0, | ||||
constraint, | constraint, | ||||
Math.floor(treeCount / templateNames.length)); | Math.floor(treeCount / templateNames.length), | ||||
retryFactor); | |||||
} | } | ||||
/** | /** | ||||
* Places a SimpleGroup consisting of the given number of the given Objects | * Places a SimpleGroup consisting of the given number of the given Objects | ||||
* at random locations that meet the given Constraint. | * at random locations that meet the given Constraint. | ||||
*/ | */ | ||||
function createMines(objects, constraint, tileClass, count) | function createMines(objects, constraint, tileClass, count) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator