mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
Room spawn collision prevention
This commit is contained in:
parent
963901f098
commit
56094e89a0
2 changed files with 29 additions and 7 deletions
|
|
@ -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