Skip to content

Commit 3c8bfe0

Browse files
committed
adjust: tile constants foi movido para uma pasta de constantes e foi adicionado uma validacao para numeros negativos no setup do tiles manager
1 parent cb8980c commit 3c8bfe0

File tree

7 files changed

+12
-14
lines changed

7 files changed

+12
-14
lines changed

Modules/GameManagers/Scripts/TilesManager.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
using System;
12
using System.Diagnostics.CodeAnalysis;
23
using System.Runtime.CompilerServices;
34
using DungeonRoyale.Modules.Tiles.Scripts;
5+
using DungeonRoyale.Shared.Scripts.Constants;
46

57
namespace DungeonRoyale.Modules.GameManagers.Scripts;
68

@@ -25,21 +27,17 @@ public override void _Ready()
2527
}
2628
}
2729

28-
2930
public void SetUpTiles(int width, int height)
3031
{
32+
if (width <= 0 || height <= 0)
33+
{
34+
throw new ArgumentException("Width and height must be greater than 0.");
35+
}
36+
3137
_width = width;
3238
_height = height;
3339

3440
Tiles = new DRTileData[_width, _height];
35-
36-
for (int x = 0; x < _width; x++)
37-
{
38-
for (int y = 0; y < _height; y++)
39-
{
40-
Tiles[x, y] = new DRTileData(x, y, true, false);
41-
}
42-
}
4341
}
4442

4543
[MethodImpl(MethodImplOptions.AggressiveInlining)]

Modules/Player/Scripts/Player.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using DungeonRoyale.Shared.Scripts.Constants;
2+
13
namespace DungeonRoyale.Modules.Player.Scripts;
24

35
public partial class Player : CharacterBody2D

Modules/Tiles/Scripts/DRTileData.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ public DRTileData()
1313
{
1414
}
1515

16-
public DRTileData(int x, int y, bool isWalkable, bool isSpawnPoint)
16+
public DRTileData(int x, int y)
1717
{
1818
X = x;
1919
Y = y;
20-
IsWalkable = isWalkable;
21-
IsSpawnPoint = isSpawnPoint;
2220
}
2321
}

Shared/Scripts/MappedInputs.cs renamed to Shared/Scripts/Constants/MappedInputs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace DungeonRoyale.Shared.Scripts;
1+
namespace DungeonRoyale.Shared.Scripts.Constants;
22

33
public static class MappedInputs
44
{
File renamed without changes.

Shared/Scripts/TilesConstants.cs renamed to Shared/Scripts/Constants/TilesConstants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace DungeonRoyale.Shared.Scripts;
1+
namespace DungeonRoyale.Shared.Scripts.Constants;
22

33
public static class TileConstants
44
{
File renamed without changes.

0 commit comments

Comments
 (0)