Refactor inventory menu logic

This commit is contained in:
2025-03-07 20:42:56 -08:00
parent d30fa35546
commit 8a61104868
19 changed files with 94 additions and 160 deletions

View File

@@ -0,0 +1,35 @@
using Chickensoft.Introspection;
namespace Zennysoft.Game.Ma.Implementation;
public partial class InGameUILogic
{
public partial record State
{
[Meta]
public partial record InventoryOpen : Active, IGet<Input.HideInventory>
{
public InventoryOpen()
{
OnAttach(() =>
{
var gameRepo = Get<IGameRepo>();
gameRepo.CloseInventoryEvent += OnCloseInventoryEvent;
gameRepo.Pause();
Output(new Output.ShowInventory());
});
OnDetach(() =>
{
var gameRepo = Get<IGameRepo>();
gameRepo.Resume();
gameRepo.CloseInventoryEvent -= OnCloseInventoryEvent;
Output(new Output.HideInventory());
});
}
private void OnCloseInventoryEvent() => Input(new Input.HideInventory());
public Transition On(in Input.HideInventory input) => To<Active>();
}
}
}