Add rmgen HeightConstraint to allow placing entities in a given height range.

This was SVN commit r20862.
This commit is contained in:
elexis
2018-01-13 22:13:03 +00:00
parent 495f83663e
commit 6278f75a1f
@@ -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;
};