Refactor inventory menu logic
This commit is contained in:
@@ -5,5 +5,7 @@ public partial class InGameUILogic
|
||||
{
|
||||
public readonly record struct ShowMinimap;
|
||||
public readonly record struct HideMinimap;
|
||||
public readonly record struct ShowInventory;
|
||||
public readonly record struct HideInventory;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@ public partial class InGameUILogic
|
||||
public readonly record struct AnnounceMessageOnMainScreen(string Message);
|
||||
public readonly record struct AnnounceMessageInInventory(string Message);
|
||||
public readonly record struct RemoveItemFromInventory(IInventoryItem Item);
|
||||
public readonly record struct DisplayMinimap();
|
||||
public readonly record struct HideMinimap();
|
||||
public readonly record struct DisplayMinimap;
|
||||
public readonly record struct HideMinimap;
|
||||
public readonly record struct ShowInventory;
|
||||
public readonly record struct HideInventory;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,10 @@ public partial class InGameUILogic
|
||||
public partial record State
|
||||
{
|
||||
[Meta]
|
||||
public partial record Active : State, IGet<Input.ShowMinimap>
|
||||
public partial record Active : State, IGet<Input.ShowMinimap>, IGet<Input.ShowInventory>
|
||||
{
|
||||
public Transition On(in Input.ShowMinimap input) => To<MinimapOpen>();
|
||||
public Transition On(in Input.ShowInventory input) => To<InventoryOpen>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
@@ -8,7 +7,7 @@ public partial class InGameUILogic
|
||||
public partial record State
|
||||
{
|
||||
[Meta]
|
||||
public partial record MinimapOpen : State, IGet<Input.HideMinimap>
|
||||
public partial record MinimapOpen : Active, IGet<Input.HideMinimap>
|
||||
{
|
||||
public MinimapOpen()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user