mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 11:25:54 +00:00
Dungeon generation
This commit is contained in:
parent
4d2b58e234
commit
c3107fbce9
9 changed files with 494 additions and 130 deletions
|
|
@ -14,11 +14,11 @@ public partial class RogueliteRoomResource : Resource
|
|||
[Export] public Vector2I Size { get; set; } = new(1, 1);
|
||||
|
||||
[Export] public Array<Vector2I> DoorGridPositions { get; set; } = [];
|
||||
|
||||
|
||||
[Export] public Array<EnemyResource> SpawnableEnemies { get; set; }
|
||||
|
||||
|
||||
[Export] public DoorDirections DoorDirections { get; set; }
|
||||
|
||||
|
||||
public bool HasDoors(DoorDirections required) => (DoorDirections & required) == required;
|
||||
|
||||
public override string ToString()
|
||||
|
|
@ -26,13 +26,31 @@ public partial class RogueliteRoomResource : Resource
|
|||
return $"{RoomName} {Type} {Size.X}x{Size.Y}";
|
||||
}
|
||||
|
||||
public List<Vector2I> GetTopRoomOffsets(Vector2I gridPosition)
|
||||
public List<Vector2I> GetRoomOffsets(Vector2I gridPosition, Direction side)
|
||||
{
|
||||
List<Vector2I> offsets = [];
|
||||
|
||||
for (int i = 0; i < Size.X; i++)
|
||||
|
||||
switch (side)
|
||||
{
|
||||
offsets.Add(new Vector2I(gridPosition.X - i, gridPosition.Y));
|
||||
case Direction.Down:
|
||||
for (int i = 0; i < Size.X; i++)
|
||||
offsets.Add(new Vector2I(gridPosition.X - i, gridPosition.Y));
|
||||
break;
|
||||
|
||||
case Direction.Up:
|
||||
for (int i = 0; i < Size.X; i++)
|
||||
offsets.Add(new Vector2I(gridPosition.X - i, gridPosition.Y + Size.Y - 1));
|
||||
break;
|
||||
|
||||
case Direction.Right:
|
||||
for (int i = 0; i < Size.Y; i++)
|
||||
offsets.Add(new Vector2I(gridPosition.X, gridPosition.Y - i));
|
||||
break;
|
||||
|
||||
case Direction.Left:
|
||||
for (int i = 0; i < Size.Y; i++)
|
||||
offsets.Add(new Vector2I(gridPosition.X + Size.X - 1, gridPosition.Y - i));
|
||||
break;
|
||||
}
|
||||
|
||||
return offsets;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue