diff --git a/OpenRa.Game/Chrome.cs b/OpenRa.Game/Chrome.cs index e350f282f6..1568c505c1 100644 --- a/OpenRa.Game/Chrome.cs +++ b/OpenRa.Game/Chrome.cs @@ -414,7 +414,7 @@ namespace OpenRa.Game shpRenderer.Flush(); } } - + void DrawChat() { var chatpos = new int2(400, Game.viewport.Height - 20); diff --git a/OpenRa.Game/GameRules/SupportPowerInfo.cs b/OpenRa.Game/GameRules/SupportPowerInfo.cs index a86f7fda87..e2eee76b7b 100644 --- a/OpenRa.Game/GameRules/SupportPowerInfo.cs +++ b/OpenRa.Game/GameRules/SupportPowerInfo.cs @@ -13,6 +13,5 @@ namespace OpenRa.Game.GameRules public readonly int TechLevel = -1; public readonly bool GivenAuto = true; public readonly string Impl = null; - public readonly bool AutoActivate = false; } } diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index a14b7ec48e..82e8e60e09 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -124,7 +124,7 @@ - + @@ -318,4 +318,4 @@ --> - \ No newline at end of file + diff --git a/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs b/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs index d73c787f19..286fef488b 100644 --- a/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs +++ b/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs @@ -4,11 +4,17 @@ using System.Linq; using System.Text; using OpenRa.Game.GameRules; using OpenRa.Game.Traits; - +using OpenRa.Game.SupportPowers; namespace OpenRa.Game.Orders { class IronCurtainOrderGenerator : IOrderGenerator { + ISupportPowerImpl power; + public IronCurtainOrderGenerator(ISupportPowerImpl power) + { + this.power = power; + } + public IEnumerable Order(int2 xy, MouseInput mi) { if (mi.Button == MouseButton.Right) @@ -31,7 +37,8 @@ namespace OpenRa.Game.Orders if (unit != null) { - yield return new Order("IronCurtain", underCursor, null, int2.Zero, null); + yield return new Order("IronCurtain", underCursor, this.power); + //yield return new Order("IronCurtain", underCursor, null, int2.Zero, null); } } } diff --git a/OpenRa.Game/Orders/Order.cs b/OpenRa.Game/Orders/Order.cs index c2d25713bc..6caa67148d 100644 --- a/OpenRa.Game/Orders/Order.cs +++ b/OpenRa.Game/Orders/Order.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Linq; +using OpenRa.Game.SupportPowers; namespace OpenRa.Game { @@ -31,6 +32,19 @@ namespace OpenRa.Game this.TargetLocation = targetLocation; this.TargetString = targetString; } + // This is a hack - fix me + public readonly ISupportPowerImpl Power; + public Order(string orderString, Actor subject, ISupportPowerImpl power) + { + this.OrderString = orderString; + this.SubjectId = UIntFromActor( subject ); + + this.Power = power; + + this.TargetActorId = UIntFromActor(null); + this.TargetLocation = int2.Zero; + this.TargetString = null; + } public bool Validate() { diff --git a/OpenRa.Game/SupportPower.cs b/OpenRa.Game/SupportPower.cs index 02e170b8a4..6740323686 100644 --- a/OpenRa.Game/SupportPower.cs +++ b/OpenRa.Game/SupportPower.cs @@ -34,7 +34,9 @@ namespace OpenRa.Game public bool IsDone { get { return RemainingTime == 0; } } public int RemainingTime { get; private set; } public int TotalTime { get; private set; } - + bool notifiedReady = false; + bool notifiedCharging = false; + public void Tick() { if (Info.OneShot && IsUsed) @@ -56,10 +58,20 @@ namespace OpenRa.Game if (IsAvailable && (!Info.Powered || Owner.GetPowerState() == PowerState.Normal)) { if (RemainingTime > 0) --RemainingTime; + if (!notifiedCharging) + { + Impl.IsChargingNotification(this); + notifiedCharging = true; + } } - if (RemainingTime == 0 && Info.AutoActivate) - Activate(); + if (RemainingTime == 0 + && Impl != null + && !notifiedReady) + { + Impl.IsReadyNotification(this); + notifiedReady = true; + } } public void Activate() @@ -76,6 +88,8 @@ namespace OpenRa.Game IsAvailable = false; } RemainingTime = TotalTime; + notifiedReady = false; + notifiedCharging = false; } public void Give(bool requireCharge) // called by crate/spy/etc code diff --git a/OpenRa.Game/SupportPowers/Chronoshift.cs b/OpenRa.Game/SupportPowers/Chronoshift.cs index 8f721d0a83..ca0968bbeb 100644 --- a/OpenRa.Game/SupportPowers/Chronoshift.cs +++ b/OpenRa.Game/SupportPowers/Chronoshift.cs @@ -11,5 +11,9 @@ namespace OpenRa.Game.SupportPowers if (Game.controller.ToggleInputMode()) Sound.Play("slcttgt1.aud"); } + + public void OnFireNotification(Actor target, int2 xy) {} + public void IsChargingNotification(SupportPower p) {} + public void IsReadyNotification(SupportPower p) {} } } diff --git a/OpenRa.Game/SupportPowers/GpsSatellite.cs b/OpenRa.Game/SupportPowers/GpsSatellite.cs index be748106fa..671fb5d410 100644 --- a/OpenRa.Game/SupportPowers/GpsSatellite.cs +++ b/OpenRa.Game/SupportPowers/GpsSatellite.cs @@ -6,8 +6,16 @@ namespace OpenRa.Game.SupportPowers { class GpsSatellite : ISupportPowerImpl { - const int revealDelay = 30 * 25; + const int revealDelay = 15 * 25; + public void OnFireNotification(Actor a, int2 xy) { } + public void IsChargingNotification(SupportPower p) { } + public void IsReadyNotification(SupportPower p) + { + // Power is auto-activated + Activate(p); + } + public void Activate(SupportPower p) { var launchSite = Game.world.Actors diff --git a/OpenRa.Game/SupportPowers/ISupportPowerImpl.cs b/OpenRa.Game/SupportPowers/ISupportPowerImpl.cs index b8831e63c2..b1ef896690 100644 --- a/OpenRa.Game/SupportPowers/ISupportPowerImpl.cs +++ b/OpenRa.Game/SupportPowers/ISupportPowerImpl.cs @@ -8,5 +8,8 @@ namespace OpenRa.Game.SupportPowers interface ISupportPowerImpl { void Activate(SupportPower p); + void OnFireNotification(Actor target, int2 xy); + void IsChargingNotification(SupportPower p); + void IsReadyNotification(SupportPower p); } } diff --git a/OpenRa.Game/SupportPowers/IronCurtainPower.cs b/OpenRa.Game/SupportPowers/IronCurtainPower.cs new file mode 100644 index 0000000000..67bb0b5c6d --- /dev/null +++ b/OpenRa.Game/SupportPowers/IronCurtainPower.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using OpenRa.Game.Orders; +using OpenRa.Game.Traits; + +namespace OpenRa.Game.SupportPowers +{ + class IronCurtainPower : ISupportPowerImpl + { + public void IsReadyNotification(SupportPower p) + { + Sound.Play("ironrdy1.aud"); + } + + public void IsChargingNotification(SupportPower p) + { + Sound.Play("ironchg1.aud"); + } + + public void OnFireNotification(Actor target, int2 xy) + { + p.FinishActivate(); + Game.controller.CancelInputMode(); + Sound.Play("ironcur9.aud"); + + // Play active anim + var ironCurtain = Game.world.Actors + .Where(a => a.Owner == p.Owner && a.traits.Contains()) + .FirstOrDefault(); + if (ironCurtain != null) + ironCurtain.traits.Get().PlayCustomAnim(ironCurtain, "active"); + } + SupportPower p; + public void Activate(SupportPower p) + { + this.p = p; + // Pick a building to use + Game.controller.orderGenerator = new IronCurtainOrderGenerator(this); + Sound.Play("slcttgt1.aud"); + } + } +} diff --git a/OpenRa.Game/SupportPowers/NullPower.cs b/OpenRa.Game/SupportPowers/NullPower.cs index dadb23b5bd..57f76dc60d 100644 --- a/OpenRa.Game/SupportPowers/NullPower.cs +++ b/OpenRa.Game/SupportPowers/NullPower.cs @@ -7,6 +7,9 @@ namespace OpenRa.Game.SupportPowers { class NullPower : ISupportPowerImpl { + public void OnFireNotification(Actor a, int2 xy) { } + public void IsReadyNotification(SupportPower p) { } + public void IsChargingNotification(SupportPower p) { } public void Activate(SupportPower p) { // if this was a real power, i'd do something here! diff --git a/OpenRa.Game/Traits/IronCurtainable.cs b/OpenRa.Game/Traits/IronCurtainable.cs index 84374c0a57..e49ace50a3 100644 --- a/OpenRa.Game/Traits/IronCurtainable.cs +++ b/OpenRa.Game/Traits/IronCurtainable.cs @@ -28,16 +28,9 @@ namespace OpenRa.Game.Traits { if (order.OrderString == "IronCurtain") { - Game.controller.CancelInputMode(); + order.Power.OnFireNotification(self, self.Location); Game.world.AddFrameEndTask(w => w.Add(new InvulnEffect(self))); RemainingTicks = (int)(Rules.General.IronCurtain * 60 * 25); - Sound.Play("ironcur9.aud"); - // Play active anim - var ironCurtain = Game.world.Actors - .Where(a => a.Owner == order.Subject.Owner && a.traits.Contains()) - .FirstOrDefault(); - if (ironCurtain != null) - ironCurtain.traits.Get().PlayCustomAnim(ironCurtain, "active"); } } } diff --git a/units.ini b/units.ini index 20fe4ea8fd..7264c4d7eb 100644 --- a/units.ini +++ b/units.ini @@ -890,7 +890,6 @@ Prerequisite=ATEK Image=gpssicon TechLevel=12 Impl=GpsSatellite -AutoActivate=yes [InvulnerabilityPower] ; the point of IRON ChargeTime=11 @@ -899,4 +898,4 @@ LongDesc=Makes a single unit invulnerable for a \nshort time. Image=infxicon Prerequisite=IRON TechLevel=12 -Impl=IronCurtain \ No newline at end of file +Impl=IronCurtainPower