Starts of offshoots

This commit is contained in:
Marco 2025-04-18 17:32:12 +02:00
commit 9331876637
2 changed files with 39 additions and 8 deletions

View file

@ -96,18 +96,25 @@ public partial class RogueliteRoomManager : Node2D
_connections.Add(new RoomConnection(origin, currentPos + new Vector2I(0, 1)));
Vector2I nextPos;
var offshoots = new List<OffshootType>()
{
OffshootType.Item,
OffshootType.Secret,
OffshootType.Shop,
OffshootType.Key
};
var shuffledOffshoots = offshoots.Shuffle().ToList();
int currentOffshoot = 0;
for (int i = 0; i < DungeonLength; i++)
{
nextPos = currentPos + new Vector2I(0, 1);
//var roomToSpawn = Rooms.Where(x => x.Type == RoomType.Regular).PickRandom();
var roomToSpawn = randomRoomsList[i];
// First pick a random door on the from room
//var doorOffset = Math.Min(0, GD.RandRange(0, currentRoom.Size.X - 1));
// We're already in the new room position, we do not care about previous anymore
var offset = 0;
// Place it at a random X position
@ -142,10 +149,25 @@ public partial class RogueliteRoomManager : Node2D
// nextPos is now the end of the room at the current exit
_connections.Add(new RoomConnection(nextPos, nextPos + new Vector2I(0, 1)));
//+ new Vector2I(0, roomToSpawn.Size.Y -1)
// Reset X offset
//nextPos = new Vector2I(0, nextPos.Y);
// Spawn offshoot here
var offshootToSpawn = shuffledOffshoots[currentOffshoot % shuffledOffshoots.Count()];
int roomsInOffshot = GD.RandRange(0, MaxBranchLength);
for (int j = 0; j < roomsInOffshot; j++)
{
// Get a random door on right or left side
// spawn
// Add path
// Move cursor
// if last room generate final room
// Continue
}
// Offshoot over
currentPos = nextPos;
}