forked from mirrors/0ad
Add rmgen HeightConstraint to allow placing entities in a given height range.
This was SVN commit r20862.
This commit is contained in:
@@ -101,3 +101,18 @@ BorderTileClassConstraint.prototype.allows = function(x, z)
|
||||
return this.tileClass.countMembersInRadius(x, z, this.distanceOutside) > 0 &&
|
||||
this.tileClass.countNonMembersInRadius(x, z, this.distanceInside) > 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* The HeightConstraint is met if the elevation of the tile is within the given range.
|
||||
* One can pass Infinity to only test for one side.
|
||||
*/
|
||||
function HeightConstraint(minHeight, maxHeight)
|
||||
{
|
||||
this.minHeight = minHeight;
|
||||
this.maxHeight = maxHeight;
|
||||
}
|
||||
|
||||
HeightConstraint.prototype.allows = function(x, z)
|
||||
{
|
||||
return this.minHeight <= g_Map.height[x][z] && g_Map.height[x][z] <= this.maxHeight;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user