- ConsoleManager: lazy GameManager/AchievementManager via Instance (fixes NullRef on console commands) - AchievementManager, GhostManager: add static Instance property - GhostEventHandler: use GhostManager.Instance, add _ExitTree unsubscription - SpeedRunManager: remove unused IsVisible guard; TimeUpdated now emits when running - SpeedRunHud: use SpeedRunManager.Instance, remove dead IsVisible binding - SaveDataDto: moved to scripts/State/SaveDataDto.cs - GameManager.AddCoins: XML doc clarifying permanent vs session coins
33 lines
974 B
C#
33 lines
974 B
C#
using Godot;
|
|
using Mr.BrickAdventures;
|
|
using Mr.BrickAdventures.Autoloads;
|
|
|
|
namespace Mr.BrickAdventures.scripts.Events;
|
|
|
|
[GlobalClass]
|
|
public partial class GhostEventHandler : Node
|
|
{
|
|
public override void _Ready()
|
|
{
|
|
EventBus.Instance.LevelStarted += OnLevelStarted;
|
|
EventBus.Instance.LevelCompleted += OnLevelCompleted;
|
|
}
|
|
|
|
public override void _ExitTree()
|
|
{
|
|
EventBus.Instance.LevelStarted -= OnLevelStarted;
|
|
EventBus.Instance.LevelCompleted -= OnLevelCompleted;
|
|
}
|
|
|
|
private void OnLevelStarted(int levelIndex, Node currentScene)
|
|
{
|
|
GD.Print($"GhostEventHandler: Level {levelIndex} started.");
|
|
GhostManager.Instance.StartRecording(levelIndex);
|
|
GhostManager.Instance.SpawnGhostPlayer(levelIndex, currentScene);
|
|
}
|
|
|
|
private void OnLevelCompleted(int levelIndex, Node currentScene, double completionTime)
|
|
{
|
|
GhostManager.Instance.StopRecording(true, completionTime);
|
|
}
|
|
} |