Remove SimpleDungeons plugin
This commit is contained in:
@@ -12,8 +12,6 @@ public partial class DungeonFloor : Node3D, IDungeonFloor
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Node] public GodotObject DungeonGenerator { get; set; } = default!;
|
||||
|
||||
[Node] public EnemyDatabase EnemyDatabase { get; set; } = default!;
|
||||
|
||||
private Transform3D _playerSpawnPoint;
|
||||
@@ -24,40 +22,37 @@ public partial class DungeonFloor : Node3D, IDungeonFloor
|
||||
|
||||
public void InitializeDungeon()
|
||||
{
|
||||
Rooms = [];
|
||||
Rooms = FindAllDungeonRooms([.. GetChildren()], Rooms);
|
||||
_playerSpawnPoint = RandomizePlayerSpawnPoint();
|
||||
var monsterRooms = Rooms.OfType<MonsterRoom>();
|
||||
foreach (var room in monsterRooms)
|
||||
room.SpawnEnemies(EnemyDatabase);
|
||||
DungeonGenerator.EmitSignal("done_generating");
|
||||
Rooms = [];
|
||||
Rooms = FindAllDungeonRooms([.. GetChildren()], Rooms);
|
||||
_playerSpawnPoint = RandomizePlayerSpawnPoint();
|
||||
var monsterRooms = Rooms.OfType<MonsterRoom>();
|
||||
foreach (var room in monsterRooms)
|
||||
room.SpawnEnemies(EnemyDatabase);
|
||||
}
|
||||
|
||||
public Transform3D GetPlayerSpawnPoint() => new Transform3D(_playerSpawnPoint.Basis, new Vector3(_playerSpawnPoint.Origin.X, -1.75f, _playerSpawnPoint.Origin.Z));
|
||||
|
||||
private Transform3D RandomizePlayerSpawnPoint()
|
||||
{
|
||||
var randomSpawnLocations = Rooms
|
||||
.OfType<MonsterRoom>()
|
||||
.Select(x => x.PlayerSpawn);
|
||||
var godotCollection = new Godot.Collections.Array<Marker3D>(randomSpawnLocations);
|
||||
var result = godotCollection.PickRandom();
|
||||
return result.GlobalTransform;
|
||||
var randomSpawnLocations = Rooms
|
||||
.OfType<MonsterRoom>()
|
||||
.Select(x => x.PlayerSpawn);
|
||||
var godotCollection = new Godot.Collections.Array<Marker3D>(randomSpawnLocations);
|
||||
var result = godotCollection.PickRandom();
|
||||
return result.GlobalTransform;
|
||||
}
|
||||
|
||||
private static ImmutableList<IDungeonRoom> FindAllDungeonRooms(List<Node> nodesToSearch, ImmutableList<IDungeonRoom> roomsFound)
|
||||
{
|
||||
if (nodesToSearch.Count == 0)
|
||||
return roomsFound;
|
||||
if (nodesToSearch.Count == 0)
|
||||
return roomsFound;
|
||||
|
||||
foreach (var node in nodesToSearch)
|
||||
{
|
||||
if (node is IDungeonRoom dungeonRoom)
|
||||
roomsFound = roomsFound.Add(dungeonRoom);
|
||||
if (node.HasSignal("dungeon_done_generating"))
|
||||
node.EmitSignal("dungeon_done_generating");
|
||||
}
|
||||
foreach (var node in nodesToSearch)
|
||||
{
|
||||
if (node is IDungeonRoom dungeonRoom)
|
||||
roomsFound = roomsFound.Add(dungeonRoom);
|
||||
}
|
||||
|
||||
return FindAllDungeonRooms(nodesToSearch.SelectMany(x => x.GetChildren()).ToList(), roomsFound);
|
||||
return FindAllDungeonRooms([.. nodesToSearch.SelectMany(x => x.GetChildren())], roomsFound);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user