Rework loading maps to be asynchronous, change debug menu so that its not completely pausing the game

This commit is contained in:
2025-09-26 14:05:05 -07:00
parent 578cde65cc
commit 9107b8c570
10 changed files with 164 additions and 95 deletions

View File

@@ -47,25 +47,6 @@ public partial class PauseDebugMenu : Control, IDebugMenu
public override void _Ready()
{
<<<<<<< HEAD
VisibilityChanged += PauseDebugMenu_VisibilityChanged;
LoadNextFloorButton.Pressed += LoadNextFloorButton_Pressed;
_itemDatabase = new ItemDatabase();
_spawnableItems = _itemDatabase.Items;
_spawnableEnemies = [];
foreach (var item in _spawnableItems)
SpawnItemDropDown.AddItem(item.ItemName);
_spawnableEnemies = [.. _enemyDatabase.EnemyList];
foreach (var enemy in _spawnableEnemies)
{
var tempEnemy = enemy.Instantiate<Enemy>();
SpawnEnemyDropDown.AddItem(tempEnemy.Name);
}
SpawnItemDropDown.AllowReselect = true;
SpawnEnemyDropDown.AllowReselect = true;
=======
VisibilityChanged += PauseDebugMenu_VisibilityChanged;
LoadNextFloorButton.Pressed += LoadNextFloorButton_Pressed;
_itemDatabase = new ItemDatabase();
@@ -76,7 +57,6 @@ public partial class PauseDebugMenu : Control, IDebugMenu
SpawnItemDropDown.AllowReselect = true;
SpawnEnemyDropDown.AllowReselect = true;
>>>>>>> 7e9114bfd1f6c5dd447c4c4e54a2e8ccb9f38e24
SpawnItemDropDown.ItemSelected += SpawnItemDropDown_ItemSelected;
SpawnEnemyDropDown.ItemSelected += SpawnEnemyDropDown_ItemSelected;
@@ -84,17 +64,10 @@ public partial class PauseDebugMenu : Control, IDebugMenu
private void SpawnEnemyDropDown_ItemSelected(long index)
{
<<<<<<< HEAD
var enemyToSpawn = _spawnableEnemies.ElementAt((int)index);
var loadedEnemy = enemyToSpawn.Instantiate<Enemy>();
AddChild(loadedEnemy);
loadedEnemy.GlobalPosition = new Vector3(_player.CurrentPosition.X, _player.CurrentPosition.Y + 1, _player.CurrentPosition.Z) + (-_player.CurrentBasis.Z * 2);
=======
var enemyToSpawn = _spawnableEnemies.ElementAt((int)index);
var loadedEnemy = GD.Load<PackedScene>(enemyToSpawn).Instantiate<Enemy>();
AddChild(loadedEnemy);
loadedEnemy.GlobalPosition = new Vector3(_player.CurrentPosition.X, _player.CurrentPosition.Y + 1, _player.CurrentPosition.Z) + (-_player.CurrentBasis.Z * 2);
>>>>>>> 7e9114bfd1f6c5dd447c4c4e54a2e8ccb9f38e24
}
private void SpawnItemDropDown_ItemSelected(long index)
@@ -105,9 +78,9 @@ public partial class PauseDebugMenu : Control, IDebugMenu
duplicated.GlobalPosition = new Vector3(_player.CurrentPosition.X, _player.CurrentPosition.Y + 1, _player.CurrentPosition.Z) + (-_player.CurrentBasis.Z * 2);
}
private void LoadNextFloorButton_Pressed()
private async void LoadNextFloorButton_Pressed()
{
_map.SpawnNextFloor();
await _map.LoadFloor();
}
private void PauseDebugMenu_VisibilityChanged()