Files
GameJamDungeon/Zennysoft.Game.Ma.Implementation/UI/InGameUI/state/States/InGameUI.State.InventoryOpen.cs
2025-03-07 20:42:56 -08:00

36 lines
914 B
C#

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>();
}
}
}