diff --git a/OpenRA.Mods.RA/Player/BaseAttackNotifier.cs b/OpenRA.Mods.RA/Player/BaseAttackNotifier.cs index a186604049..1a67f6ae84 100644 --- a/OpenRA.Mods.RA/Player/BaseAttackNotifier.cs +++ b/OpenRA.Mods.RA/Player/BaseAttackNotifier.cs @@ -8,6 +8,7 @@ */ #endregion +using System.Drawing; using OpenRA.Mods.RA.Buildings; using OpenRA.Traits; @@ -16,18 +17,26 @@ namespace OpenRA.Mods.RA public class BaseAttackNotifierInfo : ITraitInfo { public readonly int NotifyInterval = 30; // seconds + public readonly Color RadarPingColor = Color.Red; + public readonly int RadarPingDuration = 10 * 25; - public object Create(ActorInitializer init) { return new BaseAttackNotifier(this); } + public object Create(ActorInitializer init) { return new BaseAttackNotifier(init.self, this); } } public class BaseAttackNotifier : INotifyDamage { - BaseAttackNotifierInfo info; + readonly RadarPings radarPings; + readonly BaseAttackNotifierInfo info; - public int lastAttackTime = -1; + public int lastAttackTime; public CPos lastAttackLocation; - public BaseAttackNotifier(BaseAttackNotifierInfo info) { this.info = info; } + public BaseAttackNotifier(Actor self, BaseAttackNotifierInfo info) + { + radarPings = self.World.WorldActor.TraitOrDefault(); + this.info = info; + lastAttackTime = -info.NotifyInterval * 25; + } public void Damaged(Actor self, AttackInfo e) { @@ -45,8 +54,13 @@ namespace OpenRA.Mods.RA return; if (self.World.FrameNumber - lastAttackTime > info.NotifyInterval * 25) + { Sound.PlayNotification(self.Owner, "Speech", "BaseAttack", self.Owner.Country.Race); + if (radarPings != null) + 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 4f790f9df0..86ddce48a3 100644 --- a/OpenRA.Mods.RA/Player/HarvesterAttackNotifier.cs +++ b/OpenRA.Mods.RA/Player/HarvesterAttackNotifier.cs @@ -8,6 +8,7 @@ */ #endregion +using System.Drawing; using OpenRA.Traits; namespace OpenRA.Mods.RA @@ -15,18 +16,26 @@ namespace OpenRA.Mods.RA public class HarvesterAttackNotifierInfo : ITraitInfo { public readonly int NotifyInterval = 30; // seconds + public readonly Color RadarPingColor = Color.Red; + public readonly int RadarPingDuration = 10 * 25; - public object Create(ActorInitializer init) { return new HarvesterAttackNotifier(this); } + public object Create(ActorInitializer init) { return new HarvesterAttackNotifier(init.self, this); } } public class HarvesterAttackNotifier : INotifyDamage { - HarvesterAttackNotifierInfo info; + readonly RadarPings radarPings; + readonly HarvesterAttackNotifierInfo info; - public int lastAttackTime = -1; + public int lastAttackTime; public CPos lastAttackLocation; - public HarvesterAttackNotifier(HarvesterAttackNotifierInfo info) { this.info = info; } + public HarvesterAttackNotifier(Actor self, HarvesterAttackNotifierInfo info) + { + radarPings = self.World.WorldActor.TraitOrDefault(); + this.info = info; + lastAttackTime = -info.NotifyInterval * 25; + } public void Damaged(Actor self, AttackInfo e) { @@ -39,8 +48,13 @@ namespace OpenRA.Mods.RA return; if (self.World.FrameNumber - lastAttackTime > info.NotifyInterval * 25) + { Sound.PlayNotification(self.Owner, "Speech", "HarvesterAttack", self.Owner.Country.Race); + if (radarPings != null) + radarPings.Add(() => self.Owner == self.World.LocalPlayer, self.CenterPosition, info.RadarPingColor, info.RadarPingDuration); + } + lastAttackLocation = self.CenterPosition.ToCPos(); lastAttackTime = self.World.FrameNumber; }