Overhaul game state logic to support gameplay loop
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
using Zennysoft.Game.Abstractions;
|
||||
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class AppLogic
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta]
|
||||
public partial record GameStarted : State
|
||||
{
|
||||
public GameStarted()
|
||||
{
|
||||
|
||||
this.OnEnter(() =>
|
||||
{
|
||||
Output(new Output.SetupGameScene());
|
||||
Output(new Output.ShowGame());
|
||||
Get<IAppRepo>().OnEnterGame();
|
||||
});
|
||||
this.OnExit(() => Output(new Output.HideGame()));
|
||||
|
||||
OnAttach(() => Get<IAppRepo>().GameExited += OnGameExited);
|
||||
OnDetach(() => Get<IAppRepo>().GameExited -= OnGameExited);
|
||||
}
|
||||
|
||||
public void OnGameExited() => Input(new Input.QuitGame());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user