Global state singleton

This commit is contained in:
MaddoScientisto 2025-02-20 21:26:51 +01:00
commit 52d5adebcb
7 changed files with 73 additions and 5 deletions

View file

@ -8,6 +8,7 @@ using Godot.Collections;
public partial class GameManager : Node2D
{
public static GameManager Instance { get; private set;}
private Hud _hud;
private PlayerMovement _player;
@ -30,6 +31,8 @@ public partial class GameManager : Node2D
private InventoryManager _inventoryManager { get; set; }
public MapStartData MapStartData { get; set; }
//private AlarmManager _alarmManager { get; set; }
//public InventoryManager Inventory => _inventoryManager;
@ -45,6 +48,8 @@ public partial class GameManager : Node2D
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
Instance = this;
_hud = GetNodeOrNull<Hud>("HUD");
if (_hud == null) GD.Print("No HUD in scene.");
@ -73,7 +78,7 @@ public partial class GameManager : Node2D
//_ = DelayPlayerSpawn();
CallDeferred(nameof(DelayPlayerSpawn));
CallDeferred(MethodName.DelayPlayerSpawn);
}
// Called every frame. 'delta' is the elapsed time since the previous frame.