notifications (formerly EVAalerts) centralized and race specific

outsourced into notifications.yaml
triggered with PlayNotification(...)

(v2: less redundant code for PlayVoice/Notifications)

added harvester under attack and battlecontrol terminated
This commit is contained in:
Matthias Mailänder
2012-06-28 19:52:25 +02:00
committed by Chris Forbes
parent 5fee165692
commit 7a578a0679
40 changed files with 271 additions and 219 deletions

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2012 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
@@ -17,9 +17,7 @@ namespace OpenRA.Mods.RA
{
public class BaseAttackNotifierInfo : ITraitInfo
{
public readonly int NotifyInterval = 30; /* seconds */
public readonly string Audio = "baseatk1.aud";
public readonly string Race = null;
public readonly int NotifyInterval = 30; // seconds
public object Create(ActorInitializer init) { return new BaseAttackNotifier(this); }
}
@@ -35,17 +33,16 @@ namespace OpenRA.Mods.RA
public void Damaged(Actor self, AttackInfo e)
{
if (info.Race != null && info.Race != self.Owner.Country.Race) return;
/* only track last hit against our base */
// only track last hit against our base
if (!self.HasTrait<Building>())
return;
/* don't track self-damage */
// don't track self-damage
if (e.Attacker != null && e.Attacker.Owner == self.Owner)
return;
if (self.World.FrameNumber - lastAttackTime > info.NotifyInterval * 25)
Sound.PlayToPlayer(self.Owner, info.Audio);
Sound.PlayNotification(self.Owner, "Speech", "BaseAttack", self.Owner.Country.Race);
lastAttackLocation = self.CenterLocation.ToCPos();
lastAttackTime = self.World.FrameNumber;