refactor: implement singleton pattern for key managers and improve resource access

This commit is contained in:
2026-03-19 02:00:56 +01:00
parent cfef49fbc7
commit 470b0c3a8c
14 changed files with 72 additions and 83 deletions

View File

@@ -1,6 +1,5 @@
using System.Threading.Tasks;
using Godot;
using Mr.BrickAdventures;
using Mr.BrickAdventures.Autoloads;
namespace Mr.BrickAdventures.scripts.components;
@@ -17,12 +16,8 @@ public partial class LeverComponent : Node
[Signal]
public delegate void ActivatedEventHandler();
private FloatingTextManager _floatingTextManager;
public override void _Ready()
{
_floatingTextManager = GetNode<FloatingTextManager>(Constants.FloatingTextManagerPath);
if (Area == null)
{
GD.PushError("LeverComponent: Area is not set.");
@@ -52,7 +47,7 @@ public partial class LeverComponent : Node
private async Task Activate()
{
EmitSignalActivated();
_floatingTextManager?.ShowMessage("Activated!", ((Node2D)Owner).GlobalPosition);
FloatingTextManager.Instance?.ShowMessage("Activated!", ((Node2D)Owner).GlobalPosition);
Sfx?.Play();
Sprite.Frame = StartAnimationIndex + 1;
var timer = GetTree().CreateTimer(AnimationDuration);