Player/Mechanics/FallingMechanic.cs
namespace Opium;

public partial class FallingMechanci : TakeoverAnimationMechanic
{
	[Property] public List<TimedSoundEntry> TimedSounds { get; set; } = new();

	public override IEnumerable<string> GetTags()
	{
		yield return "falling";
	}

	protected override void OnDestroy()
	{
		Actor.Health = 75;
	}

	protected override void OnActiveChanged( bool before, bool after )
	{
		base.OnActiveChanged( before, after );

		if ( after )
		{
			foreach ( var snd in TimedSounds )
			{
				PlayAsyncSound( snd );
			}


		}
	}

	async void PlayAsyncSound( TimedSoundEntry snd )
	{
		await GameTask.DelaySeconds( snd.Time );

		if ( !GameObject.IsValid() ) return;

		GameObject.PlaySound( snd.Sound );
	}
}