Refactor minimap
This commit is contained in:
@@ -16,10 +16,6 @@ public partial class GameLogic
|
||||
|
||||
public readonly record struct CloseInventory;
|
||||
|
||||
public readonly record struct MiniMapButtonPressed;
|
||||
|
||||
public readonly record struct MiniMapButtonReleased;
|
||||
|
||||
public readonly record struct FloorExitReached;
|
||||
public readonly record struct HideFloorClearMenu;
|
||||
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public partial class GameLogic
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta]
|
||||
public partial record MinimapOpen : Playing, IGet<Input.MiniMapButtonReleased>
|
||||
{
|
||||
public MinimapOpen()
|
||||
{
|
||||
this.OnEnter(() => { Get<IGameRepo>().Pause(); Output(new Output.ShowMiniMap()); });
|
||||
this.OnExit(() => { Get<IGameRepo>().Resume(); Output(new Output.HideMiniMap()); });
|
||||
}
|
||||
|
||||
public Transition On(in Input.MiniMapButtonReleased input) => To<Playing>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ public partial class GameLogic
|
||||
[Meta]
|
||||
public partial record Playing : State,
|
||||
IGet<Input.OpenInventory>,
|
||||
IGet<Input.MiniMapButtonPressed>,
|
||||
IGet<Input.GameOver>,
|
||||
IGet<Input.AskForTeleport>,
|
||||
IGet<Input.PauseGame>,
|
||||
@@ -25,7 +24,6 @@ public partial class GameLogic
|
||||
|
||||
public Transition On(in Input.OpenInventory input) => To<InventoryOpened>();
|
||||
|
||||
public Transition On(in Input.MiniMapButtonPressed input) => To<MinimapOpen>();
|
||||
|
||||
public Transition On(in Input.GameOver input) => To<Quit>();
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
public partial class InGameUILogic
|
||||
{
|
||||
public static class Input
|
||||
{
|
||||
public readonly record struct ShowMinimap;
|
||||
public readonly record struct HideMinimap;
|
||||
}
|
||||
}
|
||||
@@ -8,5 +8,7 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ public partial class InGameUILogic
|
||||
public partial record State
|
||||
{
|
||||
[Meta]
|
||||
public partial record Active : State
|
||||
public partial record Active : State, IGet<Input.ShowMinimap>
|
||||
{
|
||||
|
||||
public Transition On(in Input.ShowMinimap input) => To<MinimapOpen>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Game.Ma.Implementation;
|
||||
|
||||
public partial class InGameUILogic
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta]
|
||||
public partial record MinimapOpen : State, IGet<Input.HideMinimap>
|
||||
{
|
||||
public MinimapOpen()
|
||||
{
|
||||
OnAttach(() => { Get<IGameRepo>().Pause(); Output(new Output.DisplayMinimap()); });
|
||||
OnDetach(() => { Get<IGameRepo>().Resume(); Output(new Output.HideMinimap()); });
|
||||
}
|
||||
|
||||
public Transition On(in Input.HideMinimap input) => To<Active>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user