Massive refactor (inventory menu still a little broken but its Good Enough)

This commit is contained in:
2024-09-12 02:24:14 -07:00
parent 149c8d9571
commit b4662a0c7b
94 changed files with 1066 additions and 825 deletions

View File

@@ -2,12 +2,16 @@ using Chickensoft.AutoInject;
using Chickensoft.GodotNodeInterfaces;
using Chickensoft.Introspection;
using Godot;
using System.Collections.Generic;
using System.Linq;
public interface IDungeonFloor : INode3D
{
void InitializeDungeon();
public Vector3 GetPlayerSpawnPoint();
public Vector3 GetTeleportSpawnPoint();
}
[Meta(typeof(IAutoNode))]
@@ -17,13 +21,34 @@ public partial class DungeonFloor : Node3D, IDungeonFloor
[Node] public GodotObject DungeonGenerator { get; set; } = default!;
internal List<IDungeonRoom> Rooms { get; private set; }
public void InitializeDungeon()
{
Rooms = new List<IDungeonRoom>();
DungeonGenerator.Call("generate");
Rooms = FindAllDungeonRooms(GetChildren().ToList(), Rooms);
}
public Vector3 GetPlayerSpawnPoint()
{
return Vector3.Zero;
return Rooms.First().PlayerSpawn.GlobalPosition;
}
public Vector3 GetTeleportSpawnPoint()
{
return Rooms.First().TeleportSpawn.GlobalPosition;
}
private List<IDungeonRoom> FindAllDungeonRooms(List<Node> nodesToSearch, List<IDungeonRoom> roomsFound)
{
if (nodesToSearch.Count == 0)
return roomsFound;
foreach (var node in nodesToSearch)
if (node is IDungeonRoom dungeonRoom)
roomsFound.Add(dungeonRoom);
return FindAllDungeonRooms(nodesToSearch.SelectMany(x => x.GetChildren()).ToList(), roomsFound);
}
}

View File

@@ -13,6 +13,8 @@ public partial class Overworld : Node3D, IDungeonFloor
[Node] public Marker3D PlayerSpawnPoint { get; set; } = default!;
[Node] public Marker3D ExitSpawnPoint { get; set; } = default!;
public void InitializeDungeon()
{
GameRepo.SetPlayerGlobalPosition(PlayerSpawnPoint.GlobalPosition);
@@ -22,4 +24,9 @@ public partial class Overworld : Node3D, IDungeonFloor
{
return PlayerSpawnPoint.GlobalPosition;
}
public Vector3 GetTeleportSpawnPoint()
{
return ExitSpawnPoint.GlobalPosition;
}
}