Skip to content

Commit cb8980c

Browse files
committed
feat: tiles manager foi adaptado para se tornar um singleton e tambem foi adicionado a lista de scripts auto carregaveis da godot
1 parent 16526ec commit cb8980c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Modules/GameManagers/Scripts/TilesManager.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,26 @@ namespace DungeonRoyale.Modules.GameManagers.Scripts;
66

77
public partial class TilesManager : Node2D
88
{
9+
public static TilesManager? Instance { get; private set; }
10+
911
public DRTileData[,] Tiles { get; private set; } = new DRTileData[0, 0];
1012

1113
private int _width;
1214
private int _height;
1315

16+
public override void _Ready()
17+
{
18+
if (Instance is null)
19+
{
20+
Instance = this;
21+
}
22+
else
23+
{
24+
GD.PrintErr("There is already an instance of TilesManager in the scene.");
25+
}
26+
}
27+
28+
1429
public void SetUpTiles(int width, int height)
1530
{
1631
_width = width;

project.godot

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ run/main_scene="res://Modules/Game/Scenes/Game.tscn"
1515
config/features=PackedStringArray("4.4", "C#", "GL Compatibility")
1616
config/icon="res://icon.svg"
1717

18+
[autoload]
19+
20+
TilesManager="*res://Modules/GameManagers/Scripts/TilesManager.cs"
21+
1822
[dotnet]
1923

2024
project/assembly_name="DungeonRoyale"

0 commit comments

Comments
 (0)