mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-07-01 13:01:16 +00:00
Various
This commit is contained in:
parent
6e26eb21b1
commit
15457f4314
2 changed files with 37 additions and 32 deletions
|
|
@ -44,7 +44,6 @@ script = ExtResource("4_jtlua")
|
||||||
Rooms = Array[Object]([ExtResource("5_gwtv6"), ExtResource("6_gwtv6"), ExtResource("7_wbqvu"), ExtResource("8_3fyis"), ExtResource("9_go1yg"), ExtResource("5_pfafs"), ExtResource("11_68lig"), ExtResource("12_83bvc"), ExtResource("13_y651a"), ExtResource("14_vhvs2"), ExtResource("15_6gk3e"), ExtResource("16_4gy5m"), ExtResource("17_td7hx"), ExtResource("18_2lxq3"), ExtResource("19_6ahuq"), ExtResource("20_xrp0h")])
|
Rooms = Array[Object]([ExtResource("5_gwtv6"), ExtResource("6_gwtv6"), ExtResource("7_wbqvu"), ExtResource("8_3fyis"), ExtResource("9_go1yg"), ExtResource("5_pfafs"), ExtResource("11_68lig"), ExtResource("12_83bvc"), ExtResource("13_y651a"), ExtResource("14_vhvs2"), ExtResource("15_6gk3e"), ExtResource("16_4gy5m"), ExtResource("17_td7hx"), ExtResource("18_2lxq3"), ExtResource("19_6ahuq"), ExtResource("20_xrp0h")])
|
||||||
DungeonLength = 6
|
DungeonLength = 6
|
||||||
MaxBranchLength = 2
|
MaxBranchLength = 2
|
||||||
Seed = 1
|
|
||||||
|
|
||||||
[node name="CameraController" type="Camera2D" parent="."]
|
[node name="CameraController" type="Camera2D" parent="."]
|
||||||
process_mode = 1
|
process_mode = 1
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,13 @@ public partial class RogueliteRoomManager : Node2D
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<RogueliteRoomResource> StarterRooms => Rooms.Where(x => x.Type is RoomType.Starter);
|
private IEnumerable<RogueliteRoomResource> StarterRooms => Rooms.Where(x => x.Type is RoomType.Starter);
|
||||||
private IEnumerable<RogueliteRoomResource> RegularRooms => Rooms.Where(x => x.Type is RoomType.Regular && x.HasDoors(DoorDirections.North | DoorDirections.South));
|
|
||||||
private IEnumerable<RogueliteRoomResource> OffshootRooms => Rooms.Where(x => x.Type is RoomType.Regular && x.HasDoors(DoorDirections.East | DoorDirections.West));
|
private IEnumerable<RogueliteRoomResource> RegularRooms => Rooms.Where(x =>
|
||||||
|
x.Type is RoomType.Regular && x.HasDoors(DoorDirections.North | DoorDirections.South));
|
||||||
|
|
||||||
|
private IEnumerable<RogueliteRoomResource> OffshootRooms => Rooms.Where(x =>
|
||||||
|
x.Type is RoomType.Regular && x.HasDoors(DoorDirections.East | DoorDirections.West));
|
||||||
|
|
||||||
private IEnumerable<RogueliteRoomResource> BossRooms => Rooms.Where(x => x.Type is RoomType.Boss);
|
private IEnumerable<RogueliteRoomResource> BossRooms => Rooms.Where(x => x.Type is RoomType.Boss);
|
||||||
|
|
||||||
private List<Vector2I> _mainPath = new();
|
private List<Vector2I> _mainPath = new();
|
||||||
|
|
@ -95,7 +99,7 @@ public partial class RogueliteRoomManager : Node2D
|
||||||
var randomRoomsList = RegularRooms.Shuffle(DungeonLength).ToList();
|
var randomRoomsList = RegularRooms.Shuffle(DungeonLength).ToList();
|
||||||
|
|
||||||
var randomOffshootRoomsList = OffshootRooms.Shuffle(MaxBranchLength).ToList();
|
var randomOffshootRoomsList = OffshootRooms.Shuffle(MaxBranchLength).ToList();
|
||||||
|
|
||||||
var currentPos = spawnedBeginRoom.RandomBottomExit;
|
var currentPos = spawnedBeginRoom.RandomBottomExit;
|
||||||
_connections.Add(new RoomConnection(origin, currentPos + new Vector2I(0, 1)));
|
_connections.Add(new RoomConnection(origin, currentPos + new Vector2I(0, 1)));
|
||||||
Vector2I nextPos;
|
Vector2I nextPos;
|
||||||
|
|
@ -109,9 +113,9 @@ public partial class RogueliteRoomManager : Node2D
|
||||||
RoomType.Regular
|
RoomType.Regular
|
||||||
};
|
};
|
||||||
var shuffledOffshoots = offshoots.Shuffle().ToList();
|
var shuffledOffshoots = offshoots.Shuffle().ToList();
|
||||||
|
|
||||||
int currentOffshoot = 0;
|
int currentOffshoot = 0;
|
||||||
|
|
||||||
for (int i = 0; i < DungeonLength; i++)
|
for (int i = 0; i < DungeonLength; i++)
|
||||||
{
|
{
|
||||||
GD.Print($"Dungeon room {i}");
|
GD.Print($"Dungeon room {i}");
|
||||||
|
|
@ -119,7 +123,7 @@ public partial class RogueliteRoomManager : Node2D
|
||||||
|
|
||||||
//var roomToSpawn = Rooms.Where(x => x.Type == RoomType.Regular).PickRandom();
|
//var roomToSpawn = Rooms.Where(x => x.Type == RoomType.Regular).PickRandom();
|
||||||
var roomToSpawn = randomRoomsList[i % randomRoomsList.Count];
|
var roomToSpawn = randomRoomsList[i % randomRoomsList.Count];
|
||||||
|
|
||||||
// We're already in the new room position, we do not care about previous anymore
|
// We're already in the new room position, we do not care about previous anymore
|
||||||
var offset = 0;
|
var offset = 0;
|
||||||
|
|
||||||
|
|
@ -144,17 +148,17 @@ public partial class RogueliteRoomManager : Node2D
|
||||||
_mainPath.Add(nextPos);
|
_mainPath.Add(nextPos);
|
||||||
|
|
||||||
nextPos = spawnedRoom.RandomBottomExit;
|
nextPos = spawnedRoom.RandomBottomExit;
|
||||||
|
|
||||||
GD.Print($"Next pos is now: {nextPos}");
|
GD.Print($"Next pos is now: {nextPos}");
|
||||||
|
|
||||||
// nextPos is now the end of the room at the current exit
|
// nextPos is now the end of the room at the current exit
|
||||||
|
|
||||||
_connections.Add(new RoomConnection(nextPos, nextPos + new Vector2I(0, 1)));
|
_connections.Add(new RoomConnection(nextPos, nextPos + new Vector2I(0, 1)));
|
||||||
|
|
||||||
currentPos = nextPos;
|
currentPos = nextPos;
|
||||||
|
|
||||||
// Spawn offshoot here
|
// Spawn offshoot here
|
||||||
|
|
||||||
var offshootTypeToSpawn = shuffledOffshoots[currentOffshoot % shuffledOffshoots.Count()];
|
var offshootTypeToSpawn = shuffledOffshoots[currentOffshoot % shuffledOffshoots.Count()];
|
||||||
|
|
||||||
if (offshootTypeToSpawn is RoomType.Regular)
|
if (offshootTypeToSpawn is RoomType.Regular)
|
||||||
|
|
@ -162,21 +166,23 @@ public partial class RogueliteRoomManager : Node2D
|
||||||
currentOffshoot++;
|
currentOffshoot++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int roomsInOffshot = GD.RandRange(0, MaxBranchLength);
|
int roomsInOffshot = GD.RandRange(0, MaxBranchLength);
|
||||||
|
|
||||||
var leftPosition = spawnedRoom.GridPosition;
|
var leftPosition = spawnedRoom.GridPosition;
|
||||||
|
|
||||||
// Roll whether to go left or right, if direction is full go the other, if both are full do not spawn
|
// Roll whether to go left or right, if direction is full go the other, if both are full do not spawn
|
||||||
|
|
||||||
for (int j = 0; j < roomsInOffshot; j++)
|
for (int j = 0; j < roomsInOffshot; j++)
|
||||||
{
|
{
|
||||||
var shuffledOffshootRoomsList = randomOffshootRoomsList.Shuffle().ToList();
|
var shuffledOffshootRoomsList = randomOffshootRoomsList.Shuffle().ToList();
|
||||||
|
|
||||||
|
var directions = new List<Vector2I>() { Vector2I.Left, Vector2I.Right }.Shuffle();
|
||||||
|
|
||||||
foreach (var shuffledOffshoot in shuffledOffshootRoomsList)
|
foreach (var shuffledOffshoot in shuffledOffshootRoomsList)
|
||||||
{
|
{
|
||||||
var offshootCoord = leftPosition - new Vector2I(shuffledOffshoot.Size.X, 0);
|
var offshootCoord = leftPosition - new Vector2I(shuffledOffshoot.Size.X, 0);
|
||||||
|
|
||||||
GD.Print("Spawning side room");
|
GD.Print("Spawning side room");
|
||||||
var spawned = SpawnRoom(shuffledOffshoot, offshootCoord, out var spawnedOffshoot);
|
var spawned = SpawnRoom(shuffledOffshoot, offshootCoord, out var spawnedOffshoot);
|
||||||
|
|
||||||
|
|
@ -186,9 +192,10 @@ public partial class RogueliteRoomManager : Node2D
|
||||||
// Try next in list
|
// Try next in list
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_connections.Add(new RoomConnection(leftPosition, offshootCoord + new Vector2I(shuffledOffshoot.Size.X -1, 0)));
|
_connections.Add(new RoomConnection(leftPosition,
|
||||||
|
offshootCoord + new Vector2I(shuffledOffshoot.Size.X - 1, 0)));
|
||||||
|
|
||||||
leftPosition = offshootCoord;
|
leftPosition = offshootCoord;
|
||||||
|
|
||||||
// Stop because we spawned the room we needed to
|
// Stop because we spawned the room we needed to
|
||||||
|
|
@ -198,22 +205,21 @@ public partial class RogueliteRoomManager : Node2D
|
||||||
|
|
||||||
// If it got here and couldn't spawn the offshoot, do not increase counter
|
// If it got here and couldn't spawn the offshoot, do not increase counter
|
||||||
}
|
}
|
||||||
|
|
||||||
// Offshoot over
|
// Offshoot over
|
||||||
|
|
||||||
// Spawn final room
|
// Spawn final room
|
||||||
var finalRoomToSpawn = Rooms.Where(x => x.Type == offshootTypeToSpawn).PickRandom();
|
var finalRoomToSpawn = Rooms.Where(x => x.Type == offshootTypeToSpawn).PickRandom();
|
||||||
|
|
||||||
var finalRoomCoord = leftPosition - new Vector2I(finalRoomToSpawn.Size.X, 0);
|
var finalRoomCoord = leftPosition - new Vector2I(finalRoomToSpawn.Size.X, 0);
|
||||||
|
|
||||||
SpawnRoom(finalRoomToSpawn, finalRoomCoord, out var spawnedFinalRoom);
|
SpawnRoom(finalRoomToSpawn, finalRoomCoord, out var spawnedFinalRoom);
|
||||||
|
|
||||||
_connections.Add(new RoomConnection(leftPosition, finalRoomCoord + new Vector2I(finalRoomToSpawn.Size.X -1, 0)));
|
_connections.Add(new RoomConnection(leftPosition,
|
||||||
|
finalRoomCoord + new Vector2I(finalRoomToSpawn.Size.X - 1, 0)));
|
||||||
|
|
||||||
leftPosition = finalRoomCoord;
|
leftPosition = finalRoomCoord;
|
||||||
// Done with last offshoot room
|
// Done with last offshoot room
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nextPos = currentPos + new Vector2I(0, 1);
|
nextPos = currentPos + new Vector2I(0, 1);
|
||||||
|
|
@ -229,7 +235,7 @@ public partial class RogueliteRoomManager : Node2D
|
||||||
{
|
{
|
||||||
nextPos += new Vector2I(0, bossRoom.Size.Y - 1);
|
nextPos += new Vector2I(0, bossRoom.Size.Y - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
_connections.Add(new RoomConnection(currentPos, nextPos));
|
_connections.Add(new RoomConnection(currentPos, nextPos));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -249,7 +255,7 @@ public partial class RogueliteRoomManager : Node2D
|
||||||
}
|
}
|
||||||
|
|
||||||
EmitSignalMapCreated();
|
EmitSignalMapCreated();
|
||||||
|
|
||||||
//CallDeferred(MethodName.OpenStartDoorsDeferred, spawnedBeginRoom);
|
//CallDeferred(MethodName.OpenStartDoorsDeferred, spawnedBeginRoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -304,11 +310,11 @@ public partial class RogueliteRoomManager : Node2D
|
||||||
spawnedScene.GridPosition = gridPos;
|
spawnedScene.GridPosition = gridPos;
|
||||||
|
|
||||||
spawnedScene.Name = room.RoomName.ToString().Replace(" ", "_");
|
spawnedScene.Name = room.RoomName.ToString().Replace(" ", "_");
|
||||||
|
|
||||||
SpawnedRooms.Add(spawnedScene);
|
SpawnedRooms.Add(spawnedScene);
|
||||||
|
|
||||||
GD.Print($"Spawned room: {spawnedScene}");
|
GD.Print($"Spawned room: {spawnedScene}");
|
||||||
|
|
||||||
// for reference
|
// for reference
|
||||||
//SpawnRoom(room, origin + (room.Size * new Vector2(i, j) * tileSize));
|
//SpawnRoom(room, origin + (room.Size * new Vector2(i, j) * tileSize));
|
||||||
spawnedScene.Spawn();
|
spawnedScene.Spawn();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue