Actors/Actor.Audio.cs
namespace Opium;

public partial class Actor
{
	SoundHandle CurrentVoice;
	string currentVoicePath;

	public SoundHandle PlayVoice( SoundEvent snd )
	{
		CurrentVoice?.Stop( 0.5f );

		if ( snd is null )
			return null;

		CurrentVoice = null;

		// Play next sound
		CurrentVoice = Sound.Play( snd );
		currentVoicePath = snd.ResourceName;

		return CurrentVoice;
	}

	/// <summary>
	/// Plays a voice from the Actor's VoiceList
	/// </summary>
	/// <param name="voice"></param>
	/// <param name="fallback"></param>
	/// <returns></returns>
	public SoundHandle PlayVoice( string voice, SoundEvent fallback = null )
	{
		if ( VoiceList?.Find( voice, fallback ) is { } sound )
		{
			return PlayVoice( sound );
		}
		return PlayVoice( fallback );
	}

	void UpdateVoice()
	{
		if ( CurrentVoice is null ) return;

		CurrentVoice.Position = CameraObject.WorldPosition + CameraObject.WorldRotation.Forward * 50f;
	}
}