death sounds, build sounds, better audio management

This commit is contained in:
Ian Woods 2026-06-30 23:12:27 -07:00
parent a7b2d1854d
commit 9f25844657
26 changed files with 313 additions and 12 deletions

View file

@ -126,6 +126,9 @@ namespace TD.Gameplay
/// </summary>
public event System.Action<EnemyHealth> OnDied;
/// <summary>Fired on ALL peers the moment this enemy dies. Use for client-side visuals and audio.</summary>
public event System.Action OnDiedClient;
// ----- Server-only pre-spawn init -------------------------------------
/// <summary>
@ -240,6 +243,7 @@ namespace TD.Gameplay
if (deathAnimator != null)
deathAnimator.SetTrigger(DieHash);
DiedClientRpc();
StartCoroutine(DeathSequence());
}
@ -263,6 +267,12 @@ namespace TD.Gameplay
// mesh sizes substantially, derive this from a collider bounds instead.
public float SelectionRadius => 0.4f;
[ClientRpc]
private void DiedClientRpc()
{
OnDiedClient?.Invoke();
}
private IEnumerator DeathSequence()
{
// Hold while the death animation plays.