mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-07 14:05:54 +00:00
Room spawn collision prevention
This commit is contained in:
parent
963901f098
commit
56094e89a0
2 changed files with 29 additions and 7 deletions
|
|
@ -38,7 +38,7 @@ process_mode = 1
|
|||
y_sort_enabled = true
|
||||
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")])
|
||||
DungeonLength = 4
|
||||
DungeonLength = 6
|
||||
|
||||
[node name="CameraController" type="Camera2D" parent="."]
|
||||
process_mode = 1
|
||||
|
|
|
|||
|
|
@ -162,17 +162,39 @@ public partial class RogueliteRoomManager : Node2D
|
|||
|
||||
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
|
||||
|
||||
for (int j = 0; j < roomsInOffshot; j++)
|
||||
{
|
||||
var room = randomOffshootRoomsList.Shuffle().FirstOrDefault();
|
||||
|
||||
var offshootCoord = leftPosition - new Vector2I(room.Size.X, 0);
|
||||
|
||||
SpawnRoom(room, offshootCoord, out var spanwedOffshooot);
|
||||
var shuffledOffshootRoomsList = randomOffshootRoomsList.Shuffle().ToList();
|
||||
|
||||
_connections.Add(new RoomConnection(leftPosition, offshootCoord + new Vector2I(room.Size.X -1, 0)));
|
||||
foreach (var shuffledOffshoot in shuffledOffshootRoomsList)
|
||||
{
|
||||
var offShootCoord = leftPosition - new Vector2I(shuffledOffshoot.Size.X, 0);
|
||||
|
||||
if (!CanPlaceRoom(offShootCoord, shuffledOffshoot.Size))
|
||||
{
|
||||
GD.Print($"Could not place room {shuffledOffshoot.RoomName} {shuffledOffshoot.Size}");
|
||||
// Try next in list
|
||||
continue;
|
||||
}
|
||||
|
||||
var offshootCoord = leftPosition - new Vector2I(shuffledOffshoot.Size.X, 0);
|
||||
|
||||
SpawnRoom(shuffledOffshoot, offshootCoord, out var spawnedOffshoot);
|
||||
|
||||
leftPosition = offshootCoord;
|
||||
_connections.Add(new RoomConnection(leftPosition, offshootCoord + new Vector2I(shuffledOffshoot.Size.X -1, 0)));
|
||||
|
||||
leftPosition = offshootCoord;
|
||||
|
||||
// Stop because we spawned the room we needed to
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//var room = randomOffshootRoomsList.Shuffle().FirstOrDefault();
|
||||
|
||||
// Get a random room with the required doors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue