shareable, revokable gps
This commit is contained in:
@@ -22,9 +22,10 @@ namespace OpenRA.Mods.RA
|
||||
public override object Create(ActorInitializer init) { return new GpsPower(init.self, this); }
|
||||
}
|
||||
|
||||
class GpsPower : SupportPower
|
||||
class GpsPower : SupportPower, INotifyDamage
|
||||
{
|
||||
public GpsPower(Actor self, GpsPowerInfo info) : base(self, info) { }
|
||||
public bool Granted;
|
||||
|
||||
public override void Charged(Actor self, string key)
|
||||
{
|
||||
@@ -40,9 +41,26 @@ namespace OpenRA.Mods.RA
|
||||
w.Add(new SatelliteLaunch(self));
|
||||
|
||||
/* there is only one shroud, but it is misleadingly available through Player.Shroud */
|
||||
w.Add(new DelayedAction((Info as GpsPowerInfo).RevealDelay * 25,
|
||||
() => { if (self.Owner == self.World.LocalPlayer) self.World.LocalShroud.Disabled = true; }));
|
||||
w.Add(new DelayedAction((Info as GpsPowerInfo).RevealDelay * 25,
|
||||
() => { Granted = true; RefreshGps(self); }));
|
||||
});
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageState == DamageState.Dead)
|
||||
{
|
||||
Granted = false;
|
||||
RefreshGps(self);
|
||||
}
|
||||
}
|
||||
|
||||
void RefreshGps(Actor self)
|
||||
{
|
||||
if (self.Owner == self.World.LocalPlayer)
|
||||
self.World.LocalShroud.Disabled = self.World.Queries.WithTrait<GpsPower>()
|
||||
.Any(p => p.Actor.Owner.Stances[self.Owner] == Stance.Ally &&
|
||||
p.Trait.Granted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user