diff --git a/OpenRA.Mods.RA/SupportPowers/GpsPower.cs b/OpenRA.Mods.RA/SupportPowers/GpsPower.cs index cb93913b59..678116a844 100755 --- a/OpenRA.Mods.RA/SupportPowers/GpsPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/GpsPower.cs @@ -12,7 +12,7 @@ using System.Linq; using OpenRA.Effects; using OpenRA.Mods.RA.Effects; using OpenRA.Traits; -/* + namespace OpenRA.Mods.RA { class GpsPowerInfo : SupportPowerInfo @@ -26,29 +26,21 @@ namespace OpenRA.Mods.RA { public GpsPower(Actor self, GpsPowerInfo info) : base(self, info) { } - protected override void OnFinishCharging() + public override void Charged(Actor self, string key) { - var launchSite = Owner.World.Queries.OwnedBy[Owner] - .FirstOrDefault(a => a.HasTrait()); - - if (launchSite == null) - return; - - Owner.World.AddFrameEndTask(w => + self.Owner.PlayerActor.Trait().Powers[key].Activate(new Order()); + } + + public override void Activate(Actor self, Order order) + { + self.World.AddFrameEndTask(w => { - Sound.PlayToPlayer(Owner, Info.LaunchSound); + Sound.PlayToPlayer(self.Owner, Info.LaunchSound); - w.Add(new SatelliteLaunch(launchSite)); + w.Add(new SatelliteLaunch(self)); w.Add(new DelayedAction((Info as GpsPowerInfo).RevealDelay * 25, - () => Owner.Shroud.Disabled = true)); + () => self.Owner.Shroud.Disabled = true)); }); - - FinishActivate(); } } - - // tag trait to identify the building - class GpsLaunchSiteInfo : TraitInfo { } - class GpsLaunchSite { } } -*/ \ No newline at end of file diff --git a/OpenRA.Mods.RA/SupportPowers/SupportPower.cs b/OpenRA.Mods.RA/SupportPowers/SupportPower.cs index a7115be329..1f6e796f9b 100755 --- a/OpenRA.Mods.RA/SupportPowers/SupportPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/SupportPower.cs @@ -20,13 +20,15 @@ namespace OpenRA.Mods.RA public readonly string Image = null; public readonly string Description = ""; public readonly string LongDesc = ""; - - public readonly string OrderName; + public readonly bool AllowMultiple = false; + public readonly bool OneShot = false; + public readonly string BeginChargeSound = null; public readonly string EndChargeSound = null; public readonly string SelectTargetSound = null; public readonly string LaunchSound = null; - public readonly bool AllowMultiple = false; + + public readonly string OrderName; public abstract object Create(ActorInitializer init); public SupportPowerInfo() { OrderName = GetType().Name + "Order"; } @@ -42,6 +44,16 @@ namespace OpenRA.Mods.RA Info = info; this.self = self; } + + public virtual void Charging(Actor self, string key) + { + Sound.PlayToPlayer(self.Owner, Info.BeginChargeSound); + } + + public virtual void Charged(Actor self, string key) + { + Sound.PlayToPlayer(self.Owner, Info.EndChargeSound); + } public virtual void Activate(Actor self, Order order) { } public virtual IOrderGenerator OrderGenerator(string order, SupportPowerManager manager) diff --git a/OpenRA.Mods.RA/SupportPowers/SupportPowerManager.cs b/OpenRA.Mods.RA/SupportPowers/SupportPowerManager.cs index a91e19b847..36a3286f22 100755 --- a/OpenRA.Mods.RA/SupportPowers/SupportPowerManager.cs +++ b/OpenRA.Mods.RA/SupportPowers/SupportPowerManager.cs @@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA } else { - var si = new SupportPowerInstance(this) + var si = new SupportPowerInstance(key, this) { Instances = new List() { t }, RemainingTime = t.Info.ChargeTime * 25, @@ -91,38 +91,42 @@ namespace OpenRA.Mods.RA public void Target(string key) { if (Powers.ContainsKey(key)) - Powers[key].Target(key); + Powers[key].Target(); } public class SupportPowerInstance { SupportPowerManager Manager; + string Key; + public List Instances; public int RemainingTime; public int TotalTime; public bool Active; + public bool Disabled; public SupportPowerInfo Info { get { return Instances.First().Info; } } public bool Ready { get { return Active && RemainingTime == 0; } } - public SupportPowerInstance(SupportPowerManager manager) + public SupportPowerInstance(string key, SupportPowerManager manager) { Manager = manager; + Key = key; } bool notifiedCharging; bool notifiedReady; public void Tick() { - Active = Instances.Any(i => !i.self.TraitsImplementing().Any(d => d.Disabled)); - + Active = !Disabled && Instances.Any(i => !i.self.TraitsImplementing().Any(d => d.Disabled)); + var power = Instances.First(); + if (Active) { if (RemainingTime > 0) --RemainingTime; if (!notifiedCharging) { - Sound.PlayToPlayer(Instances.First().self.Owner, Info.BeginChargeSound); - //instance.OnBeginCharging(); + power.Charging(power.self, Key); notifiedCharging = true; } } @@ -130,18 +134,17 @@ namespace OpenRA.Mods.RA if (RemainingTime == 0 && !notifiedReady) { - Sound.PlayToPlayer(Instances.First().self.Owner, Info.EndChargeSound); - //instance.FinishCharging(); + power.Charged(power.self, Key); notifiedReady = true; } } - public void Target(string key) + public void Target() { if (!Ready) return; - Manager.self.World.OrderGenerator = Instances.First().OrderGenerator(key, Manager); + Manager.self.World.OrderGenerator = Instances.First().OrderGenerator(Key, Manager); } public void Activate(Order order) @@ -154,6 +157,9 @@ namespace OpenRA.Mods.RA power.Activate(power.self, order); RemainingTime = TotalTime; notifiedCharging = notifiedReady = false; + + if (Info.OneShot) + Disabled = true; } } } diff --git a/OpenRA.Mods.RA/Widgets/SpecialPowerBinWidget.cs b/OpenRA.Mods.RA/Widgets/SpecialPowerBinWidget.cs index 7305c44d3c..ed9c428ad6 100755 --- a/OpenRA.Mods.RA/Widgets/SpecialPowerBinWidget.cs +++ b/OpenRA.Mods.RA/Widgets/SpecialPowerBinWidget.cs @@ -75,7 +75,8 @@ namespace OpenRA.Mods.RA.Widgets if( world.LocalPlayer == null ) return; var manager = world.LocalPlayer.PlayerActor.Trait(); - var numPowers = manager.Powers.Count; + var powers = manager.Powers.Where(p => !p.Value.Disabled); + var numPowers = powers.Count(); if (numPowers == 0) return; var rectBounds = RenderBounds; @@ -89,7 +90,7 @@ namespace OpenRA.Mods.RA.Widgets rectBounds.Height = 10 + numPowers * 51 + 21; var y = rectBounds.Y + 10; - foreach (var kv in manager.Powers) + foreach (var kv in powers) { var sp = kv.Value; var image = spsprites[sp.Info.Image]; diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index bd642d13f2..8b518ace88 100755 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -519,7 +519,15 @@ ATEK: Range: 10 Bib: IronCurtainable: -# GpsLaunchSite: + GpsPower: + Image: gpssicon + OneShot: yes +# ChargeTime: 480 + ChargeTime: 10 + Description: GPS Satellite + LongDesc: Reveals the entire map + RevealDelay: 15 + LaunchSound: satlnch1.aud WEAP: Inherits: ^Building diff --git a/mods/ra/rules/system.yaml b/mods/ra/rules/system.yaml index 20df6f596c..5ca42f90aa 100644 --- a/mods/ra/rules/system.yaml +++ b/mods/ra/rules/system.yaml @@ -25,15 +25,6 @@ Player: BuildSpeed: .4 LowPowerSlowdown: 3 PlaceBuilding: -# GpsPower: -# Image: gpssicon -# OneShot: yes -# ChargeTime: 8 -# Description: GPS Satellite -# LongDesc: Reveals the entire map -# Prerequisites: ATEK -# RevealDelay: 15 -# LaunchSound: satlnch1.aud # IronCurtainPower: # Image: infxicon # ChargeTime: 2