mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 02:23:47 +00:00
additionnal petra cleanup
fix a case with foundation access not defined This was SVN commit r17688.
This commit is contained in:
@@ -81,7 +81,7 @@ m.EntityCollection.prototype.toString = function()
|
||||
|
||||
m.EntityCollection.prototype.filter = function(filter, thisp)
|
||||
{
|
||||
if (typeof(filter) == "function")
|
||||
if (typeof filter === "function")
|
||||
filter = {"func": filter, "dynamicProperties": []};
|
||||
|
||||
var ret = new Map();
|
||||
@@ -174,11 +174,7 @@ m.EntityCollection.prototype.destroy = function()
|
||||
|
||||
m.EntityCollection.prototype.attack = function(unit)
|
||||
{
|
||||
var unitId;
|
||||
if (typeof(unit) === "Entity")
|
||||
unitId = unit.id();
|
||||
else
|
||||
unitId = unit;
|
||||
var unitId = unit;
|
||||
Engine.PostCommand(PlayerID,{"type": "attack", "entities": this.toIdArray(), "target": unitId, "queued": false});
|
||||
return this;
|
||||
};
|
||||
|
||||
@@ -108,10 +108,7 @@ m.Queue.prototype.countQueuedUnits = function()
|
||||
|
||||
m.Queue.prototype.hasQueuedUnitsWithClass = function(classe)
|
||||
{
|
||||
for (let plan of this.plans)
|
||||
if (plan.template && plan.template.hasClass(classe))
|
||||
return true;
|
||||
return false;
|
||||
return this.plans.some(plan => plan.template && plan.template.hasClass(classe));
|
||||
};
|
||||
|
||||
m.Queue.prototype.countQueuedUnitsWithClass = function(classe)
|
||||
@@ -132,15 +129,6 @@ m.Queue.prototype.countQueuedUnitsWithMetadata = function(data, value)
|
||||
return count;
|
||||
};
|
||||
|
||||
m.Queue.prototype.countAllByType = function(t)
|
||||
{
|
||||
var count = 0;
|
||||
for (let plan of this.plans)
|
||||
if (plan.type === t)
|
||||
count += plan.number;
|
||||
return count;
|
||||
};
|
||||
|
||||
m.Queue.prototype.Serialize = function()
|
||||
{
|
||||
let plans = [];
|
||||
|
||||
@@ -152,7 +152,7 @@ m.ConstructionPlan.prototype.findGoodPosition = function(gameState)
|
||||
if (pos)
|
||||
return { "x": pos[0], "z": pos[1], "angle": 3*Math.PI/4, "base": pos[2] };
|
||||
else if (template.hasClass("DefenseTower") || gameState.civ() === "mace" || gameState.civ() === "maur" ||
|
||||
gameState.countEntitiesByType(gameState.applyCiv("structures/{civ}_fortress"), true) > 0 ||
|
||||
gameState.countEntitiesByType(gameState.applyCiv("structures/{civ}_fortress"), true) > 0 ||
|
||||
gameState.countEntitiesByType(gameState.applyCiv("structures/{civ}_army_camp"), true) > 0)
|
||||
return false;
|
||||
// if this fortress is our first siege unit builder, just try the standard placement as we want siege units
|
||||
|
||||
@@ -445,7 +445,13 @@ m.Worker.prototype.startGathering = function(gameState)
|
||||
if (foundation.getMetadata(PlayerID, "base") !== self.baseID)
|
||||
self.ent.setMetadata(PlayerID, "base", foundation.getMetadata(PlayerID, "base"));
|
||||
self.ent.setMetadata(PlayerID, "target-foundation", foundation.id());
|
||||
navalManager.requireTransport(gameState, self.ent, access, base.accessIndex, foundation.position());
|
||||
let foundationAccess = foundation.getMetadata(PlayerID, "access");
|
||||
if (!foundationAccess)
|
||||
{
|
||||
foundationAccess = gameState.ai.accessibility.getAccessValue(foundation.position());
|
||||
foundation.setMetadata(PlayerID, "access", foundationAccess);
|
||||
}
|
||||
navalManager.requireTransport(gameState, self.ent, access, foundationAccess, foundation.position());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user