summary refs log tree commit diff stats
path: root/ArchipelagoManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ArchipelagoManager.cs')
-rw-r--r--ArchipelagoManager.cs18
1 files changed, 18 insertions, 0 deletions
diff --git a/ArchipelagoManager.cs b/ArchipelagoManager.cs index 5e1d867..b295f2a 100644 --- a/ArchipelagoManager.cs +++ b/ArchipelagoManager.cs
@@ -1,5 +1,6 @@
1using Archipelago.MultiClient.Net; 1using Archipelago.MultiClient.Net;
2using Archipelago.MultiClient.Net.Enums; 2using Archipelago.MultiClient.Net.Enums;
3using Archipelago.MultiClient.Net.MessageLog.Messages;
3using Archipelago.MultiClient.Net.Models; 4using Archipelago.MultiClient.Net.Models;
4using Archipelago.MultiClient.Net.Packets; 5using Archipelago.MultiClient.Net.Packets;
5using System; 6using System;
@@ -22,6 +23,7 @@ namespace ManifoldGardenArchipelago
22 try 23 try
23 { 24 {
24 _session = ArchipelagoSessionFactory.CreateSession(url); 25 _session = ArchipelagoSessionFactory.CreateSession(url);
26 _session.MessageLog.OnMessageReceived += OnMessageReceived;
25 27
26 RoomInfoPacket roomInfoPacket = await _session.ConnectAsync(); 28 RoomInfoPacket roomInfoPacket = await _session.ConnectAsync();
27 29
@@ -83,6 +85,7 @@ namespace ManifoldGardenArchipelago
83 ItemInfo item = _session.Items.AllItemsReceived[i]; 85 ItemInfo item = _session.Items.AllItemsReceived[i];
84 string itemName = item.ItemName; 86 string itemName = item.ItemName;
85 Plugin.Logger.LogInfo($"Received {itemName}"); 87 Plugin.Logger.LogInfo($"Received {itemName}");
88 Plugin.notificationManager.AddMessage($"Received {itemName}");
86 89
87 _items.Add(itemName); 90 _items.Add(itemName);
88 91
@@ -111,5 +114,20 @@ namespace ManifoldGardenArchipelago
111 */ 114 */
112 } 115 }
113 } 116 }
117
118 private void OnMessageReceived(LogMessage message)
119 {
120 if (message is ItemSendLogMessage itemSendLogMessage &&
121 itemSendLogMessage.IsSenderTheActivePlayer &&
122 !itemSendLogMessage.IsReceiverTheActivePlayer)
123 {
124 string itemName = itemSendLogMessage.Item.ItemName;
125 string otherPlayer = itemSendLogMessage.Receiver.Name;
126
127 string messageText = $"Sent {itemName} to {otherPlayer}";
128
129 Plugin.notificationManager.AddMessage(messageText);
130 }
131 }
114 } 132 }
115} 133}