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,5 +1,4 @@
using Godot;
using Mr.BrickAdventures;
using Mr.BrickAdventures.Autoloads;
namespace Mr.BrickAdventures.scripts.Events;
@@ -7,17 +6,18 @@ namespace Mr.BrickAdventures.scripts.Events;
[GlobalClass]
public partial class SpeedRunEventHandler : Node
{
private SpeedRunManager _speedRunManager;
public override void _Ready()
{
_speedRunManager = GetNode<SpeedRunManager>(Constants.SpeedRunManagerPath);
EventBus.Instance.LevelCompleted += OnLevelCompleted;
}
public override void _ExitTree()
{
EventBus.Instance.LevelCompleted -= OnLevelCompleted;
}
private void OnLevelCompleted(int levelIndex, Node currentScene, double completionTime)
{
_speedRunManager.Split();
SpeedRunManager.Instance?.Split();
}
}