mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-07-04 05:55:47 -07:00
Add rmgen HeightConstraint to allow placing entities in a given height range.
This was SVN commit r20862.
This commit is contained in:
parent
495f83663e
commit
6278f75a1f
1 changed files with 15 additions and 0 deletions
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue