Add radar pings to BaseAttackNotifier and HarvesterAttackNotifier

This commit is contained in:
ScottNZ
2014-02-20 21:14:32 +13:00
parent 2a8efde8e6
commit 06caf7f156
2 changed files with 36 additions and 8 deletions

View File

@@ -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;
}