feat: Implement a comprehensive global event bus with new event handlers and integrate player health and collection events.

This commit is contained in:
2026-01-31 15:15:52 +01:00
parent dde3eaa52e
commit 62bdf1ba39
15 changed files with 322 additions and 54 deletions

View File

@@ -1,5 +1,6 @@
using System;
using Godot;
using Mr.BrickAdventures;
using Mr.BrickAdventures.Autoloads;
using Mr.BrickAdventures.scripts.Resources;
@@ -35,7 +36,7 @@ public partial class CollectableComponent : Node
if (Owner.HasNode("FadeAwayComponent"))
_hasFadeAway = true;
_floatingTextManager = GetNode<FloatingTextManager>("/root/FloatingTextManager");
_floatingTextManager = GetNode<FloatingTextManager>(Constants.FloatingTextManagerPath);
}
private async void OnArea2DBodyEntered(Node2D body)
@@ -53,12 +54,18 @@ public partial class CollectableComponent : Node
{
case CollectableType.Coin:
_floatingTextManager?.ShowCoin((int)Data.Amount, ownerNode.GlobalPosition);
EventBus.EmitCoinCollected((int)Data.Amount, ownerNode.GlobalPosition);
break;
case CollectableType.Health:
_floatingTextManager?.ShowMessage("Healed!", ownerNode.GlobalPosition);
EventBus.EmitItemCollected(Data.Type, Data.Amount, ownerNode.GlobalPosition);
break;
case CollectableType.Kid:
_floatingTextManager?.ShowMessage("Rescued!", ownerNode.GlobalPosition);
EventBus.EmitChildRescued(ownerNode.GlobalPosition);
break;
default:
EventBus.EmitItemCollected(Data.Type, Data.Amount, ownerNode.GlobalPosition);
break;
}
}