Overhaul game state logic to support gameplay loop
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class GameState
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta, LogicBlock(typeof(State), Diagram = true)]
|
||||
public partial record DebugMenu : State, IGet<Input.DebugButtonPressed>
|
||||
{
|
||||
public Transition On(in Input.DebugButtonPressed input)
|
||||
{
|
||||
Output(new Output.CloseDebugMenu());
|
||||
return To<InGame>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class GameState
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta, LogicBlock(typeof(State), Diagram = true)]
|
||||
public partial record FloorExitScreen : State, IGet<Input.LoadNextFloor>, IGet<Input.ReturnToMainMenu>
|
||||
{
|
||||
public FloorExitScreen()
|
||||
{
|
||||
OnAttach(() => Get<IGameRepo>().Pause());
|
||||
}
|
||||
|
||||
public Transition On(in Input.LoadNextFloor input)
|
||||
{
|
||||
Output(new Output.LoadNextFloor());
|
||||
return To<InGame>();
|
||||
}
|
||||
|
||||
public Transition On(in Input.ReturnToMainMenu input)
|
||||
{
|
||||
return To<MainMenu>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class GameState
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta, LogicBlock(typeof(State), Diagram = true)]
|
||||
public partial record GameOver : State, IGet<Input.ContinueGame>, IGet<Input.ReturnToMainMenu>
|
||||
{
|
||||
public Transition On(in Input.ContinueGame input)
|
||||
{
|
||||
Output(new Output.InitializeGame());
|
||||
return To<InGame>();
|
||||
}
|
||||
|
||||
public Transition On(in Input.ReturnToMainMenu input)
|
||||
{
|
||||
return To<MainMenu>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class GameState
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta, LogicBlock(typeof(State), Diagram = true)]
|
||||
public partial record InGame : State,
|
||||
IGet<Input.InventoryButtonPressed>,
|
||||
IGet<Input.MiniMapButtonPressed>,
|
||||
IGet<Input.PauseButtonPressed>,
|
||||
IGet<Input.DebugButtonPressed>,
|
||||
IGet<Input.FloorExitEntered>,
|
||||
IGet<Input.GameOver>
|
||||
{
|
||||
public Transition On(in Input.InventoryButtonPressed input)
|
||||
{
|
||||
Output(new Output.OpenInventoryMenu());
|
||||
return To<InventoryScreen>();
|
||||
}
|
||||
|
||||
public Transition On(in Input.MiniMapButtonPressed input)
|
||||
{
|
||||
Output(new Output.OpenMiniMap());
|
||||
return To<MiniMapScreen>();
|
||||
}
|
||||
|
||||
public Transition On(in Input.PauseButtonPressed input)
|
||||
{
|
||||
Output(new Output.OpenPauseScreen());
|
||||
return To<PauseScreen>();
|
||||
}
|
||||
|
||||
public Transition On(in Input.DebugButtonPressed input)
|
||||
{
|
||||
Output(new Output.OpenDebugMenu());
|
||||
return To<DebugMenu>();
|
||||
}
|
||||
|
||||
public Transition On(in Input.FloorExitEntered input)
|
||||
{
|
||||
Output(new Output.OpenFloorExitScreen());
|
||||
return To<FloorExitScreen>();
|
||||
}
|
||||
|
||||
public Transition On(in Input.GameOver input)
|
||||
{
|
||||
Output(new Output.GameOver());
|
||||
return To<GameOver>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class GameState
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta, LogicBlock(typeof(State), Diagram = true)]
|
||||
public partial record InventoryScreen : State, IGet<Input.InventoryButtonPressed>
|
||||
{
|
||||
public Transition On(in Input.InventoryButtonPressed input)
|
||||
{
|
||||
Output(new Output.CloseInventoryMenu());
|
||||
return To<InGame>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
using Zennysoft.Game.Abstractions;
|
||||
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class GameState
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta, LogicBlock(typeof(State), Diagram = true)]
|
||||
public partial record MainMenu : State, IGet<Input.NewGame>, IGet<Input.ContinueGame>, IGet<Input.LoadGame>
|
||||
{
|
||||
public Transition On(in Input.NewGame input)
|
||||
{
|
||||
Output(new Output.InitializeGame());
|
||||
return To<InGame>();
|
||||
}
|
||||
|
||||
public Transition On(in Input.ContinueGame input)
|
||||
{
|
||||
Output(new Output.InitializeGame());
|
||||
return To<InGame>();
|
||||
}
|
||||
|
||||
public Transition On(in Input.LoadGame input)
|
||||
{
|
||||
Output(new Output.LoadGameFromFile());
|
||||
return To<InGame>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class GameState
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta, LogicBlock(typeof(State), Diagram = true)]
|
||||
public partial record MiniMapScreen : State, IGet<Input.MiniMapButtonPressed>
|
||||
{
|
||||
public Transition On(in Input.MiniMapButtonPressed input)
|
||||
{
|
||||
Output(new Output.CloseMiniMap());
|
||||
return To<InGame>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class GameState
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta, LogicBlock(typeof(State), Diagram = true)]
|
||||
public partial record PauseScreen : State, IGet<Input.PauseButtonPressed>
|
||||
{
|
||||
public Transition On(in Input.PauseButtonPressed input)
|
||||
{
|
||||
Output(new Output.ClosePauseScreen());
|
||||
return To<InGame>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user