Block on events where the inventory will close after, block in general to prevent inventory scrolling during inventory message display

This commit is contained in:
2026-03-03 18:59:09 -08:00
parent 7b6ca68e65
commit ff82f51451
2 changed files with 21 additions and 4 deletions

View File

@@ -235,13 +235,13 @@ public partial class Game : Node3D, IGame
switch (item)
{
case BoxItem boxItem:
EnactBoxItemEffects(boxItem);
await EnactBoxItemEffects(boxItem);
break;
case ConsumableItem consumableItem:
EnactConsumableItemEffects(consumableItem);
break;
case EffectItem effectItem:
EnactEffectItemEffects(effectItem);
await EnactEffectItemEffects(effectItem);
break;
}
RemoveItemOrSubtractFromItemCount(item);
@@ -465,13 +465,14 @@ public partial class Game : Node3D, IGame
private void FinishedLoadingSaveFile() => EmitSignal(SignalName.SaveFileLoaded);
private void EnactBoxItemEffects(BoxItem boxItem)
private async Task EnactBoxItemEffects(BoxItem boxItem)
{
switch (boxItem.ItemTag)
{
case ItemTag.DamagesPlayer:
_effectService.DamagesPlayer(boxItem.Stats.DamageToPlayer);
InventoryEventNotification.Invoke($"{boxItem.Stats.DamageToPlayer} damage done to self.");
await ToSignal(GetTree().CreateTimer(2f), "timeout");
GameRepo.CloseInventory();
break;
case ItemTag.ContainsAccessory:
@@ -560,6 +561,7 @@ public partial class Game : Node3D, IGame
ThrowItem(item);
_player.Inventory.Items.Clear();
InventoryEventNotification.Invoke($"All items have been ejected from inventory.");
await ToSignal(GetTree().CreateTimer(2f), "timeout");
GameRepo.CloseInventory();
break;
}
@@ -600,7 +602,7 @@ public partial class Game : Node3D, IGame
}
}
private void EnactEffectItemEffects(EffectItem effectItem)
private async Task EnactEffectItemEffects(EffectItem effectItem)
{
switch (effectItem.UsableItemTag)
{
@@ -608,22 +610,26 @@ public partial class Game : Node3D, IGame
_effectService.TeleportEnemiesToCurrentRoom(GetTree().GetNodesInGroup("enemy").OfType<IEnemy>().ToList());
SfxDatabase.Instance.Play(SoundEffect.RecallEnemies);
InventoryEventNotification.Invoke($"All enemies have been summoned.");
await ToSignal(GetTree().CreateTimer(2f), "timeout");
GameRepo.CloseInventory();
_player.PlaySpellFX(SpellFXEnum.DivinityRecall);
break;
case UsableItemTag.KillHalfEnemiesInRoom:
_effectService.KillHalfEnemiesInRoom();
InventoryEventNotification.Invoke($"The balance has been achieved.");
await ToSignal(GetTree().CreateTimer(2f), "timeout");
GameRepo.CloseInventory();
break;
case UsableItemTag.TurnAllEnemiesIntoHealingItem:
_effectService.TurnAllEnemiesInRoomIntoHealingItem();
InventoryEventNotification.Invoke($"Enemies in current room have been converted.");
await ToSignal(GetTree().CreateTimer(2f), "timeout");
GameRepo.CloseInventory();
break;
case UsableItemTag.HealsAllInRoomToMaxHP:
_effectService.HealAllEnemiesAndPlayerInRoomToFull();
InventoryEventNotification.Invoke($"All present have been renewed.");
await ToSignal(GetTree().CreateTimer(2f), "timeout");
GameRepo.CloseInventory();
break;
case UsableItemTag.AbsorbHPFromAllEnemiesInRoom:
@@ -631,11 +637,13 @@ public partial class Game : Node3D, IGame
if (hpAbsorbed == 0)
{
InventoryEventNotification.Invoke($"No enemies present to absorb from or invalid location.");
await ToSignal(GetTree().CreateTimer(2f), "timeout");
GameRepo.CloseInventory();
return;
}
_player.HealthComponent.Heal(hpAbsorbed);
InventoryEventNotification.Invoke($"Enemies have surrendered {hpAbsorbed} to you.");
await ToSignal(GetTree().CreateTimer(2f), "timeout");
GameRepo.CloseInventory();
_player.PlaySpellFX(SpellFXEnum.Kyuuketsuki);
break;
@@ -643,11 +651,13 @@ public partial class Game : Node3D, IGame
case UsableItemTag.DealElementalDamageToAllEnemiesInRoom:
_effectService.DealElementalDamageToAllEnemiesInRoom(effectItem.Stats.ElementalDamageType);
InventoryEventNotification.Invoke($"All enemies present have taken {effectItem.Stats.ElementalDamageType} to you.");
await ToSignal(GetTree().CreateTimer(2f), "timeout");
GameRepo.CloseInventory();
break;
case UsableItemTag.SwapHPAndVT:
_effectService.SwapHPandVT();
InventoryEventNotification.Invoke($"HP and VT have been traded.");
await ToSignal(GetTree().CreateTimer(2f), "timeout");
GameRepo.CloseInventory();
break;
case UsableItemTag.RaiseCurrentWeaponAttack:
@@ -696,6 +706,7 @@ public partial class Game : Node3D, IGame
InventoryEventNotification.Invoke($"Moved to exit room.");
else
InventoryEventNotification.Invoke($"Unable to locate exit room.");
await ToSignal(GetTree().CreateTimer(2f), "timeout");
GameRepo.CloseInventory();
break;
case UsableItemTag.IncreaseAttack:

View File

@@ -81,6 +81,12 @@ public partial class InventoryMenu : Control, IInventoryMenu
public override void _Input(InputEvent @event)
{
if (_blocking)
{
GetViewport().SetInputAsHandled();
return;
}
var validSelectableItems = _player.Inventory.Items.ToList();
if (Input.IsActionJustPressed(GameInputs.MoveUp) && _currentlySelected != null && _currentlySelected.Item.Value != validSelectableItems.First())