Files
GameJamDungeon/Zennysoft.Game.Ma.Implementation/UI/InGameUI/InGameUILogic.State.cs
2025-03-07 18:40:14 -08:00

44 lines
1.2 KiB
C#

using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
using Zennysoft.Game.Abstractions;
namespace Zennysoft.Game.Ma.Implementation;
public partial class InGameUILogic
{
[Meta]
public abstract partial record State : StateLogic<State>
{
protected State()
{
OnAttach(() =>
{
var gameRepo = Get<IGameRepo>();
gameRepo.AnnounceMessageOnMainScreenEvent += OnAnnounceMessageOnMainScreen;
gameRepo.AnnounceMessageInInventoryEvent += OnAnnounceMessageInInventory;
gameRepo.RemoveItemFromInventoryEvent += OnRemoveItemFromInventory;
});
OnDetach(() =>
{
var gameRepo = Get<IGameRepo>();
gameRepo.AnnounceMessageOnMainScreenEvent -= OnAnnounceMessageOnMainScreen;
gameRepo.AnnounceMessageInInventoryEvent -= OnAnnounceMessageInInventory;
});
}
private void OnAnnounceMessageOnMainScreen(string message)
{
Output(new Output.AnnounceMessageOnMainScreen(message));
}
private void OnAnnounceMessageInInventory(string message)
{
Output(new Output.AnnounceMessageInInventory(message));
}
private void OnRemoveItemFromInventory(IInventoryItem item) => Output(new Output.RemoveItemFromInventory(item));
}
}