Make Voiced trait conditional
This commit is contained in:
@@ -14,7 +14,7 @@ using OpenRA.Traits;
|
|||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
[Desc("This actor has a voice.")]
|
[Desc("This actor has a voice.")]
|
||||||
public class VoicedInfo : TraitInfo
|
public class VoicedInfo : ConditionalTraitInfo
|
||||||
{
|
{
|
||||||
[VoiceSetReference]
|
[VoiceSetReference]
|
||||||
[FieldLoader.Require]
|
[FieldLoader.Require]
|
||||||
@@ -27,19 +27,18 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public override object Create(ActorInitializer init) { return new Voiced(this); }
|
public override object Create(ActorInitializer init) { return new Voiced(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Voiced : IVoiced
|
public class Voiced : ConditionalTrait<VoicedInfo>, IVoiced
|
||||||
{
|
{
|
||||||
public readonly VoicedInfo Info;
|
|
||||||
|
|
||||||
public Voiced(VoicedInfo info)
|
public Voiced(VoicedInfo info)
|
||||||
{
|
: base(info) { }
|
||||||
Info = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
string IVoiced.VoiceSet => Info.VoiceSet;
|
string IVoiced.VoiceSet => Info.VoiceSet;
|
||||||
|
|
||||||
bool IVoiced.PlayVoice(Actor self, string phrase, string variant)
|
bool IVoiced.PlayVoice(Actor self, string phrase, string variant)
|
||||||
{
|
{
|
||||||
|
if (IsTraitDisabled)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (phrase == null)
|
if (phrase == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -53,6 +52,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
bool IVoiced.PlayVoiceLocal(Actor self, string phrase, string variant, float volume)
|
bool IVoiced.PlayVoiceLocal(Actor self, string phrase, string variant, float volume)
|
||||||
{
|
{
|
||||||
|
if (IsTraitDisabled)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (phrase == null)
|
if (phrase == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -65,6 +67,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
bool IVoiced.HasVoice(Actor self, string voice)
|
bool IVoiced.HasVoice(Actor self, string voice)
|
||||||
{
|
{
|
||||||
|
if (IsTraitDisabled)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(Info.VoiceSet))
|
if (string.IsNullOrEmpty(Info.VoiceSet))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user