check voice actor references

This commit is contained in:
Matthias Mailänder
2015-06-20 12:09:58 +02:00
parent 264a63e58c
commit 50e5e9df24
52 changed files with 390 additions and 81 deletions

View File

@@ -57,9 +57,21 @@ namespace OpenRA
}
}
var voicedActor = actors.FirstOrDefault(a => a.Owner == world.LocalPlayer && a.IsInWorld && a.HasTrait<IVoiced>());
if (voicedActor != null)
voicedActor.PlayVoice("Select");
// Play the selection voice from one of the selected actors
// TODO: This probably should only be considering the newly selected actors
// TODO: Ship this into an INotifySelection trait to remove the engine dependency on Selectable
foreach (var actor in actors)
{
if (actor.Owner != world.LocalPlayer || !actor.IsInWorld)
continue;
var selectable = actor.Info.Traits.GetOrDefault<SelectableInfo>();
if (selectable == null || !actor.HasVoice(selectable.Voice))
continue;
actor.PlayVoice(selectable.Voice);
break;
}
foreach (var a in newSelection)
foreach (var sel in a.TraitsImplementing<INotifySelected>())