Add radar pings to BaseAttackNotifier and HarvesterAttackNotifier
This commit is contained in:
@@ -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<RadarPings>();
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user