using Chickensoft.Introspection; using Chickensoft.LogicBlocks; namespace Zennysoft.Game.Ma.Implementation; public partial class GameLogic { [Meta] public abstract partial record State : StateLogic { protected State() { OnAttach(() => { var gameRepo = Get(); gameRepo.IsPaused.Sync += OnIsPaused; gameRepo.OpenInventory += OnOpenInventory; gameRepo.CloseInventory += OnCloseInventory; gameRepo.DoubleExpTimeStart += OnDoubleExpTimeStart; }); OnDetach(() => { var gameRepo = Get(); 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)); } }