From c8cfb10ab189fd6a0d80f258357bd46b00a46358 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Sun, 17 Apr 2016 15:26:53 +0200 Subject: [PATCH 1/3] Reduce the usage of different ways to determine the new owner We don't need the LocalPlayer check if we only play the sound to the new owner, and captor.Owner == newOwner in this case. --- OpenRA.Mods.Common/Traits/Sound/CaptureNotification.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Sound/CaptureNotification.cs b/OpenRA.Mods.Common/Traits/Sound/CaptureNotification.cs index 109c6d649c..7e7574309f 100644 --- a/OpenRA.Mods.Common/Traits/Sound/CaptureNotification.cs +++ b/OpenRA.Mods.Common/Traits/Sound/CaptureNotification.cs @@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits.Sound public class CaptureNotification : INotifyCapture { - CaptureNotificationInfo info; + readonly CaptureNotificationInfo info; public CaptureNotification(CaptureNotificationInfo info) { this.info = info; @@ -31,11 +31,8 @@ namespace OpenRA.Mods.Common.Traits.Sound public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner) { - if (captor.World.LocalPlayer != captor.Owner) - return; - var faction = info.NewOwnerVoice ? newOwner.Faction.InternalName : oldOwner.Faction.InternalName; - Game.Sound.PlayNotification(self.World.Map.Rules, captor.World.LocalPlayer, "Speech", info.Notification, faction); + Game.Sound.PlayNotification(self.World.Map.Rules, newOwner, "Speech", info.Notification, faction); } } } From a1d39b0a42fa66276865ed14664f61648eb03d9a Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Sun, 17 Apr 2016 15:29:27 +0200 Subject: [PATCH 2/3] Document the existing fields in CaptureNotificationInfo --- OpenRA.Mods.Common/Traits/Sound/CaptureNotification.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OpenRA.Mods.Common/Traits/Sound/CaptureNotification.cs b/OpenRA.Mods.Common/Traits/Sound/CaptureNotification.cs index 7e7574309f..164b67686a 100644 --- a/OpenRA.Mods.Common/Traits/Sound/CaptureNotification.cs +++ b/OpenRA.Mods.Common/Traits/Sound/CaptureNotification.cs @@ -15,7 +15,10 @@ namespace OpenRA.Mods.Common.Traits.Sound { public class CaptureNotificationInfo : ITraitInfo { + [Desc("The speech notification to play to the new owner.")] public readonly string Notification = "BuildingCaptured"; + + [Desc("Specifies if Notification is played with the voice of the new owners faction.")] public readonly bool NewOwnerVoice = true; public object Create(ActorInitializer init) { return new CaptureNotification(this); } From af3d8d4860ab89bdaa6aadeed0eeae03d489af0c Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Sun, 17 Apr 2016 16:17:32 +0200 Subject: [PATCH 3/3] Add support for playing a "LoseNotification" to the old owner through CaptureNotification --- OpenRA.Mods.Common/Traits/Sound/CaptureNotification.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OpenRA.Mods.Common/Traits/Sound/CaptureNotification.cs b/OpenRA.Mods.Common/Traits/Sound/CaptureNotification.cs index 164b67686a..1cc8cc01c9 100644 --- a/OpenRA.Mods.Common/Traits/Sound/CaptureNotification.cs +++ b/OpenRA.Mods.Common/Traits/Sound/CaptureNotification.cs @@ -21,6 +21,12 @@ namespace OpenRA.Mods.Common.Traits.Sound [Desc("Specifies if Notification is played with the voice of the new owners faction.")] public readonly bool NewOwnerVoice = true; + [Desc("The speech notification to play to the old owner.")] + public readonly string LoseNotification = null; + + [Desc("Specifies if LoseNotification is played with the voice of the new owners faction.")] + public readonly bool LoseNewOwnerVoice = false; + public object Create(ActorInitializer init) { return new CaptureNotification(this); } } @@ -36,6 +42,9 @@ namespace OpenRA.Mods.Common.Traits.Sound { var faction = info.NewOwnerVoice ? newOwner.Faction.InternalName : oldOwner.Faction.InternalName; Game.Sound.PlayNotification(self.World.Map.Rules, newOwner, "Speech", info.Notification, faction); + + var loseFaction = info.LoseNewOwnerVoice ? newOwner.Faction.InternalName : oldOwner.Faction.InternalName; + Game.Sound.PlayNotification(self.World.Map.Rules, oldOwner, "Speech", info.LoseNotification, loseFaction); } } }