mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 15:04:15 +00:00
Move the HeightPlacer from the Schwarzwald map (49194819f6) to the placer library, refs #4804.
Remove the unneeded NullConstraint check. This was SVN commit r20361.
This commit is contained in:
@@ -35,6 +35,29 @@ RectPlacer.prototype.place = function(constraint)
|
||||
return points;
|
||||
};
|
||||
|
||||
/**
|
||||
* The HeightPlacer provides all points between the minimum and maximum elevation that meet the Constraint.
|
||||
*/
|
||||
function HeightPlacer(minElevation, maxElevation)
|
||||
{
|
||||
this.minElevation = minElevation;
|
||||
this.maxElevation = maxElevation;
|
||||
}
|
||||
|
||||
HeightPlacer.prototype.place = function(constraint)
|
||||
{
|
||||
let mapSize = getMapSize();
|
||||
let points = [];
|
||||
for (let x = 0; x < mapSize; ++x)
|
||||
for (let z = 0; z < mapSize; ++z)
|
||||
if (g_Map.height[x][z] >= this.minElevation &&
|
||||
g_Map.height[x][z] <= this.maxElevation &&
|
||||
constraint.allows(x, z))
|
||||
points.push(new PointXZ(x, z));
|
||||
|
||||
return points;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PathPlacer
|
||||
//
|
||||
|
||||
@@ -111,31 +111,6 @@ var resourceRadius = 2/3 * mapRadius;
|
||||
var maxTreeDensity = min(256 * (192 + 8 * numPlayers) / (mapSize * mapSize), 1); // Has to be tweeked but works ok
|
||||
var bushChance = 1/3; // 1 means 50% chance in deepest wood, 0.5 means 25% chance in deepest wood
|
||||
|
||||
////////////////
|
||||
//
|
||||
// Some general functions
|
||||
//
|
||||
////////////////
|
||||
|
||||
function HeightPlacer(lowerBound, upperBound) {
|
||||
this.lowerBound = lowerBound;
|
||||
this.upperBound = upperBound;
|
||||
}
|
||||
|
||||
HeightPlacer.prototype.place = function (constraint) {
|
||||
constraint = (constraint || new NullConstraint());
|
||||
|
||||
var ret = [];
|
||||
for (var x = 0; x < g_Map.size; x++) {
|
||||
for (var y = 0; y < g_Map.size; y++) {
|
||||
if (g_Map.height[x][y] >= this.lowerBound && g_Map.height[x][y] <= this.upperBound && constraint.allows(x, y)) {
|
||||
ret.push(new PointXZ(x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
////////////////
|
||||
// Set height limits and water level by map size
|
||||
////////////////
|
||||
|
||||
Reference in New Issue
Block a user