mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-20 06:13:47 +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
|
y_sort_enabled = true
|
||||||
script = ExtResource("4_jtlua")
|
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")])
|
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="."]
|
[node name="CameraController" type="Camera2D" parent="."]
|
||||||
process_mode = 1
|
process_mode = 1
|
||||||
|
|
|
||||||
|
|
@ -162,17 +162,39 @@ public partial class RogueliteRoomManager : Node2D
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
for (int j = 0; j < roomsInOffshot; j++)
|
for (int j = 0; j < roomsInOffshot; j++)
|
||||||
{
|
{
|
||||||
var room = randomOffshootRoomsList.Shuffle().FirstOrDefault();
|
var shuffledOffshootRoomsList = randomOffshootRoomsList.Shuffle().ToList();
|
||||||
|
|
||||||
var offshootCoord = leftPosition - new Vector2I(room.Size.X, 0);
|
foreach (var shuffledOffshoot in shuffledOffshootRoomsList)
|
||||||
|
{
|
||||||
|
var offShootCoord = leftPosition - new Vector2I(shuffledOffshoot.Size.X, 0);
|
||||||
|
|
||||||
SpawnRoom(room, offshootCoord, out var spanwedOffshooot);
|
if (!CanPlaceRoom(offShootCoord, shuffledOffshoot.Size))
|
||||||
|
{
|
||||||
|
GD.Print($"Could not place room {shuffledOffshoot.RoomName} {shuffledOffshoot.Size}");
|
||||||
|
// Try next in list
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
_connections.Add(new RoomConnection(leftPosition, offshootCoord + new Vector2I(room.Size.X -1, 0)));
|
var offshootCoord = leftPosition - new Vector2I(shuffledOffshoot.Size.X, 0);
|
||||||
|
|
||||||
leftPosition = offshootCoord;
|
SpawnRoom(shuffledOffshoot, offshootCoord, out var spawnedOffshoot);
|
||||||
|
|
||||||
|
_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
|
// Get a random room with the required doors
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue