Refactor inventory menu logic
This commit is contained in:
@@ -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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user