mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-18 14:23:56 -07:00
Add "has" helper function to TileClass, so that one can find out if the given tile is marked with that class or not without having to fallback to Constraints.
Performance improvement for Ambush, refs #5011. This was SVN commit r21414.
This commit is contained in:
parent
e9fb0f62ed
commit
85a3a889e7
4 changed files with 8 additions and 3 deletions
|
|
@ -35,7 +35,7 @@ addElements([
|
|||
"avoid": [g_TileClasses.bluffIgnore, 0],
|
||||
"sizes": ["normal", "big", "huge"],
|
||||
"mixes": ["same"],
|
||||
"amounts": ["tons"]
|
||||
"amounts": ["many"]
|
||||
},
|
||||
{
|
||||
"func": addHills,
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ for (var ix = 0; ix <= mapSize; ix++)
|
|||
var pn = playerNearness(x, z);
|
||||
|
||||
let c = startAngle ? z : x;
|
||||
let distToWater = stayClasses(clWater, 1).allows(position) ? 0 : (0.5 - WATER_WIDTH - Math.abs(c - 0.5));
|
||||
let distToWater = clWater.has(position) ? 0 : (0.5 - WATER_WIDTH - Math.abs(c - 0.5));
|
||||
let h = distToWater ? heightHill * (1 - Math.abs(c - 0.5) / (0.5 - WATER_WIDTH)) : g_Map.getHeight(position);
|
||||
|
||||
// add some base noise
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ if (!isNomad())
|
|||
for (let i = 0; i < getNumPlayers(); ++i)
|
||||
{
|
||||
g_Map.logger.printDuration();
|
||||
setBiome(climateZones.find(zone => stayClasses(zone.tileClass, 1).allows(playerPosition[i])).biome);
|
||||
setBiome(climateZones.find(zone => zone.tileClass.has(playerPosition[i])).biome);
|
||||
|
||||
createArea(
|
||||
new ClumpPlacer(diskArea(defaultPlayerBaseRadius() * 0.8), 0.95, 0.6, Infinity, playerPosition[i]),
|
||||
|
|
|
|||
|
|
@ -76,6 +76,11 @@ function TileClass(size)
|
|||
}
|
||||
}
|
||||
|
||||
TileClass.prototype.has = function(position)
|
||||
{
|
||||
return !!this.inclusionCount[position.x] && !!this.inclusionCount[position.x][position.y];
|
||||
}
|
||||
|
||||
TileClass.prototype.add = function(position)
|
||||
{
|
||||
if (!this.inclusionCount[position.x][position.y] && g_Map.validTile(position))
|
||||
|
|
|
|||
Loading…
Reference in a new issue