diff --git a/OpenRA.Mods.Common/Traits/Sound/ActorLostNotification.cs b/OpenRA.Mods.Common/Traits/Sound/ActorLostNotification.cs index c238153c25..f52ea1ea10 100644 --- a/OpenRA.Mods.Common/Traits/Sound/ActorLostNotification.cs +++ b/OpenRA.Mods.Common/Traits/Sound/ActorLostNotification.cs @@ -13,7 +13,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits.Sound { - class ActorLostNotificationInfo : TraitInfo + class ActorLostNotificationInfo : ConditionalTraitInfo { [NotificationReference("Speech")] public readonly string Notification = "UnitLost"; @@ -23,18 +23,18 @@ namespace OpenRA.Mods.Common.Traits.Sound public override object Create(ActorInitializer init) { return new ActorLostNotification(this); } } - class ActorLostNotification : INotifyKilled + class ActorLostNotification : ConditionalTrait, INotifyKilled { - ActorLostNotificationInfo info; public ActorLostNotification(ActorLostNotificationInfo info) - { - this.info = info; - } + : base(info) { } void INotifyKilled.Killed(Actor self, AttackInfo e) { - var player = info.NotifyAll ? self.World.LocalPlayer : self.Owner; - Game.Sound.PlayNotification(self.World.Map.Rules, player, "Speech", info.Notification, self.Owner.Faction.InternalName); + if (IsTraitDisabled) + return; + + var player = Info.NotifyAll ? self.World.LocalPlayer : self.Owner; + Game.Sound.PlayNotification(self.World.Map.Rules, player, "Speech", Info.Notification, self.Owner.Faction.InternalName); } } }