Refactoring game logic

This commit is contained in:
2025-03-07 12:05:20 -08:00
parent e7ef669c29
commit c3bfab5f53
13 changed files with 127 additions and 42 deletions

View File

@@ -14,14 +14,30 @@ public partial class GameLogic
{
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));
}
}