forked from mirrors/0ad
Extend the rmgen AndConstraint to be more permissive and receive falsy values or a Constraint to remove some Constraint conversion duplication, refs #4805.
This was SVN commit r20861.
This commit is contained in:
@@ -17,7 +17,12 @@ NullConstraint.prototype.allows = function(x, z)
|
||||
*/
|
||||
function AndConstraint(constraints)
|
||||
{
|
||||
this.constraints = constraints;
|
||||
if (constraints instanceof Array)
|
||||
this.constraints = constraints
|
||||
else if (!constraints)
|
||||
this.constraints = [];
|
||||
else
|
||||
this.constraints = [constraints];
|
||||
}
|
||||
|
||||
AndConstraint.prototype.allows = function(x, z)
|
||||
|
||||
@@ -65,10 +65,9 @@ function createMountains(terrain, constraint, tileClass, count, maxHeight, minRa
|
||||
/**
|
||||
* Create a mountain using a technique very similar to ChainPlacer.
|
||||
*/
|
||||
function createMountain(maxHeight, minRadius, maxRadius, numCircles, constraint, x, z, terrain, tileClass, fcc = 0, q = [])
|
||||
function createMountain(maxHeight, minRadius, maxRadius, numCircles, constraints, x, z, terrain, tileClass, fcc = 0, q = [])
|
||||
{
|
||||
if (constraint instanceof Array)
|
||||
constraint = new AndConstraint(constraint);
|
||||
let constraint = new AndConstraint(constraints);
|
||||
|
||||
if (!g_Map.inMapBounds(x, z) || !constraint.allows(x, z))
|
||||
return;
|
||||
|
||||
@@ -247,17 +247,12 @@ function getTileClass(id)
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new Area shaped by the Placer meeting the Constraint and calls the Painters there.
|
||||
* Constructs a new Area shaped by the Placer meeting the Constraints and calls the Painters there.
|
||||
* Supports both Centered and Non-Centered Placers.
|
||||
*/
|
||||
function createArea(placer, painter, constraint)
|
||||
function createArea(placer, painter, constraints)
|
||||
{
|
||||
if (!constraint)
|
||||
constraint = new NullConstraint();
|
||||
else if (constraint instanceof Array)
|
||||
constraint = new AndConstraint(constraint);
|
||||
|
||||
let points = placer.place(constraint);
|
||||
let points = placer.place(new AndConstraint(constraints));
|
||||
if (!points)
|
||||
return undefined;
|
||||
|
||||
@@ -296,17 +291,12 @@ function unPaintTileClassBasedOnHeight(minHeight, maxHeight, mode, tileClass)
|
||||
}
|
||||
|
||||
/**
|
||||
* Places the Entities of the given Group if they meet the Constraint
|
||||
* Places the Entities of the given Group if they meet the Constraints
|
||||
* and sets the given player as the owner.
|
||||
*/
|
||||
function createObjectGroup(group, player, constraint)
|
||||
function createObjectGroup(group, player, constraints)
|
||||
{
|
||||
if (!constraint)
|
||||
constraint = new NullConstraint();
|
||||
else if (constraint instanceof Array)
|
||||
constraint = new AndConstraint(constraint);
|
||||
|
||||
return group.place(player, constraint);
|
||||
return group.place(player, new AndConstraint(constraints));
|
||||
}
|
||||
|
||||
function getMapSize()
|
||||
|
||||
Reference in New Issue
Block a user