disabled buildings no longer count as prereqs for using fully-charged powers

This commit is contained in:
Chris Forbes
2010-01-27 18:02:50 +13:00
parent d2c76ed32a
commit d9a1b4c807

View File

@@ -57,11 +57,7 @@ namespace OpenRa.Traits
&& effectivePrereq.All(a => buildings[a].Count > 0); && effectivePrereq.All(a => buildings[a].Count > 0);
} }
// Do we have enough powered prerequisites? if (IsAvailable && (!Info.RequiresPower || IsPowered()))
// Hack in support for special powers without prereqs
var isPowered = (Info.Prerequisites.Count() == 0) ? self.Owner.GetPowerState() == PowerState.Normal : effectivePrereq.Any() && effectivePrereq.All(a => buildings[a].Any(b => !b.traits.Get<Building>().Disabled));
if (IsAvailable && (!Info.RequiresPower || isPowered))
{ {
if (RemainingTime > 0) --RemainingTime; if (RemainingTime > 0) --RemainingTime;
if (!notifiedCharging) if (!notifiedCharging)
@@ -79,6 +75,20 @@ namespace OpenRa.Traits
} }
} }
bool IsPowered()
{
var buildings = Rules.TechTree.GatherBuildings(Owner);
var effectivePrereq = Info.Prerequisites
.Select(a => a.ToLowerInvariant())
.Where(a => Rules.Info[a].Traits.Get<BuildableInfo>().Owner.Contains(Owner.Race));
if (Info.Prerequisites.Count() == 0)
return Owner.GetPowerState() == PowerState.Normal;
return effectivePrereq.Any() &&
effectivePrereq.All(a => buildings[a].Any(b => !b.traits.Get<Building>().Disabled));
}
public void FinishActivate() public void FinishActivate()
{ {
if (Info.OneShot) if (Info.OneShot)
@@ -110,7 +120,7 @@ namespace OpenRa.Traits
return; return;
} }
if (Info.RequiresPower && Owner.GetPowerState() != PowerState.Normal) if (Info.RequiresPower && !IsPowered())
{ {
Sound.Play("nopowr1.aud"); Sound.Play("nopowr1.aud");
return; return;