Files
GameJamDungeon/Zennysoft.Game.Ma.Implementation/UI/InGameUI/InGameUILogic.State.cs
2025-03-09 12:24:30 -07:00

44 lines
1.3 KiB
C#

using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
namespace Zennysoft.Ma.Adapter;
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;
gameRepo.RemoveItemFromInventoryEvent -= OnRemoveItemFromInventory;
});
}
private void OnAnnounceMessageOnMainScreen(string message)
{
Output(new Output.AnnounceMessageOnMainScreen(message));
}
private void OnAnnounceMessageInInventory(string message)
{
Output(new Output.AnnounceMessageInInventory(message));
}
private void OnRemoveItemFromInventory(InventoryItem item) => Output(new Output.RemoveItemFromInventory(item));
}
}