using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using On.RoR2;
using On.RoR2.UI;
using RoR2;
using RoR2.UI;
using UnityEngine;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ItemStats")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+b4a9ebe5c241fc9b030d57fbb8d377d9f5d19187")]
[assembly: AssemblyProduct("ItemStats")]
[assembly: AssemblyTitle("ItemStats")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ItemStats
{
[BepInPlugin("com.Moffein.ItemStats", "ItemStats", "1.3.2")]
public class ItemStats : BaseUnityPlugin
{
public static List<ItemDef> IgnoredItems = new List<ItemDef>();
public static List<EquipmentDef> IgnoredEquipment = new List<EquipmentDef>();
public static bool pingDetails = true;
public static bool pingDetailsVerbose = false;
public static float pingDetailsDuration = 3f;
public static bool pingNotif = true;
public static bool pingChat = false;
public static bool detailedHover = true;
public static bool detailedPickup = true;
public void Awake()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Expected O, but got Unknown
ReadConfig();
if (detailedHover)
{
ItemIcon.SetItemIndex += new hook_SetItemIndex(ItemIcon_SetItemIndex);
EquipmentIcon.Update += new hook_Update(EquipmentIcon_Update);
}
if (detailedPickup)
{
GenericNotification.SetItem += new hook_SetItem(GenericNotification_SetItem);
GenericNotification.SetEquipment += new hook_SetEquipment(GenericNotification_SetEquipment);
}
if (pingDetails)
{
PingerController.SetCurrentPing += new hook_SetCurrentPing(PingerController_SetCurrentPing);
}
}
public void ReadConfig()
{
detailedHover = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Detailed Hover", true, "Show full item description when hovering over the item icon.").Value;
detailedPickup = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Detailed Pickup", true, "Show full item description when picking up the item.").Value;
pingDetailsDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Ping Details - Notification Duration", 4f, "How long the item notification lasts for.").Value;
pingDetails = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Ping Details", true, "Pinging an item shows its description.").Value;
pingNotif = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Ping Details - Show as Notification", true, "Item description shows as a notification on the HUD.").Value;
pingChat = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Ping Details - Show as Chat Message", false, "Item description shows as a chat message.").Value;
pingDetailsVerbose = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Ping Details - Show as Chat Message - Show Full Description", false, "Chat messages show the full item description.").Value;
if (!pingChat && !pingNotif)
{
pingDetails = false;
}
}
private void PingerController_SetCurrentPing(orig_SetCurrentPing orig, PingerController self, PingInfo newPingInfo)
{
//IL_0003: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Expected O, but got Unknown
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Expected O, but got Unknown
orig.Invoke(self, newPingInfo);
if (!((NetworkBehaviour)self).hasAuthority || !Object.op_Implicit((Object)(object)((PingInfo)(ref newPingInfo)).targetGameObject))
{
return;
}
PickupDef val = null;
GenericPickupController component = ((PingInfo)(ref newPingInfo)).targetGameObject.GetComponent<GenericPickupController>();
if (Object.op_Implicit((Object)(object)component))
{
val = PickupCatalog.GetPickupDef(component.pickupIndex);
}
else
{
ShopTerminalBehavior component2 = ((PingInfo)(ref newPingInfo)).targetGameObject.GetComponent<ShopTerminalBehavior>();
if (Object.op_Implicit((Object)(object)component2) && !component2.pickupIndexIsHidden && !component2.Networkhidden && Object.op_Implicit((Object)(object)component2.pickupDisplay))
{
val = PickupCatalog.GetPickupDef(component2.pickupIndex);
}
}
if (val == null)
{
return;
}
ItemDef itemDef = ItemCatalog.GetItemDef(val.itemIndex);
if (Object.op_Implicit((Object)(object)itemDef))
{
if (pingChat)
{
Chat.AddMessage((ChatMessageBase)new SimpleChatMessage
{
baseToken = ((pingDetailsVerbose && !IgnoredItems.Contains(itemDef)) ? itemDef.descriptionToken : itemDef.pickupToken)
});
}
if (pingNotif)
{
CharacterMaster component3 = ((Component)self).gameObject.GetComponent<CharacterMaster>();
if (Object.op_Implicit((Object)(object)component3))
{
PushItemNotificationDuration(component3, itemDef.itemIndex, pingDetailsDuration);
}
}
return;
}
EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(val.equipmentIndex);
if (!Object.op_Implicit((Object)(object)equipmentDef))
{
return;
}
if (pingChat)
{
Chat.AddMessage((ChatMessageBase)new SimpleChatMessage
{
baseToken = ((pingDetailsVerbose && !IgnoredEquipment.Contains(equipmentDef)) ? equipmentDef.descriptionToken : equipmentDef.pickupToken)
});
}
if (pingNotif)
{
CharacterMaster component4 = ((Component)self).gameObject.GetComponent<CharacterMaster>();
if (Object.op_Implicit((Object)(object)component4))
{
PushEquipmentNotificationDuration(component4, equipmentDef.equipmentIndex, pingDetailsDuration);
}
}
}
public static void GenericNotification_SetItem(orig_SetItem orig, GenericNotification self, ItemDef itemDef)
{
orig.Invoke(self, itemDef);
if (!IgnoredItems.Contains(itemDef))
{
if (!Language.IsTokenInvalid(itemDef.descriptionToken))
{
self.descriptionText.token = itemDef.descriptionToken;
}
else
{
self.descriptionText.token = itemDef.pickupToken;
}
}
}
private void GenericNotification_SetEquipment(orig_SetEquipment orig, GenericNotification self, EquipmentDef equipmentDef)
{
orig.Invoke(self, equipmentDef);
if (!IgnoredEquipment.Contains(equipmentDef))
{
if (!Language.IsTokenInvalid(equipmentDef.descriptionToken))
{
self.descriptionText.token = equipmentDef.descriptionToken;
}
else
{
self.descriptionText.token = equipmentDef.pickupToken;
}
}
}
public static void ItemIcon_SetItemIndex(orig_SetItemIndex orig, ItemIcon self, ItemIndex newItemIndex, int newItemCount)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self, newItemIndex, newItemCount);
ItemDef itemDef = ItemCatalog.GetItemDef(newItemIndex);
if (Object.op_Implicit((Object)(object)itemDef) && Object.op_Implicit((Object)(object)self.tooltipProvider) && !IgnoredItems.Contains(itemDef))
{
if (!Language.IsTokenInvalid(itemDef.descriptionToken))
{
self.tooltipProvider.overrideBodyText = Language.GetString(itemDef.descriptionToken);
}
else
{
self.tooltipProvider.overrideBodyText = itemDef.pickupToken;
}
}
}
private void EquipmentIcon_Update(orig_Update orig, EquipmentIcon self)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
if (!self.hasEquipment || !Object.op_Implicit((Object)(object)self.tooltipProvider) || !Object.op_Implicit((Object)(object)self.targetEquipmentSlot))
{
return;
}
EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(self.targetEquipmentSlot.equipmentIndex);
if (Object.op_Implicit((Object)(object)equipmentDef) && !IgnoredEquipment.Contains(equipmentDef))
{
if (!Language.IsTokenInvalid(equipmentDef.descriptionToken))
{
self.tooltipProvider.overrideBodyText = Language.GetString(equipmentDef.descriptionToken);
}
else
{
self.tooltipProvider.overrideBodyText = Language.GetString(equipmentDef.pickupToken);
}
}
}
public static void PushItemNotificationDuration(CharacterMaster characterMaster, ItemIndex itemIndex, float duration)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Invalid comparison between Unknown and I4
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
if (!((NetworkBehaviour)characterMaster).hasAuthority)
{
Debug.LogError((object)("Can't PushItemNotification for " + Util.GetBestMasterName(characterMaster) + " because they aren't local."));
return;
}
CharacterMasterNotificationQueue notificationQueueForMaster = CharacterMasterNotificationQueue.GetNotificationQueueForMaster(characterMaster);
if (Object.op_Implicit((Object)(object)notificationQueueForMaster) && (int)itemIndex != -1)
{
ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex);
if (!((Object)(object)itemDef == (Object)null) && !itemDef.hidden)
{
notificationQueueForMaster.PushNotification(new NotificationInfo((object)ItemCatalog.GetItemDef(itemIndex), (TransformationInfo)null), duration);
}
}
}
public static void PushEquipmentNotificationDuration(CharacterMaster characterMaster, EquipmentIndex equipmentIndex, float duration)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Invalid comparison between Unknown and I4
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
if (!((NetworkBehaviour)characterMaster).hasAuthority)
{
Debug.LogError((object)("Can't PushEquipmentNotification for " + Util.GetBestMasterName(characterMaster) + " because they aren't local."));
return;
}
CharacterMasterNotificationQueue notificationQueueForMaster = CharacterMasterNotificationQueue.GetNotificationQueueForMaster(characterMaster);
if (Object.op_Implicit((Object)(object)notificationQueueForMaster) && (int)equipmentIndex != -1)
{
notificationQueueForMaster.PushNotification(new NotificationInfo((object)EquipmentCatalog.GetEquipmentDef(equipmentIndex), (TransformationInfo)null), duration);
}
}
}
}
namespace R2API.Utils
{
[AttributeUsage(AttributeTargets.Assembly)]
public class ManualNetworkRegistrationAttribute : Attribute
{
}
}