diff --git a/OpenRA.Mods.RA/Player/BaseAttackNotifier.cs b/OpenRA.Mods.RA/Player/BaseAttackNotifier.cs index 1a67f6ae84..a905455cb7 100644 --- a/OpenRA.Mods.RA/Player/BaseAttackNotifier.cs +++ b/OpenRA.Mods.RA/Player/BaseAttackNotifier.cs @@ -28,8 +28,7 @@ namespace OpenRA.Mods.RA readonly RadarPings radarPings; readonly BaseAttackNotifierInfo info; - public int lastAttackTime; - public CPos lastAttackLocation; + int lastAttackTime; public BaseAttackNotifier(Actor self, BaseAttackNotifierInfo info) { @@ -61,7 +60,6 @@ namespace OpenRA.Mods.RA radarPings.Add(() => self.Owner == self.World.LocalPlayer, self.CenterPosition, info.RadarPingColor, info.RadarPingDuration); } - lastAttackLocation = self.CenterPosition.ToCPos(); lastAttackTime = self.World.FrameNumber; } } diff --git a/OpenRA.Mods.RA/Player/HarvesterAttackNotifier.cs b/OpenRA.Mods.RA/Player/HarvesterAttackNotifier.cs index 86ddce48a3..29e773592a 100644 --- a/OpenRA.Mods.RA/Player/HarvesterAttackNotifier.cs +++ b/OpenRA.Mods.RA/Player/HarvesterAttackNotifier.cs @@ -27,8 +27,7 @@ namespace OpenRA.Mods.RA readonly RadarPings radarPings; readonly HarvesterAttackNotifierInfo info; - public int lastAttackTime; - public CPos lastAttackLocation; + int lastAttackTime; public HarvesterAttackNotifier(Actor self, HarvesterAttackNotifierInfo info) { @@ -55,7 +54,6 @@ namespace OpenRA.Mods.RA radarPings.Add(() => self.Owner == self.World.LocalPlayer, self.CenterPosition, info.RadarPingColor, info.RadarPingDuration); } - lastAttackLocation = self.CenterPosition.ToCPos(); lastAttackTime = self.World.FrameNumber; } } diff --git a/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs b/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs index bdc4837c39..fbd056e4ee 100644 --- a/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs +++ b/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs @@ -22,12 +22,14 @@ namespace OpenRA.Mods.RA.Widgets { readonly World world; readonly WorldRenderer worldRenderer; + readonly RadarPings radarPings; [ObjectCreator.UseCtor] public WorldCommandWidget(World world, WorldRenderer worldRenderer) { this.world = world; this.worldRenderer = worldRenderer; + radarPings = world.WorldActor.TraitOrDefault(); } public override string GetCursor(int2 pos) { return null; } @@ -241,17 +243,10 @@ namespace OpenRA.Mods.RA.Widgets bool ToLastEvent() { - if (world.LocalPlayer == null) + if (radarPings == null || radarPings.LastPingPosition == null) return true; - var eventNotifier = world.LocalPlayer.PlayerActor.TraitOrDefault(); - if (eventNotifier == null) - return true; - - if (eventNotifier.lastAttackTime < 0) - return true; - - worldRenderer.Viewport.Center(eventNotifier.lastAttackLocation.CenterPosition); + worldRenderer.Viewport.Center(radarPings.LastPingPosition.Value); return true; } diff --git a/OpenRA.Mods.RA/World/RadarPings.cs b/OpenRA.Mods.RA/World/RadarPings.cs index a9677f5f18..1a0cd22dc2 100644 --- a/OpenRA.Mods.RA/World/RadarPings.cs +++ b/OpenRA.Mods.RA/World/RadarPings.cs @@ -30,6 +30,8 @@ namespace OpenRA.Mods.RA public readonly List Pings = new List(); readonly RadarPingsInfo info; + public WPos? LastPingPosition; + public RadarPings(RadarPingsInfo info) { this.info = info; @@ -46,7 +48,12 @@ namespace OpenRA.Mods.RA { var ping = new RadarPing(isVisible, position, color, duration, info.FromRadius, info.ToRadius, info.ShrinkSpeed, info.RotationSpeed); + + if (ping.IsVisible()) + LastPingPosition = ping.Position; + Pings.Add(ping); + return ping; }