diff --git a/Source/ArchipelagoManager.cs b/Source/ArchipelagoManager.cs index 11aa4a10..d54ccd4f 100644 --- a/Source/ArchipelagoManager.cs +++ b/Source/ArchipelagoManager.cs @@ -11,6 +11,7 @@ using System.Diagnostics; using System.Collections.ObjectModel; using System.Text.Json.Serialization; +using Archipelago.MultiClient.Net.MessageLog.Messages; namespace Celeste64; @@ -190,6 +191,7 @@ public async Task TryConnect() // Watch for the following events. _session.Socket.ErrorReceived += OnError; _session.Socket.PacketReceived += OnPacketReceived; + _session.MessageLog.OnMessageReceived += OnMessageReceived; _session.Items.ItemReceived += OnItemReceived; _session.Locations.CheckedLocationsUpdated += OnLocationReceived; @@ -411,6 +413,21 @@ private async Task BuildLocationDictionary() } } + private void OnMessageReceived(LogMessage message) + { + switch (message) + { + case ItemSendLogMessage: + ItemSendLogMessage itemSendMessage = (ItemSendLogMessage)message; + + if (itemSendMessage.IsRelatedToActivePlayer && !itemSendMessage.IsReceiverTheActivePlayer) + { + MessageLog.Add(new ArchipelagoMessage(message.ToString())); + } + break; + } + } + private void OnPacketReceived(ArchipelagoPacketBase packet) {