Move voice playing for orders into a helper function

This commit is contained in:
abcdefg30
2019-12-12 22:35:55 +01:00
committed by reaperrr
parent 4d407da3e6
commit 959c750851

View File

@@ -51,15 +51,22 @@ namespace OpenRA
public static void PlayVoiceForOrders(this World w, Order[] orders)
{
// Find an actor with a phrase to say
// Find the first actor with a phrase to say
foreach (var o in orders)
{
if (o == null)
continue;
if (PlayVoiceForOrder(o))
return;
}
}
static bool PlayVoiceForOrder(Order o)
{
var orderSubject = o.Subject;
if (orderSubject == null || orderSubject.Disposed)
continue;
return false;
foreach (var voice in orderSubject.TraitsImplementing<IVoiced>())
{
@@ -67,10 +74,11 @@ namespace OpenRA
{
if (voice.PlayVoice(orderSubject, v.VoicePhraseForOrder(orderSubject, o),
orderSubject.Owner.Faction.InternalName))
return;
}
return true;
}
}
return false;
}
}
}