Files
GameJamDungeon/Zennysoft.Game.Ma.Implementation/Game/GameLogic.State.cs

40 lines
1.2 KiB
C#

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