Merge pull request #11018 from Mailaender/gps-disable

Fixed GPS power not taking tech center disablement into account
This commit is contained in:
reaperrr
2016-05-14 16:31:34 +02:00
2 changed files with 24 additions and 2 deletions

View File

@@ -41,17 +41,22 @@ namespace OpenRA.Mods.RA.Traits
[Desc("Custom palette is a player palette BaseName")] [Desc("Custom palette is a player palette BaseName")]
public readonly bool SatellitePaletteIsPlayerPalette = true; public readonly bool SatellitePaletteIsPlayerPalette = true;
[Desc("Requires an actor with an online `ProvidesRadar` to show GPS dots.")]
public readonly bool RequiresActiveRadar = true;
public override object Create(ActorInitializer init) { return new GpsPower(init.Self, this); } public override object Create(ActorInitializer init) { return new GpsPower(init.Self, this); }
} }
class GpsPower : SupportPower, INotifyKilled, INotifySold, INotifyOwnerChanged class GpsPower : SupportPower, INotifyKilled, INotifySold, INotifyOwnerChanged, ITick
{ {
readonly Actor self;
readonly GpsPowerInfo info; readonly GpsPowerInfo info;
GpsWatcher owner; GpsWatcher owner;
public GpsPower(Actor self, GpsPowerInfo info) public GpsPower(Actor self, GpsPowerInfo info)
: base(self, info) : base(self, info)
{ {
this.self = self;
this.info = info; this.info = info;
owner = self.Owner.PlayerActor.Trait<GpsWatcher>(); owner = self.Owner.PlayerActor.Trait<GpsWatcher>();
owner.GpsAdd(self); owner.GpsAdd(self);
@@ -93,5 +98,22 @@ namespace OpenRA.Mods.RA.Traits
owner = newOwner.PlayerActor.Trait<GpsWatcher>(); owner = newOwner.PlayerActor.Trait<GpsWatcher>();
owner.GpsAdd(self); owner.GpsAdd(self);
} }
bool NoActiveRadar { get { return !self.World.ActorsHavingTrait<ProvidesRadar>(r => r.IsActive).Any(a => a.Owner == self.Owner); } }
bool wasDisabled;
public void Tick(Actor self)
{
if (!wasDisabled && (self.IsDisabled() || (info.RequiresActiveRadar && NoActiveRadar)))
{
wasDisabled = true;
RemoveGps(self);
}
else if (wasDisabled && !self.IsDisabled() && !(info.RequiresActiveRadar && NoActiveRadar))
{
wasDisabled = false;
owner.GpsAdd(self);
}
}
} }
} }

View File

@@ -776,7 +776,7 @@ ATEK:
OneShot: yes OneShot: yes
ChargeTime: 480 ChargeTime: 480
Description: GPS Satellite Description: GPS Satellite
LongDesc: Reveals map terrain and provides tactical\ninformation. LongDesc: Reveals map terrain and provides tactical\ninformation. Requires power and active radar.
RevealDelay: 15 RevealDelay: 15
LaunchSound: satlnch1.aud LaunchSound: satlnch1.aud
DisplayTimer: True DisplayTimer: True