From 433d69af7a1b9bccfcb3fc3a81fc8a256107cafa Mon Sep 17 00:00:00 2001 From: michaeldgg2 <119738087+michaeldgg2@users.noreply.github.com> Date: Sat, 8 Jul 2023 21:05:28 +0200 Subject: [PATCH] Make Voiced trait conditional --- OpenRA.Mods.Common/Traits/Voiced.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Voiced.cs b/OpenRA.Mods.Common/Traits/Voiced.cs index 113d130d2d..b94027cbf4 100644 --- a/OpenRA.Mods.Common/Traits/Voiced.cs +++ b/OpenRA.Mods.Common/Traits/Voiced.cs @@ -14,7 +14,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("This actor has a voice.")] - public class VoicedInfo : TraitInfo + public class VoicedInfo : ConditionalTraitInfo { [VoiceSetReference] [FieldLoader.Require] @@ -27,19 +27,18 @@ namespace OpenRA.Mods.Common.Traits public override object Create(ActorInitializer init) { return new Voiced(this); } } - public class Voiced : IVoiced + public class Voiced : ConditionalTrait, IVoiced { - public readonly VoicedInfo Info; - public Voiced(VoicedInfo info) - { - Info = info; - } + : base(info) { } string IVoiced.VoiceSet => Info.VoiceSet; bool IVoiced.PlayVoice(Actor self, string phrase, string variant) { + if (IsTraitDisabled) + return false; + if (phrase == null) return false; @@ -53,6 +52,9 @@ namespace OpenRA.Mods.Common.Traits bool IVoiced.PlayVoiceLocal(Actor self, string phrase, string variant, float volume) { + if (IsTraitDisabled) + return false; + if (phrase == null) return false; @@ -65,6 +67,9 @@ namespace OpenRA.Mods.Common.Traits bool IVoiced.HasVoice(Actor self, string voice) { + if (IsTraitDisabled) + return false; + if (string.IsNullOrEmpty(Info.VoiceSet)) return false;