using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using On.RoR2;
using R2API.Utils;
using RoR2;
using RoR2.Networking;
using UnityEngine;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ItemExchangeNotifier")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+db00d670ee92516c59fcaa02a80800b7c9a2867d")]
[assembly: AssemblyProduct("ItemExchangeNotifier")]
[assembly: AssemblyTitle("ItemExchangeNotifier")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ItemExchangeNotifier;
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.MagnusMagnuson.ItemExchangeNotifier", "ItemExchangeNotifier", "1.4.2")]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class ItemExchangeNotifier : BaseUnityPlugin
{
public void Awake()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
PurchaseInteraction.OnInteractionBegin += (hook_OnInteractionBegin)delegate(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Invalid comparison between Unknown and I4
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
if (self.CanBeAffordedByInteractor(activator))
{
CostTypeIndex costType = self.costType;
if (costType - 4 <= 2)
{
CharacterBody component = ((Component)activator).GetComponent<CharacterBody>();
if (Object.op_Implicit((Object)(object)component))
{
Inventory inventory = component.inventory;
if (Object.op_Implicit((Object)(object)inventory))
{
List<ItemCount> list = new List<ItemCount>();
List<ItemCount> list2 = new List<ItemCount>();
list = getAllCurrentItems(inventory);
orig.Invoke(self, activator);
list2 = getAllCurrentItems(inventory);
if (list.Count > 0)
{
List<ItemCount> list3 = new List<ItemCount>();
foreach (ItemCount item3 in list)
{
bool flag = false;
foreach (ItemCount item4 in list2)
{
if (item3.itemIndex == item4.itemIndex)
{
flag = true;
if (item3.count > item4.count)
{
ItemCount item = new ItemCount(item3.itemIndex, item3.count - item4.count);
list3.Add(item);
}
break;
}
}
if (!flag)
{
ItemCount item2 = new ItemCount(item3.itemIndex, item3.count);
list3.Add(item2);
}
}
string tradeInMessage = constructItemsLostString(list3);
SendCustomMessage(activator, tradeInMessage);
}
}
else
{
orig.Invoke(self, activator);
}
}
else
{
orig.Invoke(self, activator);
}
}
else
{
orig.Invoke(self, activator);
}
}
};
CharacterMasterNotificationQueue.PushItemTransformNotification += new hook_PushItemTransformNotification(CharacterMasterNotificationQueue_PushItemTransformNotification);
}
private void CharacterMasterNotificationQueue_PushItemTransformNotification(orig_PushItemTransformNotification orig, CharacterMaster characterMaster, ItemIndex oldIndex, ItemIndex newIndex, TransformationType transformationType)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Expected O, but got Unknown
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Expected O, but got Unknown
orig.Invoke(characterMaster, oldIndex, newIndex, transformationType);
if (newIndex == Items.LunarSun.itemIndex)
{
NetworkConnection clientAuthorityOwner = characterMaster.networkIdentity.clientAuthorityOwner;
PickupIndex val = default(PickupIndex);
((PickupIndex)(ref val))..ctor(oldIndex);
string @string = Language.GetString(ItemCatalog.GetItemDef(oldIndex).nameToken);
string text = "#" + ColorUtility.ToHtmlStringRGB(((PickupIndex)(ref val)).GetPickupColor());
string text2 = "<color=#8296ae>Egocentrism consumed one ";
text2 = text2 + "<color=" + text + ">" + @string + "</color>.";
SimpleChatMessage val2 = new SimpleChatMessage
{
baseToken = text2
};
NetworkWriter val3 = new NetworkWriter();
val3.StartMessage((short)59);
val3.Write(((ChatMessageBase)val2).GetTypeIndex());
val3.Write((MessageBase)(object)val2);
val3.FinishMessage();
if (clientAuthorityOwner != null)
{
clientAuthorityOwner.SendWriter(val3, QosChannelIndex.chat.intVal);
}
}
}
private void SendCustomMessage(Interactor activator, string tradeInMessage)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
NetworkConnection clientAuthorityOwner = ((Component)activator).GetComponent<NetworkIdentity>().clientAuthorityOwner;
SimpleChatMessage val = new SimpleChatMessage
{
baseToken = tradeInMessage
};
NetworkWriter val2 = new NetworkWriter();
val2.StartMessage((short)59);
val2.Write(((ChatMessageBase)val).GetTypeIndex());
val2.Write((MessageBase)(object)val);
val2.FinishMessage();
if (clientAuthorityOwner != null)
{
clientAuthorityOwner.SendWriter(val2, QosChannelIndex.chat.intVal);
}
}
private string constructItemsLostString(List<ItemCount> difference)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
string text = "<color=#8296ae>You gave up ";
PickupIndex val = default(PickupIndex);
for (int i = 0; i < difference.Count; i++)
{
ItemCount itemCount = difference[i];
((PickupIndex)(ref val))..ctor(itemCount.itemIndex);
string @string = Language.GetString(ItemCatalog.GetItemDef(itemCount.itemIndex).nameToken);
string text2 = "#" + ColorUtility.ToHtmlStringRGB(((PickupIndex)(ref val)).GetPickupColor());
text = text + "x" + itemCount.count + " <color=" + text2 + ">" + @string + "</color>";
text = ((i + 1 >= difference.Count) ? (text + "</color>") : (text + ", "));
}
return text;
}
private List<ItemCount> getAllCurrentItems(Inventory inv)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
List<ItemCount> list = new List<ItemCount>();
foreach (ItemIndex item2 in inv.itemAcquisitionOrder)
{
ItemCount item = new ItemCount(item2, inv.GetItemCount(item2));
list.Add(item);
}
return list;
}
}
internal class ItemCount
{
public ItemIndex itemIndex;
public int count;
public ItemCount(ItemIndex index, int count)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
itemIndex = index;
this.count = count;
}
}