Files
GameJamDungeon/Zennysoft.Game.Ma.Implementation/Game/GameLogic.State.cs
2025-03-09 12:24:30 -07:00

36 lines
990 B
C#

using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
namespace Zennysoft.Ma.Adapter;
public partial class GameLogic
{
[Meta]
public abstract partial record State : StateLogic<State>
{
protected State()
{
OnAttach(() =>
{
var gameRepo = Get<IGameRepo>();
gameRepo.IsPaused.Sync += OnIsPaused;
gameRepo.DoubleExpTimeStart += OnDoubleExpTimeStart;
gameRepo.Ended += OnGameEnded;
});
OnDetach(() =>
{
var gameRepo = Get<IGameRepo>();
gameRepo.IsPaused.Sync -= OnIsPaused;
gameRepo.DoubleExpTimeStart -= OnDoubleExpTimeStart;
gameRepo.Ended -= OnGameEnded;
});
}
private void OnDoubleExpTimeStart(int lengthOfTimeInSeconds) => Output(new Output.DoubleExpTimeStart(lengthOfTimeInSeconds));
private void OnGameEnded() => Output(new Output.ShowLostScreen());
public void OnIsPaused(bool isPaused) => Output(new Output.SetPauseMode(isPaused));
}
}