Add support for transient text notifications matching speech notifications

This commit is contained in:
Ivaylo Draganov
2022-01-08 18:28:25 +02:00
committed by Paul Chote
parent 9f723be65a
commit 24b9482cc1
50 changed files with 372 additions and 46 deletions

View File

@@ -16,8 +16,12 @@ namespace OpenRA.Mods.Common.Traits.Sound
class ActorLostNotificationInfo : ConditionalTraitInfo
{
[NotificationReference("Speech")]
[Desc("Speech notification to play.")]
public readonly string Notification = "UnitLost";
[Desc("Text notification to display.")]
public readonly string TextNotification = null;
public readonly bool NotifyAll = false;
public override object Create(ActorInitializer init) { return new ActorLostNotification(this); }
@@ -33,8 +37,15 @@ namespace OpenRA.Mods.Common.Traits.Sound
if (IsTraitDisabled)
return;
var player = Info.NotifyAll ? self.World.LocalPlayer : self.Owner;
var localPlayer = self.World.LocalPlayer;
if (localPlayer == null || localPlayer.Spectating)
return;
var player = Info.NotifyAll ? localPlayer : self.Owner;
Game.Sound.PlayNotification(self.World.Map.Rules, player, "Speech", Info.Notification, self.Owner.Faction.InternalName);
TextNotificationsManager.AddTransientLine(Info.TextNotification, player);
}
}
}