using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using Microsoft.CodeAnalysis; using RoR2; using UnityEngine; [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("BubbetsRamenCompat")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BubbetsRamenCompat")] [assembly: AssemblyTitle("BubbetsRamenCompat")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BubbetsRamenCompat { [BepInPlugin("local.bubbetsramencompat", "Bubbets Items - Risk Of Ramen Void Lunar Compat", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "local.bubbetsramencompat"; public const string PluginName = "Bubbets Items - Risk Of Ramen Void Lunar Compat"; public const string PluginVersion = "1.0.1"; private const string RiskOfRamenGuid = "com.Ramen.RiskOfRamen"; private const string BubbetsItemsGuid = "bubbet.bubbetsitems"; private bool applied; private void Awake() { RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(ApplyCompatibility)); } private void OnDestroy() { RoR2Application.onLoad = (Action)Delegate.Remove(RoR2Application.onLoad, new Action(ApplyCompatibility)); } private void ApplyCompatibility() { //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_0496: Expected O, but got Unknown //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Expected O, but got Unknown //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) if (applied) { return; } applied = true; try { Assembly assembly = ((object)Chainloader.PluginInfos["com.Ramen.RiskOfRamen"].Instance).GetType().Assembly; Assembly assembly2 = ((object)Chainloader.PluginInfos["bubbet.bubbetsitems"].Instance).GetType().Assembly; Type type = assembly.GetType("RiskOfRamen.RiskOfRamenContent", throwOnError: true); Type? type2 = assembly.GetType("RiskOfRamen.RiskOfRamenMain", throwOnError: true); Type type3 = assembly2.GetType("BubbetsItems.BubbetsItemsPlugin", throwOnError: true); Type type4 = assembly2.GetType("BubbetsItems.ItemBase", throwOnError: true); FieldInfo field = type.GetField("_corruptibleLunars", BindingFlags.Static | BindingFlags.Public); FieldInfo field2 = type2.GetField("corruptibleLunar", BindingFlags.Static | BindingFlags.Public); MethodInfo method = type2.GetMethod("GetSpecificItemPayCost", BindingFlags.Static | BindingFlags.Public); MethodInfo method2 = type2.GetMethod("GetSpecificItemIsAffordable", BindingFlags.Static | BindingFlags.Public); FieldInfo field3 = type3.GetField("VoidLunarTier", BindingFlags.Static | BindingFlags.Public); PropertyInfo property = type4.GetProperty("Items", BindingFlags.Static | BindingFlags.Public); FieldInfo field4 = type4.GetField("ItemDef", BindingFlags.Instance | BindingFlags.Public); FieldInfo field5 = type4.GetField("voidPairing", BindingFlags.Instance | BindingFlags.Public); if (field == null || field2 == null || method == null || method2 == null || field3 == null || property == null || field4 == null || field5 == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Compatibility failed: one or more expected public fields/methods were not found."); return; } object? value = field3.GetValue(null); ItemTierDef val = (ItemTierDef)((value is ItemTierDef) ? value : null); if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Compatibility failed: Bubbets Items Void Lunar tier was not initialized."); return; } Pair[] array = field.GetValue(null) as Pair[]; if (array == null) { array = Array.Empty(); } Dictionary dictionary = new Dictionary(); Pair[] array2 = array; foreach (Pair val2 in array2) { if (IsCatalogued(val2.itemDef1) && IsCatalogued(val2.itemDef2)) { dictionary[val2.itemDef1.itemIndex] = val2; } } if (!(property.GetValue(null, null) is IEnumerable enumerable)) { ((BaseUnityPlugin)this).Logger.LogError((object)"Compatibility failed: Bubbets Items item list was unavailable."); return; } List list = new List(); foreach (object item in enumerable) { if (item == null) { continue; } object? value2 = field4.GetValue(item); ItemDef val3 = (ItemDef)((value2 is ItemDef) ? value2 : null); if (!IsCatalogued(val3) || val3.tier != val.tier) { continue; } object value3 = field5.GetValue(item); if (value3 == null) { continue; } FieldInfo field6 = value3.GetType().GetField("ItemDefs", BindingFlags.Instance | BindingFlags.Public); ItemDef[] array3 = ((field6 != null) ? (field6.GetValue(value3) as ItemDef[]) : null); if (array3 == null) { continue; } ItemDef[] array4 = array3; foreach (ItemDef val4 in array4) { if (IsCatalogued(val4)) { list.Add(new Pair { itemDef1 = val4, itemDef2 = val3 }); } } } int num = 0; int num2 = 0; foreach (Pair item2 in list) { if (dictionary.TryGetValue(item2.itemDef1.itemIndex, out var value4)) { num2++; ((BaseUnityPlugin)this).Logger.LogWarning((object)("Not replacing enabled Risk Of Ramen Font conversion " + GetItemName(value4.itemDef1) + " -> " + GetItemName(value4.itemDef2) + " with Bubbets conversion -> " + GetItemName(item2.itemDef2) + ".")); } else { dictionary.Add(item2.itemDef1.itemIndex, item2); num++; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Added Contamination Font conversion: " + GetItemName(item2.itemDef1) + " -> " + GetItemName(item2.itemDef2))); } } Pair[] array5 = dictionary.Values.ToArray(); field.SetValue(null, array5); object? value5 = field2.GetValue(null); CostTypeDef val5 = (CostTypeDef)((value5 is CostTypeDef) ? value5 : null); if (val5 == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Compatibility failed: Risk Of Ramen Contamination Font cost type was not initialized."); return; } val5.payCost = (PayCostDelegate)method.Invoke(null, new object[1] { array5 }); val5.isAffordable = (IsAffordableDelegate)method2.Invoke(null, new object[1] { array5 }); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Contamination Font compatibility applied. Added " + num + " Bubbets Void Lunar conversion(s); kept " + num2 + " enabled Risk Of Ramen conflict(s). Total Font pairs: " + array5.Length + ".")); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Failed to apply Bubbets/Risk Of Ramen compatibility:\n" + ex)); } } private static bool IsCatalogued(ItemDef itemDef) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0015: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)itemDef == (Object)null || (int)itemDef.itemIndex == -1) { return false; } return ItemCatalog.GetItemDef(itemDef.itemIndex) == itemDef; } private static string GetItemName(ItemDef itemDef) { if ((Object)(object)itemDef == (Object)null) { return ""; } string text = Language.GetString(itemDef.nameToken); if (!string.IsNullOrEmpty(text)) { return text; } return ((Object)itemDef).name; } } }