44 lines
1.4 KiB
C#
44 lines
1.4 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.AnnounceMessage += OnAnnounceMessage;
|
|
gameRepo.DoubleExpTimeStart += OnDoubleExpTimeStart;
|
|
});
|
|
OnDetach(() =>
|
|
{
|
|
var gameRepo = Get<IGameRepo>();
|
|
gameRepo.IsPaused.Sync -= OnIsPaused;
|
|
gameRepo.OpenInventory -= OnOpenInventory;
|
|
gameRepo.CloseInventory -= OnCloseInventory;
|
|
gameRepo.AnnounceMessage -= OnAnnounceMessage;
|
|
gameRepo.DoubleExpTimeStart -= OnDoubleExpTimeStart;
|
|
});
|
|
}
|
|
|
|
private void OnOpenInventory() => Output(new Output.OpenInventory());
|
|
|
|
private void OnCloseInventory() => Output(new Output.CloseInventory());
|
|
|
|
private void OnAnnounceMessage(string message) => Output(new Output.AnnounceMessage(message));
|
|
|
|
private void OnDoubleExpTimeStart(int lengthOfTimeInSeconds) => Output(new Output.DoubleExpTimeStart(lengthOfTimeInSeconds));
|
|
|
|
public void OnIsPaused(bool isPaused) => Output(new Output.SetPauseMode(isPaused));
|
|
}
|
|
}
|