1
0
forked from 0ad/0ad

Small garrison code clean-up

This was SVN commit r13505.
This commit is contained in:
leper 2013-06-26 19:24:56 +00:00
parent 6cbdc13e08
commit 623f5d9a9f

View File

@ -117,9 +117,6 @@ GarrisonHolder.prototype.AllowedToGarrison = function(entity)
*/
GarrisonHolder.prototype.Garrison = function(entity)
{
var entityPopCost = (Engine.QueryInterface(entity, IID_Cost)).GetPopCost();
var entityClasses = (Engine.QueryInterface(entity, IID_Identity)).GetClassesList();
if (!this.HasEnoughHealth())
return false;
@ -130,15 +127,16 @@ GarrisonHolder.prototype.Garrison = function(entity)
if (this.GetCapacity() < this.spaceOccupied + 1)
return false;
var cmpPosition = Engine.QueryInterface(entity, IID_Position);
if (!cmpPosition)
return false;
if (!this.timer && this.GetHealRate() > 0)
{
var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
this.timer = cmpTimer.SetTimeout(this.entity, IID_GarrisonHolder, "HealTimeout", 1000, {});
}
var cmpPosition = Engine.QueryInterface(entity, IID_Position);
if (cmpPosition)
{
// Actual garrisoning happens here
this.entities.push(entity);
this.spaceOccupied += 1;
@ -150,8 +148,6 @@ GarrisonHolder.prototype.Garrison = function(entity)
Engine.PostMessage(this.entity, MT_GarrisonedUnitsChanged, {});
return true;
}
return false;
};
/**