Fix up item usage

This commit is contained in:
2025-03-07 18:40:14 -08:00
parent 93c04440d4
commit fe3c539a62
15 changed files with 125 additions and 65 deletions

View File

@@ -1,5 +1,7 @@
using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
using Zennysoft.Game.Abstractions;
namespace Zennysoft.Game.Ma.Implementation;
@@ -13,18 +15,29 @@ public partial class InGameUILogic
OnAttach(() =>
{
var gameRepo = Get<IGameRepo>();
gameRepo.AnnounceMessage += OnAnnounceMessage;
gameRepo.AnnounceMessageOnMainScreenEvent += OnAnnounceMessageOnMainScreen;
gameRepo.AnnounceMessageInInventoryEvent += OnAnnounceMessageInInventory;
gameRepo.RemoveItemFromInventoryEvent += OnRemoveItemFromInventory;
});
OnDetach(() =>
{
var gameRepo = Get<IGameRepo>();
gameRepo.AnnounceMessage -= OnAnnounceMessage;
gameRepo.AnnounceMessageOnMainScreenEvent -= OnAnnounceMessageOnMainScreen;
gameRepo.AnnounceMessageInInventoryEvent -= OnAnnounceMessageInInventory;
});
}
private void OnAnnounceMessage(string message)
private void OnAnnounceMessageOnMainScreen(string message)
{
Output(new Output.AnnounceMessage(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));
}
}