using Godot;
using Mr.BrickAdventures.Autoloads;
namespace Mr.BrickAdventures.scripts.Events;
///
/// Charges a death to the Playthrough.
///
///
/// One call now does what three did: spend a life, discard the Attempt's ledger, and announce the
/// settled result. It is also idempotent — overlapping hazards in a kill zone, or a hazard re-firing
/// during the two seconds before the scene reloads, cost one life. See
/// docs/adr/0005-playthrough-settles-attempts.md.
///
public partial class LivesStateHandler : Node
{
public override void _Ready()
{
EventBus.Instance.PlayerDied += OnPlayerDied;
}
public override void _ExitTree()
{
if (EventBus.Instance != null)
EventBus.Instance.PlayerDied -= OnPlayerDied;
}
private void OnPlayerDied(Vector2 position)
{
ProgressionRoot.Instance?.HandlePlayerDeath();
}
}