Arrange debug floor situation

This commit is contained in:
2025-09-26 22:50:09 -07:00
parent 2a3c80a7af
commit 2ea96e5933
37 changed files with 137 additions and 3900 deletions

View File

@@ -17,12 +17,14 @@ public partial class PauseDebugMenu : Control, IDebugMenu
[Dependency] private IPlayer _player => this.DependOn<IPlayer>();
[Node] public Button LoadNextFloorButton { get; set; } = default!;
[Node] public OptionButton FloorSelectDropDown { get; set; } = default!;
[Node] public OptionButton SpawnItemDropDown { get; set; } = default;
[Node] public OptionButton SpawnEnemyDropDown { get; set; } = default!;
private readonly string _floorFilePath = @"res://src/map/dungeon/floors/";
private ImmutableList<InventoryItem> _spawnableItems;
private ImmutableList<string> _spawnableEnemies =
[
@@ -47,19 +49,34 @@ public partial class PauseDebugMenu : Control, IDebugMenu
public override void _Ready()
{
VisibilityChanged += PauseDebugMenu_VisibilityChanged;
LoadNextFloorButton.Pressed += LoadNextFloorButton_Pressed;
_itemDatabase = new ItemDatabase();
_spawnableItems = _itemDatabase.Items;
foreach (var item in _spawnableItems)
SpawnItemDropDown.AddItem(item.ItemName);
var folders = DirAccess.GetDirectoriesAt(_floorFilePath);
foreach (var folder in folders)
{
var files = DirAccess.GetFilesAt(_floorFilePath + folder).Where(x => x.EndsWith(".tscn"));
foreach (var file in files)
FloorSelectDropDown.AddItem(folder + "/" + file);
}
FloorSelectDropDown.AllowReselect = true;
SpawnItemDropDown.AllowReselect = true;
SpawnEnemyDropDown.AllowReselect = true;
SpawnItemDropDown.ItemSelected += SpawnItemDropDown_ItemSelected;
SpawnEnemyDropDown.ItemSelected += SpawnEnemyDropDown_ItemSelected;
FloorSelectDropDown.ItemSelected += FloorSelectDropDown_ItemSelected;
SpawnItemDropDown.ItemSelected += SpawnItemDropDown_ItemSelected;
SpawnEnemyDropDown.ItemSelected += SpawnEnemyDropDown_ItemSelected;
}
private void FloorSelectDropDown_ItemSelected(long index)
{
var sceneName = FloorSelectDropDown.GetItemText((int)index);
_map.LoadFloor(_floorFilePath + "/" + sceneName);
}
private void SpawnEnemyDropDown_ItemSelected(long index)
@@ -72,22 +89,14 @@ public partial class PauseDebugMenu : Control, IDebugMenu
private void SpawnItemDropDown_ItemSelected(long index)
{
var itemToSpawn = _spawnableItems.ElementAt((int)index);
var duplicated = itemToSpawn.Duplicate((int)DuplicateFlags.UseInstantiation) as Node3D;
AddChild(duplicated);
duplicated.GlobalPosition = new Vector3(_player.CurrentPosition.X, _player.CurrentPosition.Y + 1, _player.CurrentPosition.Z) + (-_player.CurrentBasis.Z * 2);
var itemToSpawn = _spawnableItems.ElementAt((int)index);
var duplicated = itemToSpawn.Duplicate((int)DuplicateFlags.UseInstantiation) as Node3D;
AddChild(duplicated);
duplicated.GlobalPosition = new Vector3(_player.CurrentPosition.X, _player.CurrentPosition.Y + 1, _player.CurrentPosition.Z) + (-_player.CurrentBasis.Z * 2);
}
private async void LoadNextFloorButton_Pressed()
{
await _map.LoadFloor();
}
private void PauseDebugMenu_VisibilityChanged()
{
if (Visible)
LoadNextFloorButton.GrabFocus();
else
ReleaseFocus();
}
}