Move PlayVoice and PlayVoiceLocal from Sound to Voiced.
Move HasVoice, HasVoices and GetVoices from WorldUtils to Voiced.
This commit is contained in:
@@ -57,9 +57,10 @@ namespace OpenRA
|
||||
}
|
||||
}
|
||||
|
||||
var voicedActor = actors.FirstOrDefault(a => a.Owner == world.LocalPlayer && a.IsInWorld && a.HasVoices());
|
||||
var voicedActor = actors.FirstOrDefault(a => a.Owner == world.LocalPlayer && a.IsInWorld && (a.TraitsImplementing<IVoiced>() != null));
|
||||
if (voicedActor != null)
|
||||
Sound.PlayVoice("Select", voicedActor, voicedActor.Owner.Country.Race);
|
||||
foreach (var voice in voicedActor.TraitsImplementing<IVoiced>())
|
||||
voice.PlayVoice("Select", voicedActor, voicedActor.Owner.Country.Race);
|
||||
|
||||
foreach (var a in newSelection)
|
||||
foreach (var sel in a.TraitsImplementing<INotifySelected>())
|
||||
|
||||
@@ -364,32 +364,6 @@ namespace OpenRA
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool PlayVoice(string phrase, Actor voicedActor, string variant)
|
||||
{
|
||||
if (voicedActor == null || phrase == null)
|
||||
return false;
|
||||
|
||||
var mi = voicedActor.TraitOrDefault<IVoiced>();
|
||||
if (mi == null || mi.VoiceSet == null)
|
||||
return false;
|
||||
|
||||
var type = mi.VoiceSet.ToLowerInvariant();
|
||||
return PlayPredefined(voicedActor.World.Map.Rules, null, voicedActor, type, phrase, variant, true, WPos.Zero, 1f, true);
|
||||
}
|
||||
|
||||
public static bool PlayVoiceLocal(string phrase, Actor voicedActor, string variant, WPos pos, float volume)
|
||||
{
|
||||
if (voicedActor == null || phrase == null)
|
||||
return false;
|
||||
|
||||
var mi = voicedActor.TraitOrDefault<IVoiced>();
|
||||
if (mi == null || mi.VoiceSet == null)
|
||||
return false;
|
||||
|
||||
var type = mi.VoiceSet.ToLowerInvariant();
|
||||
return PlayPredefined(voicedActor.World.Map.Rules, null, voicedActor, type, phrase, variant, false, pos, volume, true);
|
||||
}
|
||||
|
||||
public static bool PlayNotification(Ruleset rules, Player player, string type, string notification, string variant)
|
||||
{
|
||||
if (rules == null)
|
||||
|
||||
@@ -109,7 +109,15 @@ namespace OpenRA.Traits
|
||||
|
||||
public interface ISeedableResource { void Seed(Actor self); }
|
||||
|
||||
public interface IVoiced { string VoiceSet { get; } }
|
||||
public interface IVoiced
|
||||
{
|
||||
bool PlayVoice(string phrase, Actor voicedActor, string variant);
|
||||
bool PlayVoiceLocal(string phrase, Actor voicedActor, string variant, WPos pos, float volume);
|
||||
bool HasVoices(Actor actor);
|
||||
bool HasVoice(Actor actor, string voice);
|
||||
string VoiceSet { get; }
|
||||
}
|
||||
|
||||
public interface IDemolishableInfo { bool IsValidTarget(ActorInfo actorInfo, Actor saboteur); }
|
||||
public interface IDemolishable
|
||||
{
|
||||
|
||||
@@ -42,28 +42,6 @@ namespace OpenRA
|
||||
}
|
||||
}
|
||||
|
||||
public static bool HasVoices(this Actor a)
|
||||
{
|
||||
var voice = a.TraitOrDefault<IVoiced>();
|
||||
return voice != null && voice.VoiceSet != null;
|
||||
}
|
||||
|
||||
public static bool HasVoice(this Actor a, string voice)
|
||||
{
|
||||
var v = GetVoices(a);
|
||||
return v != null && v.Voices.ContainsKey(voice);
|
||||
}
|
||||
|
||||
public static SoundInfo GetVoices(this Actor a)
|
||||
{
|
||||
var voiced = a.TraitOrDefault<IVoiced>();
|
||||
if (voiced == null)
|
||||
return null;
|
||||
|
||||
var v = voiced.VoiceSet;
|
||||
return (v == null) ? null : a.World.Map.Rules.Voices[v.ToLowerInvariant()];
|
||||
}
|
||||
|
||||
public static void PlayVoiceForOrders(this World w, Order[] orders)
|
||||
{
|
||||
// Find an actor with a phrase to say
|
||||
@@ -75,13 +53,15 @@ namespace OpenRA
|
||||
if (o.Subject.Destroyed)
|
||||
continue;
|
||||
|
||||
if (!o.Subject.HasVoices())
|
||||
var hasVoice = o.Subject.TraitsImplementing<IVoiced>();
|
||||
if (hasVoice == null)
|
||||
continue;
|
||||
|
||||
foreach (var v in o.Subject.TraitsImplementing<IOrderVoice>())
|
||||
if (Sound.PlayVoice(v.VoicePhraseForOrder(o.Subject, o),
|
||||
o.Subject, o.Subject.Owner.Country.Race))
|
||||
return;
|
||||
foreach (var voice in o.Subject.TraitsImplementing<IVoiced>())
|
||||
if (voice.PlayVoice(v.VoicePhraseForOrder(o.Subject, o),
|
||||
o.Subject, o.Subject.Owner.Country.Race))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user