Adjusted other users of timed upgrades.

This commit is contained in:
Matija Hustić
2015-07-06 18:17:15 +01:00
parent 6f54fe7e5d
commit b2a26c57bc
5 changed files with 22 additions and 18 deletions

View File

@@ -47,7 +47,8 @@ namespace OpenRA.Mods.Common.Traits
bool AcceptsUpgrade(Actor a)
{
var um = a.TraitOrDefault<UpgradeManager>();
return um != null && info.Upgrades.Any(u => um.AcceptsUpgrade(a, u));
return um != null && (info.Duration > 0 ?
info.Upgrades.Any(u => um.AcknowledgesUpgrade(a, u)) : info.Upgrades.Any(u => um.AcceptsUpgrade(a, u)));
}
public override int GetSelectionShares(Actor collector)
@@ -73,13 +74,16 @@ namespace OpenRA.Mods.Common.Traits
var um = a.TraitOrDefault<UpgradeManager>();
foreach (var u in info.Upgrades)
{
if (!um.AcceptsUpgrade(a, u))
continue;
if (info.Duration > 0)
um.GrantTimedUpgrade(a, u, info.Duration);
{
if (um.AcknowledgesUpgrade(a, u))
um.GrantTimedUpgrade(a, u, info.Duration);
}
else
um.GrantUpgrade(a, u, this);
{
if (um.AcceptsUpgrade(a, u))
um.GrantUpgrade(a, u, this);
}
}
}
});