diff --git a/OpenRa.Game/Chrome.cs b/OpenRa.Game/Chrome.cs index be8c42280e..2966536c79 100644 --- a/OpenRa.Game/Chrome.cs +++ b/OpenRa.Game/Chrome.cs @@ -767,7 +767,7 @@ namespace OpenRa.Game var seconds = ticks / 25; var minutes = seconds / 60; - return "{0}:{1}".F(minutes, seconds % 60); + return "{0:D2}:{1:D2}".F(minutes, seconds % 60); } void DrawSupportPowerTooltip(string sp, int2 pos) diff --git a/OpenRa.Game/GameRules/SupportPowerInfo.cs b/OpenRa.Game/GameRules/SupportPowerInfo.cs index df60930d1f..0f6192c8cd 100644 --- a/OpenRa.Game/GameRules/SupportPowerInfo.cs +++ b/OpenRa.Game/GameRules/SupportPowerInfo.cs @@ -9,7 +9,7 @@ namespace OpenRa.Game.GameRules { public readonly bool Powered = true; public readonly bool OneShot = false; - public readonly int ChargeTime = 0; + public readonly float ChargeTime = 0; public readonly string Image; public readonly string Description = ""; public readonly string LongDesc = ""; diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index 9abbb92717..15182d690a 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -122,6 +122,7 @@ + diff --git a/OpenRa.Game/SupportPower.cs b/OpenRa.Game/SupportPower.cs index 1669fc0459..3f8bab86a6 100644 --- a/OpenRa.Game/SupportPower.cs +++ b/OpenRa.Game/SupportPower.cs @@ -8,6 +8,8 @@ using OpenRa.Game.SupportPowers; namespace OpenRa.Game { + // todo: fix this to route Activate through the orders system (otherwise desync in netplay) + class SupportPower { public readonly SupportPowerInfo Info; @@ -26,7 +28,7 @@ namespace OpenRa.Game { Info = info; Owner = owner; - RemainingTime = TotalTime = (int)info.ChargeTime * 60 * 25; + RemainingTime = TotalTime = (int)(info.ChargeTime * 60 * 25); Impl = ConstructPowerImpl(info.Impl); } diff --git a/OpenRa.Game/SupportPowers/GpsSatellite.cs b/OpenRa.Game/SupportPowers/GpsSatellite.cs new file mode 100644 index 0000000000..a40f959de1 --- /dev/null +++ b/OpenRa.Game/SupportPowers/GpsSatellite.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using OpenRa.Game.Effects; + +namespace OpenRa.Game.SupportPowers +{ + class GpsSatellite : ISupportPowerImpl + { + const int revealDelay = 30 * 25; + + public void Activate(SupportPower p) + { + var launchSite = Game.world.Actors + .FirstOrDefault( a => a.Owner == p.Owner && a.traits.Contains() ); + + if (launchSite == null) + return; + + Game.world.AddFrameEndTask(w => + { + w.Add(new SatelliteLaunch(launchSite)); + w.Add(new DelayedAction(revealDelay, () => p.Owner.Shroud.HasGPS = true)); + }); + + p.FinishActivate(); + } + } +} diff --git a/OpenRa.Game/Traits/GpsSatellite.cs b/OpenRa.Game/Traits/GpsSatellite.cs index f735f941be..3e6f70fd5e 100644 --- a/OpenRa.Game/Traits/GpsSatellite.cs +++ b/OpenRa.Game/Traits/GpsSatellite.cs @@ -2,28 +2,5 @@ namespace OpenRa.Game.Traits { - class GpsSatellite : ITick - { - int frame = 0; - int revealTicks = 30 * 25; // 30 second delay between launch and reveal - bool fired = false; - - public GpsSatellite(Actor self) {} - public void Tick(Actor self) - { - // HACK: Launch after 5 seconds - if (++frame == 150) - Activate(self); - - if (fired && --revealTicks == 0) - { - self.Owner.Shroud.HasGPS = true; - } - } - public void Activate(Actor self) - { - Game.world.AddFrameEndTask(w => w.Add(new SatelliteLaunch(self))); - fired = true; - } - } + class GpsSatellite { public GpsSatellite(Actor self) { } } } diff --git a/units.ini b/units.ini index e6f3f32f3f..abbdf16043 100644 --- a/units.ini +++ b/units.ini @@ -889,7 +889,7 @@ OneShot=yes Prerequisite=ATEK Image=gpssicon TechLevel=12 -Impl=NullPower +Impl=GpsSatellite AutoActivate=yes [InvulnerabilityPower] ; the point of IRON