From 6494004f64d93381768e95eec04a886ac53df838 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 24 Feb 2025 12:19:59 -0500 Subject: Created basic notifications They don't look great yet but hey we can see items being sent out or received in game now! --- ArchipelagoManager.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'ArchipelagoManager.cs') diff --git a/ArchipelagoManager.cs b/ArchipelagoManager.cs index 5e1d867..b295f2a 100644 --- a/ArchipelagoManager.cs +++ b/ArchipelagoManager.cs @@ -1,5 +1,6 @@ using Archipelago.MultiClient.Net; using Archipelago.MultiClient.Net.Enums; +using Archipelago.MultiClient.Net.MessageLog.Messages; using Archipelago.MultiClient.Net.Models; using Archipelago.MultiClient.Net.Packets; using System; @@ -22,6 +23,7 @@ namespace ManifoldGardenArchipelago try { _session = ArchipelagoSessionFactory.CreateSession(url); + _session.MessageLog.OnMessageReceived += OnMessageReceived; RoomInfoPacket roomInfoPacket = await _session.ConnectAsync(); @@ -83,6 +85,7 @@ namespace ManifoldGardenArchipelago ItemInfo item = _session.Items.AllItemsReceived[i]; string itemName = item.ItemName; Plugin.Logger.LogInfo($"Received {itemName}"); + Plugin.notificationManager.AddMessage($"Received {itemName}"); _items.Add(itemName); @@ -111,5 +114,20 @@ namespace ManifoldGardenArchipelago */ } } + + private void OnMessageReceived(LogMessage message) + { + if (message is ItemSendLogMessage itemSendLogMessage && + itemSendLogMessage.IsSenderTheActivePlayer && + !itemSendLogMessage.IsReceiverTheActivePlayer) + { + string itemName = itemSendLogMessage.Item.ItemName; + string otherPlayer = itemSendLogMessage.Receiver.Name; + + string messageText = $"Sent {itemName} to {otherPlayer}"; + + Plugin.notificationManager.AddMessage(messageText); + } + } } } -- cgit 1.4.1