Files
GameJamDungeon/Zennysoft.Game.Ma.Implementation/UI/InGameUI/InGameUILogic.State.cs
2025-03-08 13:49:46 -08:00

45 lines
1.3 KiB
C#

using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
using Zennysoft.Game.Abstractions;
namespace Zennysoft.Ma.Godot.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(IInventoryItem item) => Output(new Output.RemoveItemFromInventory(item));
}
}