Decompiled source of AzuExtendedPlayerInventory v1.4.6
AzuExtendedPlayerInventory.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using APIManager; using AzuExtendedPlayerInventory; using AzuExtendedPlayerInventory.EPI.Patches; using AzuExtendedPlayerInventory.EPI.QAB; using AzuExtendedPlayerInventory.EPI.Utilities; using AzuExtendedPlayerInventory.Moveable; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using BepInEx.Preloader; using BepInEx.Preloader.Patching; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Collections.Generic; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.BufferedDeserialization; using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyProduct("AzuExtendedPlayerInventory")] [assembly: AssemblyCompany("Azumatt")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyDescription("")] [assembly: AssemblyTitle("AzuExtendedPlayerInventory")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyFileVersion("1.4.6")] [assembly: AssemblyConfiguration("")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.6.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<0cd6ab66-77e6-4947-9b36-c73aa52f689b>Embedded] internal sealed class <0cd6ab66-77e6-4947-9b36-c73aa52f689b>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [<0cd6ab66-77e6-4947-9b36-c73aa52f689b>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class <44ee33d9-48e7-4664-a04b-1c08524d7599>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <44ee33d9-48e7-4664-a04b-1c08524d7599>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <44ee33d9-48e7-4664-a04b-1c08524d7599>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [<0cd6ab66-77e6-4947-9b36-c73aa52f689b>Embedded] [CompilerGenerated] internal sealed class <8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContextAttribute : Attribute { public readonly byte Flag; public <8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace APIManager { [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(1)] [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(0)] public static class Patcher { [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] private class MonoAssemblyResolver : IAssemblyResolver, IDisposable { [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(1)] public AssemblyDefinition Resolve(AssemblyNameReference name) { return AssemblyDefinition.ReadAssembly(AppDomain.CurrentDomain.Load(name.FullName).Location); } [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(1)] public AssemblyDefinition Resolve(AssemblyNameReference name, ReaderParameters parameters) { return Resolve(name); } public void Dispose() { } } [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(0)] private class AssemblyLoadInterceptor { [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] private static string assemblyPath; private static MethodInfo TargetMethod() { return AccessTools.DeclaredMethod(typeof(Assembly), "Load", new Type[1] { typeof(byte[]) }, (Type[])null); } private static bool Prefix(ref byte[] __0, [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] ref Assembly __result) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Expected O, but got Unknown //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) assemblyPath = null; if (modifyNextLoad) { modifyNextLoad = false; try { AssemblyDefinition val = AssemblyDefinition.ReadAssembly((Stream)new MemoryStream(__0), new ReaderParameters { AssemblyResolver = (IAssemblyResolver)(object)new MonoAssemblyResolver() }); try { ((Dictionary<string, string>)typeof(EnvVars).Assembly.GetType("BepInEx.Preloader.RuntimeFixes.UnityPatches").GetProperty("AssemblyLocations").GetValue(null))[val.FullName] = currentAssemblyPath; FixupModuleReferences(val.MainModule); TypeDefinition val2 = val.MainModule.GetType("APIManager", "PatchedAttribute"); if (val2 == null) { val2 = new TypeDefinition("APIManager", "PatchedAttribute", (TypeAttributes)3) { BaseType = val.MainModule.ImportReference(typeof(Attribute)) }; MethodDefinition val3 = new MethodDefinition(".ctor", (MethodAttributes)6278, val.MainModule.TypeSystem.Void); ((MethodReference)val3).Parameters.Add(new ParameterDefinition(val.MainModule.TypeSystem.String)); ((MethodReference)val3).Parameters.Add(new ParameterDefinition(val.MainModule.TypeSystem.String)); val3.Body.Instructions.Add(Instruction.Create(OpCodes.Ret)); val2.Methods.Add(val3); val.MainModule.Types.Add(val2); CustomAttribute val4 = new CustomAttribute((MethodReference)(object)val3); val4.ConstructorArguments.Add(new CustomAttributeArgument(val.MainModule.TypeSystem.String, (object)"")); val4.ConstructorArguments.Add(new CustomAttributeArgument(val.MainModule.TypeSystem.String, (object)val.MainModule.Mvid.ToString())); val.CustomAttributes.Add(val4); } CustomAttribute val5 = new CustomAttribute((MethodReference)(object)((IEnumerable<MethodDefinition>)val2.Methods).First([<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (MethodDefinition m) => ((MemberReference)m).Name == ".ctor")); val5.ConstructorArguments.Add(new CustomAttributeArgument(val.MainModule.TypeSystem.String, (object)modGUID)); val5.ConstructorArguments.Add(new CustomAttributeArgument(val.MainModule.TypeSystem.String, (object)patchingAssembly.ManifestModule.ModuleVersionId.ToString())); val.CustomAttributes.Add(val5); using MemoryStream memoryStream = new MemoryStream(); val.Write((Stream)memoryStream); __0 = memoryStream.ToArray(); string dumpedAssembliesPath = Patcher.dumpedAssembliesPath; char directorySeparatorChar = Path.DirectorySeparatorChar; string path = dumpedAssembliesPath + directorySeparatorChar + ((AssemblyNameReference)val.Name).Name + ".dll"; Directory.CreateDirectory(Patcher.dumpedAssembliesPath); File.WriteAllBytes(path, __0); assemblyPath = path; __result = null; return false; } finally { ((IDisposable)val)?.Dispose(); } } catch (BadImageFormatException) { } catch (Exception ex2) { Debug.LogError((object)("Failed patching ... " + ex2)); } } return true; } [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(2)] private static void Postfix(ref Assembly __result) { if (assemblyPath != null && __result == null) { __result = Assembly.LoadFrom(assemblyPath); assemblyPath = null; } } } [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] private static PluginInfo lastPluginInfo; private static bool modifyNextLoad = false; private static string modGUID = null; private static HashSet<string> redirectedNamespaces = null; private static readonly Assembly patchingAssembly = Assembly.GetExecutingAssembly(); private static string currentAssemblyPath = null; private static readonly string dumpedAssembliesPath = (string)AccessTools.DeclaredField(typeof(AssemblyPatcher), "DumpedAssembliesPath").GetValue(null); private static void GrabPluginInfo(PluginInfo __instance) { lastPluginInfo = __instance; } [HarmonyPriority(700)] private static void CheckAssemblyLoadFile(string __0) { PluginInfo obj = lastPluginInfo; if (__0 == ((obj != null) ? obj.Location : null) && lastPluginInfo.Dependencies.Any([<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (BepInDependency d) => d.DependencyGUID == modGUID)) { modifyNextLoad = true; currentAssemblyPath = __0; } lastPluginInfo = null; } [HarmonyPriority(500)] private static bool InterceptAssemblyLoadFile(string __0, [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] ref Assembly __result) { //IL_003b: 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) //IL_0050: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) if (modifyNextLoad && (object)__result == null) { string text = dumpedAssembliesPath; char directorySeparatorChar = Path.DirectorySeparatorChar; string text2 = text + directorySeparatorChar + Path.GetFileName(__0); if (File.Exists(text2)) { AssemblyDefinition val = AssemblyDefinition.ReadAssembly(text2, new ReaderParameters { AssemblyResolver = (IAssemblyResolver)(object)new MonoAssemblyResolver() }); try { bool flag = false; Enumerator<CustomAttribute> enumerator = val.CustomAttributes.GetEnumerator(); try { while (enumerator.MoveNext()) { CustomAttribute current = enumerator.Current; TypeReference declaringType = ((MemberReference)current.Constructor).DeclaringType; if (declaringType.Namespace == "APIManager" && ((MemberReference)declaringType).Name == "PatchedAttribute") { CustomAttributeArgument val2 = current.ConstructorArguments[0]; if ((string)((CustomAttributeArgument)(ref val2)).Value == modGUID) { val2 = current.ConstructorArguments[1]; flag = (string)((CustomAttributeArgument)(ref val2)).Value == patchingAssembly.ManifestModule.ModuleVersionId.ToString(); break; } } } } finally { ((IDisposable)enumerator).Dispose(); } if (flag) { return true; } } finally { ((IDisposable)val)?.Dispose(); } } __result = Assembly.Load(File.ReadAllBytes(__0)); return false; } return true; } [HarmonyPriority(499)] private static bool ReplaceAssemblyLoadWithCache(ref string __0, [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] ref Assembly __result) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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 (modifyNextLoad && (object)__result == null && !__0.StartsWith(dumpedAssembliesPath)) { string text = dumpedAssembliesPath; char directorySeparatorChar = Path.DirectorySeparatorChar; string text2 = text + directorySeparatorChar + Path.GetFileName(__0); AssemblyDefinition val = AssemblyDefinition.ReadAssembly(text2, new ReaderParameters { AssemblyResolver = (IAssemblyResolver)(object)new MonoAssemblyResolver() }); AssemblyDefinition val2 = AssemblyDefinition.ReadAssembly(__0, new ReaderParameters { AssemblyResolver = (IAssemblyResolver)(object)new MonoAssemblyResolver() }); Enumerator<CustomAttribute> enumerator = val.CustomAttributes.GetEnumerator(); try { while (enumerator.MoveNext()) { CustomAttribute current = enumerator.Current; TypeReference declaringType = ((MemberReference)current.Constructor).DeclaringType; if (declaringType.Namespace == "APIManager" && ((MemberReference)declaringType).Name == "PatchedAttribute") { CustomAttributeArgument val3 = current.ConstructorArguments[0]; string text3 = (string)((CustomAttributeArgument)(ref val3)).Value; bool num; if (!(text3 == "")) { num = !Chainloader.PluginInfos.ContainsKey(text3); } else { val3 = current.ConstructorArguments[1]; num = (string)((CustomAttributeArgument)(ref val3)).Value != val2.MainModule.Mvid.ToString(); } if (num) { val2.Dispose(); val.Dispose(); __result = Assembly.Load(File.ReadAllBytes(__0)); return false; } } } } finally { ((IDisposable)enumerator).Dispose(); } ((Dictionary<string, string>)typeof(EnvVars).Assembly.GetType("BepInEx.Preloader.RuntimeFixes.UnityPatches").GetProperty("AssemblyLocations").GetValue(null))[val.FullName] = __0; val2.Dispose(); val.Dispose(); __0 = text2; } modifyNextLoad = false; return true; } private static void FixupModuleReferences(ModuleDefinition module) { foreach (TypeDefinition type4 in module.GetTypes()) { if ((object)patchingAssembly.GetType(((MemberReference)type4).FullName) == null) { Dispatch(type4); } } static bool AreSame(TypeReference a, TypeReference b) { return (bool)typeof(MetadataResolver).Assembly.GetType("Mono.Cecil.MetadataResolver").GetMethod("AreSame", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[2] { typeof(TypeReference), typeof(TypeReference) }, null).Invoke(null, new object[2] { a, b }); } void Dispatch(TypeDefinition type) { if (type.BaseType != null && type.BaseType.Scope == module && redirectedNamespaces.Contains(baseDeclaringType(type.BaseType).Namespace)) { Type type3 = patchingAssembly.GetType(((MemberReference)type.BaseType).FullName); if ((object)type3 != null) { type.BaseType = module.ImportReference(type3); } } DispatchGenericParameters((IGenericParameterProvider)(object)type, ((MemberReference)type).FullName); DispatchInterfaces(type, ((MemberReference)type).FullName); DispatchAttributes((ICustomAttributeProvider)(object)type, ((MemberReference)type).FullName); DispatchFields(type, ((MemberReference)type).FullName); DispatchProperties(type, ((MemberReference)type).FullName); DispatchEvents(type, ((MemberReference)type).FullName); DispatchMethods(type); } void DispatchAttributes(ICustomAttributeProvider provider, string referencingEntityName) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) if (!provider.HasCustomAttributes) { return; } Enumerator<CustomAttribute> enumerator11 = provider.CustomAttributes.GetEnumerator(); try { while (enumerator11.MoveNext()) { CustomAttribute current11 = enumerator11.Current; MethodReference val12 = importMethodReference(current11.Constructor); if (val12 != null) { current11.Constructor = val12; } else { VisitMethod(current11.Constructor, referencingEntityName); } for (int n = 0; n < current11.ConstructorArguments.Count; n++) { CustomAttributeArgument val13 = current11.ConstructorArguments[n]; current11.ConstructorArguments[n] = new CustomAttributeArgument(VisitType(((CustomAttributeArgument)(ref val13)).Type, referencingEntityName), ((CustomAttributeArgument)(ref val13)).Value); } CustomAttributeArgument argument; for (int num = 0; num < current11.Properties.Count; num++) { CustomAttributeNamedArgument val14 = current11.Properties[num]; Collection<CustomAttributeNamedArgument> properties = current11.Properties; int num2 = num; string name = ((CustomAttributeNamedArgument)(ref val14)).Name; argument = ((CustomAttributeNamedArgument)(ref val14)).Argument; TypeReference obj2 = VisitType(((CustomAttributeArgument)(ref argument)).Type, referencingEntityName); argument = ((CustomAttributeNamedArgument)(ref val14)).Argument; properties[num2] = new CustomAttributeNamedArgument(name, new CustomAttributeArgument(obj2, ((CustomAttributeArgument)(ref argument)).Value)); } for (int num3 = 0; num3 < current11.Fields.Count; num3++) { CustomAttributeNamedArgument val15 = current11.Fields[num3]; Collection<CustomAttributeNamedArgument> fields = current11.Fields; int num4 = num3; string name2 = ((CustomAttributeNamedArgument)(ref val15)).Name; argument = ((CustomAttributeNamedArgument)(ref val15)).Argument; TypeReference obj3 = VisitType(((CustomAttributeArgument)(ref argument)).Type, referencingEntityName); argument = ((CustomAttributeNamedArgument)(ref val15)).Argument; fields[num4] = new CustomAttributeNamedArgument(name2, new CustomAttributeArgument(obj3, ((CustomAttributeArgument)(ref argument)).Value)); } } } finally { ((IDisposable)enumerator11).Dispose(); } } void DispatchEvents(TypeDefinition type, string referencingEntityName) { //IL_0006: 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) Enumerator<EventDefinition> enumerator6 = type.Events.GetEnumerator(); try { while (enumerator6.MoveNext()) { EventDefinition current6 = enumerator6.Current; ((EventReference)current6).EventType = VisitType(((EventReference)current6).EventType, referencingEntityName); DispatchAttributes((ICustomAttributeProvider)(object)current6, referencingEntityName); } } finally { ((IDisposable)enumerator6).Dispose(); } } void DispatchFields(TypeDefinition type, string referencingEntityName) { //IL_0006: 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) Enumerator<FieldDefinition> enumerator8 = type.Fields.GetEnumerator(); try { while (enumerator8.MoveNext()) { FieldDefinition current8 = enumerator8.Current; ((FieldReference)current8).FieldType = VisitType(((FieldReference)current8).FieldType, referencingEntityName); DispatchAttributes((ICustomAttributeProvider)(object)current8, referencingEntityName); } } finally { ((IDisposable)enumerator8).Dispose(); } } void DispatchGenericArguments(IGenericInstance genericInstance, string referencingEntityName) { for (int j = 0; j < genericInstance.GenericArguments.Count; j++) { genericInstance.GenericArguments[j] = VisitType(genericInstance.GenericArguments[j], referencingEntityName); } } void DispatchGenericParameters(IGenericParameterProvider provider, string referencingEntityName) { //IL_0006: 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) Enumerator<GenericParameter> enumerator12 = provider.GenericParameters.GetEnumerator(); try { while (enumerator12.MoveNext()) { GenericParameter current12 = enumerator12.Current; DispatchAttributes((ICustomAttributeProvider)(object)current12, referencingEntityName); for (int num5 = 0; num5 < current12.Constraints.Count; num5++) { current12.Constraints[num5] = VisitType(current12.Constraints[num5], referencingEntityName); } } } finally { ((IDisposable)enumerator12).Dispose(); } } void DispatchInterfaces(TypeDefinition type, string referencingEntityName) { //IL_0006: 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) Enumerator<InterfaceImplementation> enumerator9 = type.Interfaces.GetEnumerator(); try { while (enumerator9.MoveNext()) { InterfaceImplementation current9 = enumerator9.Current; current9.InterfaceType = VisitType(current9.InterfaceType, referencingEntityName); } } finally { ((IDisposable)enumerator9).Dispose(); } } void DispatchMethod(MethodDefinition method) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) ((MethodReference)method).ReturnType = VisitType(((MethodReference)method).ReturnType, ((MemberReference)method).FullName); DispatchAttributes((ICustomAttributeProvider)(object)((MethodReference)method).MethodReturnType, ((MemberReference)method).FullName); DispatchGenericParameters((IGenericParameterProvider)(object)method, ((MemberReference)method).FullName); Enumerator<ParameterDefinition> enumerator4 = ((MethodReference)method).Parameters.GetEnumerator(); try { while (enumerator4.MoveNext()) { ParameterDefinition current4 = enumerator4.Current; ((ParameterReference)current4).ParameterType = VisitType(((ParameterReference)current4).ParameterType, ((MemberReference)method).FullName); DispatchAttributes((ICustomAttributeProvider)(object)current4, ((MemberReference)method).FullName); } } finally { ((IDisposable)enumerator4).Dispose(); } for (int i = 0; i < method.Overrides.Count; i++) { MethodReference val6 = importMethodReference(method.Overrides[i]); if (val6 != null) { method.Overrides[i] = val6; } else { VisitMethod(method.Overrides[i], ((MemberReference)method).FullName); } } if (method.HasBody) { DispatchMethodBody(method.Body); } } void DispatchMethodBody(MethodBody body) { //IL_0006: 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) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) Enumerator<VariableDefinition> enumerator2 = body.Variables.GetEnumerator(); try { while (enumerator2.MoveNext()) { VariableDefinition current2 = enumerator2.Current; ((VariableReference)current2).VariableType = VisitType(((VariableReference)current2).VariableType, ((MemberReference)body.Method).FullName); } } finally { ((IDisposable)enumerator2).Dispose(); } Enumerator<Instruction> enumerator3 = body.Instructions.GetEnumerator(); try { while (enumerator3.MoveNext()) { Instruction current3 = enumerator3.Current; object operand = current3.Operand; FieldReference val = (FieldReference)((operand is FieldReference) ? operand : null); if (val == null) { MethodReference val2 = (MethodReference)((operand is MethodReference) ? operand : null); if (val2 == null) { TypeReference val3 = (TypeReference)((operand is TypeReference) ? operand : null); if (val3 != null) { current3.Operand = VisitType(val3, ((MemberReference)body.Method).FullName); } } else { MethodReference val4 = importMethodReference(val2); if (val4 != null) { current3.Operand = val4; } else { VisitMethod(val2, ((MemberReference)body.Method).FullName); } } } else { FieldReference val5 = importFieldReference(val); if (val5 != null) { current3.Operand = val5; } else { VisitField(val, ((MemberReference)body.Method).FullName); } } } } finally { ((IDisposable)enumerator3).Dispose(); } } void DispatchMethods(TypeDefinition type) { //IL_0006: 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) Enumerator<MethodDefinition> enumerator5 = type.Methods.GetEnumerator(); try { while (enumerator5.MoveNext()) { MethodDefinition current5 = enumerator5.Current; DispatchMethod(current5); } } finally { ((IDisposable)enumerator5).Dispose(); } } void DispatchProperties(TypeDefinition type, string referencingEntityName) { //IL_0006: 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) Enumerator<PropertyDefinition> enumerator7 = type.Properties.GetEnumerator(); try { while (enumerator7.MoveNext()) { PropertyDefinition current7 = enumerator7.Current; ((PropertyReference)current7).PropertyType = VisitType(((PropertyReference)current7).PropertyType, referencingEntityName); DispatchAttributes((ICustomAttributeProvider)(object)current7, referencingEntityName); } } finally { ((IDisposable)enumerator7).Dispose(); } } TypeReference FixupType(TypeReference type) { if (type.Scope == module && redirectedNamespaces.Contains(baseDeclaringType(type).Namespace)) { if (type.IsNested) { return FixupType(((MemberReference)type).DeclaringType); } Type type2 = patchingAssembly.GetType(((MemberReference)type).FullName); if ((object)type2 != null) { return module.ImportReference(type2); } } return type; } void VisitField([<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] FieldReference field, string referencingEntityName) { if (field != null) { field.FieldType = VisitType(field.FieldType, referencingEntityName); if (!(field is FieldDefinition)) { ((MemberReference)field).DeclaringType = VisitType(((MemberReference)field).DeclaringType, referencingEntityName); } } } void VisitMethod([<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] MethodReference method, string referencingEntityName) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (method != null) { GenericInstanceMethod val7 = (GenericInstanceMethod)(object)((method is GenericInstanceMethod) ? method : null); if (val7 != null) { DispatchGenericArguments((IGenericInstance)(object)val7, referencingEntityName); } method.ReturnType = VisitType(method.ReturnType, referencingEntityName); Enumerator<ParameterDefinition> enumerator10 = method.Parameters.GetEnumerator(); try { while (enumerator10.MoveNext()) { ParameterDefinition current10 = enumerator10.Current; ((ParameterReference)current10).ParameterType = VisitType(((ParameterReference)current10).ParameterType, referencingEntityName); } } finally { ((IDisposable)enumerator10).Dispose(); } if (!(method is MethodSpecification)) { ((MemberReference)method).DeclaringType = VisitType(((MemberReference)method).DeclaringType, referencingEntityName); } } } [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(2)] TypeReference VisitType(TypeReference type, [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(1)] string referencingEntityName) { if (type == null) { return type; } if (type.GetElementType().IsGenericParameter) { return type; } GenericInstanceType val8 = (GenericInstanceType)(object)((type is GenericInstanceType) ? type : null); if (val8 != null) { DispatchGenericArguments((IGenericInstance)(object)val8, referencingEntityName); } return FixupType(type); } static TypeReference baseDeclaringType(TypeReference type) { while (((MemberReference)type).DeclaringType != null) { type = ((MemberReference)type).DeclaringType; } return type; } [return: <44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] FieldReference importFieldReference(FieldReference field) { if (((MemberReference)field).DeclaringType.Scope == module && redirectedNamespaces.Contains(baseDeclaringType(((MemberReference)field).DeclaringType).Namespace)) { FieldInfo fieldInfo = patchingAssembly.GetType(((MemberReference)((MemberReference)field).DeclaringType).FullName)?.GetField(((MemberReference)field).Name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if ((object)fieldInfo != null) { return module.ImportReference(fieldInfo); } } return null; } [return: <44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] MethodReference importMethodReference(MethodReference method) { //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Expected O, but got Unknown if (((MemberReference)method).DeclaringType.Scope == module && redirectedNamespaces.Contains(baseDeclaringType(((MemberReference)method).DeclaringType).Namespace)) { if (((MemberReference)method).Name == ".cctor") { ConstructorInfo[] array = patchingAssembly.GetType(((MemberReference)((MemberReference)method).DeclaringType).FullName)?.GetConstructors(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (array != null && array.Length == 1) { return module.ImportReference((MethodBase)array[0]); } } else if (((MemberReference)method).Name == ".ctor") { ConstructorInfo constructorInfo = patchingAssembly.GetType(((MemberReference)((MemberReference)method).DeclaringType).FullName)?.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault(CompareMethods); if ((object)constructorInfo != null) { return module.ImportReference((MethodBase)constructorInfo); } } else { MethodInfo methodInfo = patchingAssembly.GetType(((MemberReference)((MemberReference)method).DeclaringType).FullName)?.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault([<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (MethodInfo m) => { if (m.Name != ((MemberReference)method).Name) { return false; } return (((MemberReference)method.ReturnType).ContainsGenericParameter == m.ReturnType.IsGenericParameter || AreSame(method.ReturnType, module.ImportReference(m.ReturnType))) && CompareMethods(m); }); if ((object)methodInfo != null) { MethodReference val9 = module.ImportReference((MethodBase)methodInfo); MethodReference obj = method; GenericInstanceMethod val10 = (GenericInstanceMethod)(object)((obj is GenericInstanceMethod) ? obj : null); if (val10 != null) { GenericInstanceMethod val11 = new GenericInstanceMethod(val9); for (int k = 0; k < val10.GenericArguments.Count; k++) { val10.GenericArguments[k] = VisitType(val10.GenericArguments[k], ((MemberReference)method).FullName); val11.GenericArguments.Add(val10.GenericArguments[k]); } val9 = (MethodReference)(object)val11; } return val9; } } } return null; bool CompareMethods(MethodBase m) { ParameterInfo[] parameters = m.GetParameters(); if (method.IsGenericInstance != m.IsGenericMethodDefinition || parameters.Length != 0 != method.HasParameters) { return false; } if (method.HasParameters) { if (method.Parameters.Count != parameters.Length) { return false; } for (int l = 0; l < method.Parameters.Count; l++) { if (parameters[l].ParameterType.IsGenericParameter ? (!((ParameterReference)method.Parameters[l]).ParameterType.IsGenericParameter) : (!AreSame(((ParameterReference)method.Parameters[l]).ParameterType, module.ImportReference(parameters[l].ParameterType)))) { return false; } } } return true; } } } [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(2)] public static bool PreventHarmonyInteropFixLoad(Assembly __0) { return __0 == null; } public static void Patch([<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(new byte[] { 2, 1 })] IEnumerable<string> extraNamespaces = null) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected O, but got Unknown //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Expected O, but got Unknown //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Expected O, but got Unknown Harmony val = new Harmony("org.bepinex.plugins.APIManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(PluginInfo), "ToString", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Patcher), "GrabPluginInfo", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Assembly), "LoadFile", new Type[1] { typeof(string) }, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Patcher), "InterceptAssemblyLoadFile", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Assembly), "LoadFile", new Type[1] { typeof(string) }, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Patcher), "CheckAssemblyLoadFile", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Assembly), "LoadFile", new Type[1] { typeof(string) }, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Patcher), "ReplaceAssemblyLoadWithCache", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); new PatchClassProcessor(val, typeof(AssemblyLoadInterceptor), true).Patch(); Type type = typeof(AssemblyPatcher).Assembly.GetType("BepInEx.Preloader.RuntimeFixes.HarmonyInteropFix"); if ((object)type != null) { val.Patch((MethodBase)AccessTools.DeclaredMethod(type, "OnAssemblyLoad", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Patcher), "PreventHarmonyInteropFixLoad", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } IEnumerable<TypeInfo> source; try { source = patchingAssembly.DefinedTypes.ToList(); } catch (ReflectionTypeLoadException ex) { source = from t in ex.Types where t != null select t.GetTypeInfo(); } BaseUnityPlugin val2 = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); redirectedNamespaces = new HashSet<string>(extraNamespaces ?? Array.Empty<string>()) { ((object)val2).GetType().Namespace }; modGUID = val2.Info.Metadata.GUID; } } } namespace LocalizationManager { [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(1)] [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(0)] [PublicAPI] public class Localizer { private static readonly Dictionary<string, Dictionary<string, Func<string>>> PlaceholderProcessors; private static readonly Dictionary<string, Dictionary<string, string>> loadedTexts; private static readonly ConditionalWeakTable<Localization, string> localizationLanguage; private static readonly List<WeakReference<Localization>> localizationObjects; [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] private static BaseUnityPlugin _plugin; private static readonly List<string> fileExtensions; private static BaseUnityPlugin plugin { get { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown if (_plugin == null) { IEnumerable<TypeInfo> source; try { source = Assembly.GetExecutingAssembly().DefinedTypes.ToList(); } catch (ReflectionTypeLoadException ex) { source = from t in ex.Types where t != null select t.GetTypeInfo(); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } private static void UpdatePlaceholderText(Localization localization, string key) { localizationLanguage.TryGetValue(localization, out var value); string text = loadedTexts[value][key]; if (PlaceholderProcessors.TryGetValue(key, out var value2)) { text = value2.Aggregate(text, [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (string current, KeyValuePair<string, Func<string>> kv) => current.Replace("{" + kv.Key + "}", kv.Value())); } localization.AddWord(key, text); } public static void AddPlaceholder<T>(string key, string placeholder, ConfigEntry<T> config, [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(new byte[] { 2, 1, 1 })] Func<T, string> convertConfigValue = null) { if (convertConfigValue == null) { convertConfigValue = (T val) => val.ToString(); } if (!PlaceholderProcessors.ContainsKey(key)) { PlaceholderProcessors[key] = new Dictionary<string, Func<string>>(); } config.SettingChanged += [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (object _, EventArgs _) => { UpdatePlaceholder(); }; if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage())) { UpdatePlaceholder(); } void UpdatePlaceholder() { PlaceholderProcessors[key][placeholder] = () => convertConfigValue(config.Value); UpdatePlaceholderText(Localization.instance, key); } } public static void AddText(string key, string text) { List<WeakReference<Localization>> list = new List<WeakReference<Localization>>(); foreach (WeakReference<Localization> localizationObject in localizationObjects) { if (localizationObject.TryGetTarget(out var target)) { Dictionary<string, string> dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)]; if (!target.m_translations.ContainsKey(key)) { dictionary[key] = text; target.AddWord(key, text); } } else { list.Add(localizationObject); } } foreach (WeakReference<Localization> item in list) { localizationObjects.Remove(item); } } public static void Load() { LoadLocalization(Localization.instance, Localization.instance.GetSelectedLanguage()); } private static void LoadLocalization(Localization __instance, string language) { if (!localizationLanguage.Remove(__instance)) { localizationObjects.Add(new WeakReference<Localization>(__instance)); } localizationLanguage.Add(__instance, language); Dictionary<string, string> dictionary = new Dictionary<string, string>(); foreach (string item in from f in Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), plugin.Info.Metadata.Name + ".*", SearchOption.AllDirectories) where fileExtensions.IndexOf(Path.GetExtension(f)) >= 0 select f) { string text = Path.GetFileNameWithoutExtension(item).Split(new char[1] { '.' })[1]; if (dictionary.ContainsKey(text)) { Debug.LogWarning((object)("Duplicate key " + text + " found for " + plugin.Info.Metadata.Name + ". The duplicate file found at " + item + " will be skipped.")); } else { dictionary[text] = item; } } byte[] array = LoadTranslationFromAssembly("English"); if (array == null) { throw new Exception("Found no English localizations in mod " + plugin.Info.Metadata.Name + ". Expected an embedded resource translations/English.json or translations/English.yml."); } Dictionary<string, string> dictionary2 = new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(Encoding.UTF8.GetString(array)); if (dictionary2 == null) { throw new Exception("Localization for mod " + plugin.Info.Metadata.Name + " failed: Localization file was empty."); } string text2 = null; if (language != "English") { if (dictionary.ContainsKey(language)) { text2 = File.ReadAllText(dictionary[language]); } else { byte[] array2 = LoadTranslationFromAssembly(language); if (array2 != null) { text2 = Encoding.UTF8.GetString(array2); } } } if (text2 == null && dictionary.ContainsKey("English")) { text2 = File.ReadAllText(dictionary["English"]); } if (text2 != null) { foreach (KeyValuePair<string, string> item2 in new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(text2) ?? new Dictionary<string, string>()) { dictionary2[item2.Key] = item2.Value; } } loadedTexts[language] = dictionary2; foreach (KeyValuePair<string, string> item3 in dictionary2) { UpdatePlaceholderText(__instance, item3.Key); } } static Localizer() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown PlaceholderProcessors = new Dictionary<string, Dictionary<string, Func<string>>>(); loadedTexts = new Dictionary<string, Dictionary<string, string>>(); localizationLanguage = new ConditionalWeakTable<Localization, string>(); localizationObjects = new List<WeakReference<Localization>>(); fileExtensions = new List<string> { ".json", ".yml" }; new Harmony("org.bepinex.helpers.LocalizationManager").Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } [return: <44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] private static byte[] LoadTranslationFromAssembly(string language) { foreach (string fileExtension in fileExtensions) { byte[] array = ReadEmbeddedFileBytes("translations." + language + fileExtension); if (array != null) { return array; } } return null; } [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(2)] public static byte[] ReadEmbeddedFileBytes([<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(1)] string resourceFileName, Assembly containingAssembly = null) { using MemoryStream memoryStream = new MemoryStream(); if ((object)containingAssembly == null) { containingAssembly = Assembly.GetCallingAssembly(); } string text = containingAssembly.GetManifestResourceNames().FirstOrDefault([<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal)); if (text != null) { containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream); } return (memoryStream.Length == 0L) ? null : memoryStream.ToArray(); } } } namespace ItemDataManager { [PublicAPI] [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(0)] [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(1)] public abstract class ItemData { internal static WeakReference<ItemInfo> constructingInfo = null; [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(new byte[] { 2, 1 })] internal WeakReference<ItemInfo> info; private static readonly FieldInfo parameterInfoClassImpl = AccessTools.DeclaredField(typeof(ParameterInfo), "ClassImpl"); private static Dictionary<Type, Dictionary<string, FieldInfo>> serializedFields = new Dictionary<Type, Dictionary<string, FieldInfo>>(); public string CustomDataKey { get; internal set; } protected virtual bool AllowStackingIdenticalValues { get; set; } public string Value { get { if (!Item.m_customData.TryGetValue(CustomDataKey, out var value)) { return ""; } return value; } set { Item.m_customData[CustomDataKey] = value; } } public string Key { get; internal set; } public bool IsCloned => Info.isCloned.Contains(CustomDataKey); public bool IsAlive { get { ItemInfo target; return (info ?? constructingInfo).TryGetTarget(out target); } } public ItemData Item => Info.ItemData; public ItemInfo Info { get { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (!(info ?? constructingInfo).TryGetTarget(out var target)) { return new ItemInfo(new ItemData()); } return target; } } public virtual void FirstLoad() { } public virtual void Load() { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown Dictionary<string, FieldInfo> dictionary = fetchSerializedFields(); if (dictionary == null || dictionary.Count <= 0 || Value == "") { return; } List<object> list = new List<object>(); string[] array = Value.Split(new char[1] { '|' }); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { ':' }); if (array2.Length == 2 && dictionary.TryGetValue(array2[0], out var value)) { ZPackage val = new ZPackage(array2[1]); ParameterInfo parameterInfo = (ParameterInfo)FormatterServices.GetUninitializedObject(typeof(ParameterInfo)); parameterInfoClassImpl.SetValue(parameterInfo, value.FieldType); list.Clear(); ZRpc.Deserialize(new ParameterInfo[2] { null, parameterInfo }, val, ref list); if (list.Count > 0) { value.SetValue(this, list[0]); } } } } public virtual void Save() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown Dictionary<string, FieldInfo> dictionary = fetchSerializedFields(); if (dictionary == null || dictionary.Count <= 0) { return; } StringBuilder stringBuilder = new StringBuilder(); foreach (FieldInfo value in dictionary.Values) { ZPackage val = new ZPackage(); ZRpc.Serialize(new object[1] { value.GetValue(this) }, ref val); stringBuilder.Append(value.Name); stringBuilder.Append(':'); stringBuilder.Append(val.GetBase64()); stringBuilder.Append('|'); } int length = stringBuilder.Length - 1; stringBuilder.Length = length; Value = stringBuilder.ToString(); } public virtual void Unload() { } public virtual void Upgraded() { } [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(2)] public virtual string TryStack(ItemData data) { if (!AllowStackingIdenticalValues || !(data?.Value == Value)) { return null; } return Value; } private Dictionary<string, FieldInfo> fetchSerializedFields() { Type type = GetType(); if (serializedFields.TryGetValue(type, out var value)) { return value; } return serializedFields[type] = (from f in type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where f.GetCustomAttributes(typeof(SerializeField), inherit: true).Length != 0 select f).ToDictionary([<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (FieldInfo f) => f.Name, [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (FieldInfo f) => f); } } public sealed class StringItemData : ItemData { } [PublicAPI] [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(0)] [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(1)] public class ItemInfo : IEnumerable<ItemData>, IEnumerable { public static HashSet<Type> ForceLoadTypes; [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] internal static string _modGuid; private static Dictionary<Type, HashSet<Type>> typeInheritorsCache; private static HashSet<string> knownTypes; private Dictionary<string, ItemData> data = new Dictionary<string, ItemData>(); [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(new byte[] { 2, 1 })] private WeakReference<ItemInfo> selfReference; internal HashSet<string> isCloned = new HashSet<string>(); [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] private static ItemData awakeningItem; private static Assembly primaryAssembly; private static Dictionary<Assembly, string> assemblyNameCache; private static Dictionary<Type, string> classKeyCache; private HashSet<string> fetchedClassKeys = new HashSet<string>(); private static MethodInfo removeMethod; [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] private static ItemData checkingForStackableItemData; [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(new byte[] { 2, 1, 1 })] private static Dictionary<string, string> newValuesOnStackable; [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] private static ItemData currentlyUpgradingItem; internal static string modGuid => _modGuid ?? (_modGuid = ((Func<string>)delegate { //IL_0091: Unknown result type (might be due to invalid IL or missing references) IEnumerable<TypeInfo> source; try { source = Assembly.GetExecutingAssembly().DefinedTypes.ToList(); } catch (ReflectionTypeLoadException ex) { source = from t in ex.Types where t != null select t.GetTypeInfo(); } return ((BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)))).Info.Metadata.GUID; })()); public string Mod => modGuid; public ItemData ItemData { get; private set; } [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] public string this[string key] { [return: <44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] get { return Get<StringItemData>(key)?.Value; } [param: <44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] set { GetOrCreate<StringItemData>(key).Value = value ?? ""; } } internal static void addTypeToInheritorsCache(Type type, string typeKey) { if (!knownTypes.Contains(typeKey)) { knownTypes.Add(typeKey); Type type2 = type; while ((object)type2 != null) { AddInterfaces(type2); type2 = type2.BaseType; } } void AddInterfaces(Type baseType) { if (!typeInheritorsCache.TryGetValue(baseType, out var value)) { HashSet<Type> hashSet2 = (typeInheritorsCache[baseType] = new HashSet<Type>()); value = hashSet2; } value.Add(type); Type[] interfaces = baseType.GetInterfaces(); for (int i = 0; i < interfaces.Length; i++) { AddInterfaces(interfaces[i]); } } } private static string cachedAssemblyName(Assembly assembly) { if (assemblyNameCache.TryGetValue(assembly, out var value)) { return value; } return assemblyNameCache[assembly] = assembly.GetName().Name; } internal static string classKey(Type type, string key) { if (!classKeyCache.TryGetValue(type, out var value)) { value = type.FullName + ((type.Assembly != primaryAssembly) ? ("," + cachedAssemblyName(type.Assembly)) : ""); addTypeToInheritorsCache(type, value); } if (key == "") { return value; } return value + "#" + key; } internal static string dataKey(string key) { return modGuid + "#" + key; } internal ItemInfo(ItemData itemData) { ItemData = itemData; string text = dataKey(""); foreach (string item in ItemData.m_customData.Keys.ToList()) { if (!item.StartsWith(text)) { continue; } string[] array = item.Substring(text.Length).Split(new char[1] { '#' }, 2); if (!knownTypes.Contains(array[0])) { Type type = Type.GetType(array[0]); if ((object)type != null && typeof(ItemData).IsAssignableFrom(type)) { addTypeToInheritorsCache(type, array[0]); } } } } public T GetOrCreate<[<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(0)] T>(string key = "") where T : ItemData, new() { return Add<T>(key) ?? Get<T>(key); } [return: <44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] public T Add<[<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(0)] T>(string key = "") where T : ItemData, new() { string text = classKey(typeof(T), key); if (fetchedClassKeys.Contains(text) && data.ContainsKey(text)) { return null; } string text2 = dataKey(text); if (ItemData.m_customData.ContainsKey(text2) || (awakeningItem != ItemData && data.ContainsKey(text))) { return null; } ItemData.m_customData[text2] = ""; ItemDataManager.ItemData.constructingInfo = selfReference ?? (selfReference = new WeakReference<ItemInfo>(this)); T val = new T { info = selfReference, Key = key, CustomDataKey = text2 }; data[text] = val; val.Value = ""; val.FirstLoad(); return val; } [return: <44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] public T Get<T>(string key = "") where T : class { if (!typeInheritorsCache.TryGetValue(typeof(T), out var value)) { if (!typeof(ItemData).IsAssignableFrom(typeof(T)) || typeof(T) == typeof(ItemData)) { throw new Exception("Trying to get value from ItemDataManager for class not inheriting from ItemData"); } return null; } foreach (Type item in value) { string text = classKey(item, key); if (data.TryGetValue(text, out var value2)) { return (T)(object)value2; } if (!fetchedClassKeys.Contains(text) && awakeningItem != ItemData) { string text2 = dataKey(text); fetchedClassKeys.Add(text); if (ItemData.m_customData.ContainsKey(text2)) { return (T)(object)constructDataObj(text2, text); } } } return null; } public Dictionary<string, T> GetAll<[<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(0)] T>() where T : ItemData { LoadAll(); return data.Values.Where([<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (ItemData o) => o is T).ToDictionary([<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (ItemData o) => o.Key, [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (ItemData o) => (T)o); } public bool Remove(string key = "") { return Remove<StringItemData>(key); } public bool Remove<[<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(0)] T>(string key = "") where T : ItemData { string key2 = classKey(typeof(T), key); string key3 = dataKey(key2); if (ItemData.m_customData.Remove(key3)) { if (data.TryGetValue(key2, out var value)) { value.Unload(); data.Remove(key2); } return true; } return false; } public bool Remove<[<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(0)] T>(T itemData) where T : ItemData { if (typeof(T) == itemData.GetType()) { return Remove<T>(itemData.Key); } return (bool)removeMethod.MakeGenericMethod(itemData.GetType()).Invoke(this, new object[1] { itemData.Key }); } [return: <44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] private ItemData constructDataObj(string fullkey, string key) { string[] array = key.Split(new char[1] { '#' }, 2); Type type = Type.GetType(array[0]); if ((object)type == null || !typeof(ItemData).IsAssignableFrom(type)) { return null; } ItemDataManager.ItemData.constructingInfo = selfReference ?? (selfReference = new WeakReference<ItemInfo>(this)); ItemData itemData = (ItemData)Activator.CreateInstance(type); data[key] = itemData; itemData.info = selfReference; itemData.Key = ((array.Length > 1) ? array[1] : ""); itemData.CustomDataKey = fullkey; itemData.Load(); return itemData; } public void Save() { foreach (ItemData value in data.Values) { value.Save(); } } public void LoadAll() { if (awakeningItem == ItemData) { return; } string text = dataKey(""); foreach (string item in ItemData.m_customData.Keys.ToList()) { if (item.StartsWith(text)) { string key = item.Substring(text.Length); if (!data.ContainsKey(key)) { constructDataObj(item, key); } } } } public IEnumerator<ItemData> GetEnumerator() { LoadAll(); return data.Values.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } private static void SavePrefix(ItemData __instance) { SaveItem(__instance); } private static void SaveInventoryPrefix(Inventory __instance) { foreach (ItemData item in __instance.m_inventory) { SaveItem(item); } } private static void SaveItem(ItemData item) { if (ItemExtensions.itemInfo.TryGetValue(item, out var value)) { value.Save(); } } [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(2)] [return: <44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(new byte[] { 2, 1, 1 })] public Dictionary<string, string> IsStackableWithOtherInfo(ItemInfo info) { LoadAll(); Dictionary<string, string> dictionary = new Dictionary<string, string>(); if (info != null) { info.LoadAll(); foreach (string item in new HashSet<string>(info.data.Keys.Intersect(data.Keys))) { string text = data[item].TryStack(info.data[item]); if (text == null) { return null; } dictionary[item] = text; } foreach (KeyValuePair<string, ItemData> datum in info.data) { if (!dictionary.ContainsKey(datum.Key)) { string text2 = info.data[datum.Key].TryStack(null); if (text2 == null) { return null; } dictionary[datum.Key] = text2; } } } foreach (KeyValuePair<string, ItemData> datum2 in data) { if (!dictionary.ContainsKey(datum2.Key)) { string text3 = data[datum2.Key].TryStack(null); if (text3 == null) { return null; } dictionary[datum2.Key] = text3; } } return dictionary.ToDictionary([<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (KeyValuePair<string, string> kv) => dataKey(kv.Key), [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (KeyValuePair<string, string> kv) => kv.Value); } [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(2)] private static void RegisterForceLoadedTypesAddItem(ItemData __result) { awakeningItem = null; if (__result != null) { RegisterForceLoadedTypes(__result); } } private static void RegisterForceLoadedTypes(ItemData itemData) { foreach (Type forceLoadType in ForceLoadTypes) { string key = classKey(forceLoadType, ""); string text = dataKey(key); if (itemData.m_customData.ContainsKey(text)) { ItemInfo itemInfo = itemData.Data(); if (!itemInfo.data.ContainsKey(key)) { itemInfo.constructDataObj(text, key); } } } } private static void ItemDropAwake(ItemDrop __instance) { GameObject dropPrefab = __instance.m_itemData.m_dropPrefab; if (dropPrefab != null && ItemExtensions.itemInfo.TryGetValue(dropPrefab.GetComponent<ItemDrop>().m_itemData, out var value)) { __instance.m_itemData.Data().isCloned = new HashSet<string>(value.data.Values.Select([<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (ItemData i) => i.CustomDataKey)); } } private static void ItemDropAwakeDelayed(ItemDrop __instance) { if (!ZNetView.m_forceDisableInit) { RegisterForceLoadedTypes(__instance.m_itemData); } } private static void ItemDataClonePrefix(ItemData __instance, ItemData __result) { SaveItem(__instance); } private static void ItemDataClonePostfix(ItemData __instance, ItemData __result) { if (ItemExtensions.itemInfo.TryGetValue(__instance, out var value)) { __result.Data().isCloned = new HashSet<string>(value.data.Values.Select([<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (ItemData i) => i.CustomDataKey)); } } private static void ItemDataClonePostfixDelayed(ItemData __result) { RegisterForceLoadedTypes(__result); } private static void RegisterForceLoadedTypesOnPlayerLoaded(Player __instance) { foreach (Food food in __instance.m_foods) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(food.m_name); if (itemPrefab.GetComponent<ItemDrop>().m_itemData == food.m_item) { food.m_item = food.m_item.Clone(); food.m_item.m_dropPrefab = itemPrefab; } RegisterForceLoadedTypes(food.m_item); } } private static void SaveCheckingForStackableItemData(ItemData item) { if (item == awakeningItem) { awakeningItem = null; } checkingForStackableItemData = item; } private static void ResetCheckingForStackableItemData() { checkingForStackableItemData = null; } private static IEnumerable<CodeInstruction> CheckStackableInFindFreeStackMethods(IEnumerable<CodeInstruction> instructionsEnumerable) { CodeInstruction[] instructions = instructionsEnumerable.ToArray(); Label target = (Label)instructions.First([<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (CodeInstruction i) => i.opcode == OpCodes.Br || i.opcode == OpCodes.Br_S).operand; CodeInstruction targetedInstr = instructions.First([<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (CodeInstruction i) => i.labels.Contains(target)); Label? label = default(Label?); CodeInstruction lastBranch = instructions.Reverse().First([<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (CodeInstruction i) => CodeInstructionExtensions.Branches(i, ref label) && targetedInstr.labels.Contains(label.Value)); CodeInstruction loadingInstruction = null; int j = 0; while (j < instructions.Length) { yield return instructions[j]; if (loadingInstruction == null && instructions[j].opcode == OpCodes.Call && ((MethodInfo)instructions[j].operand).Name == "get_Current") { loadingInstruction = instructions[j + 1].Clone(); loadingInstruction.opcode = new Dictionary<OpCode, OpCode> { { OpCodes.Stloc_0, OpCodes.Ldloc_0 }, { OpCodes.Stloc_1, OpCodes.Ldloc_1 }, { OpCodes.Stloc_2, OpCodes.Ldloc_2 }, { OpCodes.Stloc_3, OpCodes.Ldloc_3 }, { OpCodes.Stloc_S, OpCodes.Ldloc_S } }[loadingInstruction.opcode]; } if (instructions[j] == lastBranch) { yield return loadingInstruction; yield return new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.DeclaredField(typeof(ItemInfo), "checkingForStackableItemData")); yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(ItemInfo), "CheckItemDataIsStackableFindFree", (Type[])null, (Type[])null)); yield return new CodeInstruction(OpCodes.Brfalse, (object)target); } int num = j + 1; j = num; } } private static bool CheckItemDataIsStackableFindFree(ItemData item, [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] ItemData target) { if (target == null) { return true; } Dictionary<string, string> dictionary = IsStackable(item, target); if (dictionary != null) { newValuesOnStackable = dictionary; return true; } return false; } private static void ResetNewValuesOnStackable() { newValuesOnStackable = null; } [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(2)] private static void ApplyNewValuesOnStackable(ItemData __result) { if (__result == null || newValuesOnStackable == null) { return; } foreach (KeyValuePair<string, string> item in newValuesOnStackable) { __result.m_customData[item.Key] = item.Value; } } [return: <44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(new byte[] { 2, 1, 1 })] private static Dictionary<string, string> IsStackable(ItemData a, ItemData b) { ItemInfo itemInfo = a.Data(); if (itemInfo != null) { return itemInfo.IsStackableWithOtherInfo(b.Data()); } ItemInfo itemInfo2 = b.Data(); if (itemInfo2 != null) { return itemInfo2.IsStackableWithOtherInfo(null); } return new Dictionary<string, string>(); } private static bool CheckItemDataStackableAddItem(Inventory __instance, ItemData item, int x, int y, [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(new byte[] { 2, 1, 1 })] ref Dictionary<string, string> __state, ref bool __result) { ItemData itemAt = __instance.GetItemAt(x, y); if (itemAt != null) { Dictionary<string, string> dictionary = IsStackable(item, itemAt); if (dictionary == null) { __result = false; return false; } __state = dictionary; } return true; } private static void ApplyCustomItemDataStackableAddItem(Inventory __instance, int x, int y, [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(new byte[] { 2, 1, 1 })] Dictionary<string, string> __state, bool __result) { if (!__result || __state == null) { return; } foreach (KeyValuePair<string, string> item in __state) { __instance.GetItemAt(x, y).m_customData[item.Key] = item.Value; } } private static void ApplyCustomItemDataStackableAutoStack(ItemDrop item, Dictionary<string, string> customData) { item.m_itemData.m_customData = customData; } [return: <44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(new byte[] { 2, 1, 1 })] private static Dictionary<string, string> IsStackableItemDrop(ItemDrop drop, ItemData item) { return IsStackable(drop.m_itemData, item); } private static IEnumerable<CodeInstruction> HandleAutostackableItems(IEnumerable<CodeInstruction> instructionList, ILGenerator ilg) { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Expected O, but got Unknown //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Expected O, but got Unknown //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Expected O, but got Unknown //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Expected O, but got Unknown //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Expected O, but got Unknown //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Expected O, but got Unknown List<CodeInstruction> list = instructionList.ToList(); FieldInfo fieldInfo = AccessTools.DeclaredField(typeof(ItemData), "m_stack"); FieldInfo fieldInfo2 = AccessTools.DeclaredField(typeof(ItemDrop), "m_itemData"); Label? label = default(Label?); for (int i = 0; i < list.Count; i++) { if (!CodeInstructionExtensions.StoresField(list[i], fieldInfo)) { continue; } for (int num = i; num > 0; num--) { if (CodeInstructionExtensions.Branches(list[num], ref label)) { for (int num2 = num; num2 > 0; num2--) { if (CodeInstructionExtensions.LoadsField(list[num2], fieldInfo2, false)) { LocalBuilder localBuilder = ilg.DeclareLocal(typeof(Dictionary<string, string>)); LocalBuilder localBuilder2 = ilg.DeclareLocal(typeof(ItemData)); list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(ItemInfo), "ApplyCustomItemDataStackableAutoStack", (Type[])null, (Type[])null))); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldloc, (object)localBuilder.LocalIndex)); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(num + 1, new CodeInstruction(OpCodes.Brfalse, (object)label)); list.Insert(num + 1, new CodeInstruction(OpCodes.Stloc, (object)localBuilder.LocalIndex)); list.Insert(num + 1, new CodeInstruction(OpCodes.Dup, (object)localBuilder.LocalIndex)); list.Insert(num + 1, new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(ItemInfo), "IsStackableItemDrop", (Type[])null, (Type[])null))); list.Insert(num + 1, new CodeInstruction(OpCodes.Ldloc, (object)localBuilder2.LocalIndex)); list.Insert(num + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(num2 + 1, new CodeInstruction(OpCodes.Stloc, (object)localBuilder2.LocalIndex)); list.Insert(num2 + 1, new CodeInstruction(OpCodes.Dup, (object)null)); return list; } } } } } throw new Exception("Found no stack store in a branch"); } private static IEnumerable<CodeInstruction> TransferCustomItemDataOnUpgrade(IEnumerable<CodeInstruction> instructions, ILGenerator ilg) { MethodInfo itemDeleter = AccessTools.DeclaredMethod(typeof(Inventory), "RemoveItem", new Type[1] { typeof(ItemData) }, (Type[])null); foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Callvirt && CodeInstructionExtensions.OperandIs(instruction, (MemberInfo)itemDeleter)) { yield return new CodeInstruction(OpCodes.Dup, (object)null); yield return new CodeInstruction(OpCodes.Stsfld, (object)AccessTools.DeclaredField(typeof(ItemInfo), "currentlyUpgradingItem")); } yield return instruction; } } private static void ResetCurrentlyUpgradingItem() { currentlyUpgradingItem = null; } private static void CopyCustomDataFromUpgradedItem(ItemDrop item) { if (currentlyUpgradingItem != null) { item.m_itemData.m_customData = currentlyUpgradingItem.m_customData; ItemInfo itemInfo = currentlyUpgradingItem.Data(); ItemExtensions.itemInfo.Remove(currentlyUpgradingItem); ItemExtensions.itemInfo.Add(item.m_itemData, itemInfo); item.m_itemData.m_quality = currentlyUpgradingItem.m_quality + 1; item.m_itemData.m_variant = currentlyUpgradingItem.m_variant; itemInfo.ItemData = item.m_itemData; itemInfo.LoadAll(); foreach (ItemData value in itemInfo.data.Values) { value.Upgraded(); } currentlyUpgradingItem = null; awakeningItem = null; return; } GameObject dropPrefab = item.m_itemData.m_dropPrefab; if (dropPrefab == null || item.m_itemData.m_customData.Count != 0) { return; } ZNetView component = ((Component)item).GetComponent<ZNetView>(); ZDO val = ((Object.op_Implicit((Object)(object)component) && component.IsValid()) ? component.GetZDO() : null); if (val != null && val.GetInt(ZDOVars.s_dataCount, -1) != -1) { return; } item.m_itemData.m_customData = new Dictionary<string, string>(dropPrefab.GetComponent<ItemDrop>().m_itemData.m_customData); if (val == null) { return; } int num = 0; val.Set(ZDOVars.s_dataCount, item.m_itemData.m_customData.Count, false); foreach (KeyValuePair<string, string> customDatum in item.m_itemData.m_customData) { val.Set($"data_{num}", customDatum.Key); val.Set($"data__{num++}", customDatum.Value); } } private static IEnumerable<CodeInstruction> ImportCustomDataOnUpgrade(IEnumerable<CodeInstruction> instructionList) { List<CodeInstruction> list = instructionList.ToList(); foreach (CodeInstruction instruction in list) { yield return instruction; if (instruction.opcode == OpCodes.Stfld && CodeInstructionExtensions.OperandIs(instruction, (MemberInfo)AccessTools.DeclaredField(typeof(ItemData), "m_dropPrefab"))) { yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(ItemInfo), "CopyCustomDataFromUpgradedItem", (Type[])null, (Type[])null)); } } } private static void TrackAwakeningItem(ItemDrop __instance) { if (ZNetView.m_forceDisableInit) { awakeningItem = __instance.m_itemData; } } static ItemInfo() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Expected O, but got Unknown //IL_01d0: Expected O, but got Unknown //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Expected O, but got Unknown //IL_023f: Expected O, but got Unknown //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Expected O, but got Unknown //IL_02a1: Expected O, but got Unknown //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Expected O, but got Unknown //IL_0310: Expected O, but got Unknown //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Expected O, but got Unknown //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Expected O, but got Unknown //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Expected O, but got Unknown //IL_03c0: Expected O, but got Unknown //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Expected O, but got Unknown //IL_042c: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Expected O, but got Unknown //IL_0452: Expected O, but got Unknown //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04b0: Expected O, but got Unknown //IL_0503: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Expected O, but got Unknown //IL_05bc: Unknown result type (might be due to invalid IL or missing references) //IL_05c9: Expected O, but got Unknown //IL_05f7: Unknown result type (might be due to invalid IL or missing references) //IL_0622: Unknown result type (might be due to invalid IL or missing references) //IL_0629: Expected O, but got Unknown //IL_064f: Unknown result type (might be due to invalid IL or missing references) //IL_065d: Expected O, but got Unknown //IL_065d: Expected O, but got Unknown //IL_069c: Unknown result type (might be due to invalid IL or missing references) //IL_06a9: Expected O, but got Unknown //IL_06d7: Unknown result type (might be due to invalid IL or missing references) //IL_0702: Unknown result type (might be due to invalid IL or missing references) //IL_070f: Expected O, but got Unknown //IL_070f: Expected O, but got Unknown //IL_074e: Unknown result type (might be due to invalid IL or missing references) //IL_075b: Expected O, but got Unknown ForceLoadTypes = new HashSet<Type>(); typeInheritorsCache = new Dictionary<Type, HashSet<Type>>(); knownTypes = new HashSet<string>(); awakeningItem = null; primaryAssembly = Assembly.GetExecutingAssembly(); assemblyNameCache = new Dictionary<Assembly, string>(); classKeyCache = new Dictionary<Type, string>(); removeMethod = typeof(ItemInfo).GetMethods().Single([<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(0)] (MethodInfo m) => m.Name == "Remove" && m.IsGenericMethod && m.GetParameters()[0].ParameterType == typeof(string)); Harmony val = new Harmony("org.bepinex.helpers.ItemDataManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Inventory), "Save", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "SaveInventoryPrefix", (Type[])null, (Type[])null), 800, (string[])null, (string[])null, (bool?)null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); foreach (MethodInfo item in from m in typeof(ItemData).GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) where m.Name == "SaveToZDO" select m) { val.Patch((MethodBase)item, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "SavePrefix", (Type[])null, (Type[])null), 800, (string[])null, (string[])null, (bool?)null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Inventory), "AddItem", new Type[4] { typeof(ItemData), typeof(int), typeof(int), typeof(int) }, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "CheckItemDataStackableAddItem", (Type[])null, (Type[])null)), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "ApplyCustomItemDataStackableAddItem", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Inventory), "CanAddItem", new Type[2] { typeof(ItemData), typeof(int) }, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "SaveCheckingForStackableItemData", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(ItemInfo), "ResetCheckingForStackableItemData", (Type[])null), (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Inventory), "AddItem", new Type[1] { typeof(ItemData) }, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "SaveCheckingForStackableItemData", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(ItemInfo), "ResetCheckingForStackableItemData", (Type[])null), (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Inventory), "AddItem", new Type[2] { typeof(ItemData), typeof(Vector2i) }, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "SaveCheckingForStackableItemData", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(ItemInfo), "ResetCheckingForStackableItemData", (Type[])null), (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Inventory), "FindFreeStackSpace", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "CheckStackableInFindFreeStackMethods", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(Inventory), "FindFreeStackItem", (Type[])null, (Type[])null); HarmonyMethod val2 = new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "CheckStackableInFindFreeStackMethods", (Type[])null, (Type[])null)); val.Patch((MethodBase)methodInfo, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "ResetNewValuesOnStackable", (Type[])null, (Type[])null)), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "ApplyNewValuesOnStackable", (Type[])null, (Type[])null)), val2, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ItemDrop), "AutoStackItems", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "HandleAutostackableItems", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(InventoryGui), "DoCrafting", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "TransferCustomItemDataOnUpgrade", (Type[])null, (Type[])null)), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "ResetCurrentlyUpgradingItem", (Type[])null, (Type[])null)), (HarmonyMethod)null); foreach (MethodInfo item2 in from m in typeof(ItemData).GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) where m.Name == "LoadFromZDO" select m) { val.Patch((MethodBase)item2, (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "RegisterForceLoadedTypes", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Player), "Load", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "RegisterForceLoadedTypesOnPlayerLoaded", (Type[])null, (Type[])null), 700, (string[])null, (string[])null, (bool?)null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Inventory), "AddItem", new Type[8] { typeof(string), typeof(int), typeof(int), typeof(int), typeof(long), typeof(string), typeof(Vector2i), typeof(bool) }, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "RegisterForceLoadedTypesAddItem", (Type[])null, (Type[])null), 800, (string[])null, (string[])null, (bool?)null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo2 = AccessTools.DeclaredMethod(typeof(ItemDrop), "Awake", (Type[])null, (Type[])null); HarmonyMethod val3 = new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "TrackAwakeningItem", (Type[])null, (Type[])null)); val2 = new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "ImportCustomDataOnUpgrade", (Type[])null, (Type[])null), 800, (string[])null, (string[])null, (bool?)null); val.Patch((MethodBase)methodInfo2, val3, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "ItemDropAwake", (Type[])null, (Type[])null), 800, (string[])null, (string[])null, (bool?)null), val2, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ItemDrop), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "ItemDropAwakeDelayed", (Type[])null, (Type[])null), 799, (string[])null, (string[])null, (bool?)null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ItemData), "Clone", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "ItemDataClonePrefix", (Type[])null, (Type[])null)), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "ItemDataClonePostfix", (Type[])null, (Type[])null), 500, (string[])null, (string[])null, (bool?)null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ItemData), "Clone", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ItemInfo), "ItemDataClonePostfixDelayed", (Type[])null, (Type[])null), 499, (string[])null, (string[])null, (bool?)null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(1)] [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(0)] [PublicAPI] public class ForeignItemInfo : IEnumerable<object>, IEnumerable { private readonly object foreignItemInfo; public string Mod => ((string)foreignItemInfo.GetType().GetProperty("Mod")?.GetValue(foreignItemInfo)) ?? ""; public ItemData ItemData { get; private set; } [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] public string this[string key] { [return: <44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] get { object obj = foreignItemInfo.GetType().InvokeMember("Item", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty, null, foreignItemInfo, new object[1] { key }); if (obj != null) { return (string)obj.GetType().GetProperty("Value")?.GetValue(obj); } return null; } [param: <44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] set { foreignItemInfo.GetType().GetMethod("set_Item", BindingFlags.Instance | BindingFlags.Public)?.Invoke(foreignItemInfo, new object[2] { key, value }); } } internal ForeignItemInfo(ItemData itemData, object foreignItemInfo) { ItemData = itemData; this.foreignItemInfo = foreignItemInfo; } public T GetOrCreate<T>(string key = "") where T : class, new() { return Add<T>(key) ?? Get<T>(key); } [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(2)] private object call([<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(1)] string name, [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(new byte[] { 1, 2 })] object[] values, [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(new byte[] { 1, 2 })] Type[] args, Type generic = null) { MethodInfo[] methods = foreignItemInfo.GetType().GetMethods(); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name == name && (from p in methodInfo.GetParameters() select (!p.ParameterType.IsGenericParameter) ? p.ParameterType : null).SequenceEqual(args) && (object)generic != null == methodInfo.IsGenericMethod) { MethodInfo methodInfo2 = methodInfo; if ((object)generic != null) { methodInfo2 = methodInfo2.MakeGenericMethod(generic); } return methodInfo2.Invoke(foreignItemInfo, values); } } return null; } [return: <44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] public T Add<T>(string key = "") where T : class, new() { return call("Add", new object[1] { key }, new Type[1] { typeof(string) }, typeof(T)) as T; } [return: <44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] public T Get<T>(string key = "") where T : class { return call("Get", new object[1] { key }, new Type[1] { typeof(string) }, typeof(T)) as T; } public Dictionary<string, T> GetAll<T>() where T : class { return ((call("GetAll", Array.Empty<object>(), Array.Empty<Type>(), typeof(T)) as T) as Dictionary<string, T>) ?? new Dictionary<string, T>(); } public bool Remove(string key = "") { return (call("Add", new object[1] { key }, new Type[1] { typeof(string) }) as bool?).GetValueOrDefault(); } public bool Remove<T>(string key = "") where T : class { return (call("Remove", new object[1] { key }, new Type[1] { typeof(string) }, typeof(T)) as bool?).GetValueOrDefault(); } public bool Remove<T>(T itemData) where T : class { return (call("Remove", new object[1] { itemData }, new Type[1], typeof(T)) as bool?).GetValueOrDefault(); } public void Save() { call("Save", Array.Empty<object>(), Array.Empty<Type>()); } public void LoadAll() { call("LoadAll", Array.Empty<object>(), Array.Empty<Type>()); } public IEnumerator<object> GetEnumerator() { return (IEnumerator<object>)((call("GetEnumerator", Array.Empty<object>(), Array.Empty<Type>()) as IEnumerator<object>) ?? ((object)new List<object>().GetEnumerator())); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(1)] [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(0)] [PublicAPI] public static class ItemExtensions { private const string className = "ItemDataManager.ItemExtensions"; internal static readonly ConditionalWeakTable<ItemData, ItemInfo> itemInfo = new ConditionalWeakTable<ItemData, ItemInfo>(); [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(new byte[] { 1, 1, 1, 1, 2 })] private static readonly ConditionalWeakTable<ItemData, Dictionary<string, ForeignItemInfo>> foreignItemInfo = new ConditionalWeakTable<ItemData, Dictionary<string, ForeignItemInfo>>(); public static ItemInfo Data(this ItemData item) { if (itemInfo.TryGetValue(item, out var value)) { return value; } itemInfo.Add(item, value = new ItemInfo(item)); return value; } [return: <44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(2)] public static ForeignItemInfo Data(this ItemData item, string mod) { Dictionary<string, ForeignItemInfo> orCreateValue = ItemExtensions.foreignItemInfo.GetOrCreateValue(item); if (orCreateValue.TryGetValue(mod, out var value)) { return value; } if (!Chainloader.PluginInfos.TryGetValue(mod, out var value2)) { return null; } object obj = ((object)value2.Instance).GetType().Assembly.GetType("ItemDataManager.ItemExtensions")?.GetMethod("Data", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(ItemData) }, Array.Empty<ParameterModifier>())?.Invoke(null, new object[1] { item }); if (obj != null) { return orCreateValue[mod] = new ForeignItemInfo(item, obj); } Debug.LogWarning((object)("Mod " + mod + " has an ItemDataManager.ItemExtensions class, but no Data(ItemDrop.ItemData) method could be called on it.")); return orCreateValue[mod] = null; } } } namespace AzuEPI.EPI.Utilities { [HarmonyPatch(typeof(ZNet), "OnNewConnection")] public static class RegisterAndCheckVersion { [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(1)] private static void Prefix(ZNetPeer peer, ref ZNet __instance) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown AzuExtendedPlayerInventoryPlugin.AzuExtendedPlayerInventoryLogger.LogDebug((object)"Registering version RPC handler"); peer.m_rpc.Register<ZPackage>("AzuExtendedPlayerInventory_VersionCheck", (Action<ZRpc, ZPackage>)RpcHandlers.RPC_AzuEPI_Version); AzuExtendedPlayerInventoryPlugin.AzuExtendedPlayerInventoryLogger.LogInfo((object)"Invoking version check"); ZPackage val = new ZPackage(); val.Write("1.4.6"); peer.m_rpc.Invoke("AzuExtendedPlayerInventory_VersionCheck", new object[1] { val }); } } [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(0)] [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(1)] [HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")] public static class VerifyClient { private static bool Prefix(ZRpc rpc, ZPackage pkg, ref ZNet __instance) { if (!__instance.IsServer() || RpcHandlers.ValidatedPeers.Contains(rpc)) { return true; } AzuExtendedPlayerInventoryPlugin.AzuExtendedPlayerInventoryLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") never sent version or couldn't due to previous disconnect, disconnecting")); rpc.Invoke("Error", new object[1] { 3 }); return false; } private static void Postfix(ZNet __instance) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "AzuExtendedPlayerInventoryRequestAdminSync", new object[1] { (object)new ZPackage() }); } } [HarmonyPatch(typeof(FejdStartup), "ShowConnectError")] public class ShowConnectionError { [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(1)] private static void Postfix(FejdStartup __instance) { if (__instance.m_connectionFailedPanel.activeSelf) { __instance.m_connectionFailedError.fontSizeMax = 25f; __instance.m_connectionFailedError.fontSizeMin = 15f; TMP_Text connectionFailedError = __instance.m_connectionFailedError; connectionFailedError.text = connectionFailedError.text + "\n" + AzuExtendedPlayerInventoryPlugin.ConnectionError; } } } [HarmonyPatch(typeof(ZNet), "Disconnect")] public static class RemoveDisconnectedPeerFromVerified { [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(1)] private static void Prefix(ZNetPeer peer, ref ZNet __instance) { if (__instance.IsServer()) { AzuExtendedPlayerInventoryPlugin.AzuExtendedPlayerInventoryLogger.LogInfo((object)("Peer (" + peer.m_rpc.m_socket.GetHostName() + ") disconnected, removing from validated list")); RpcHandlers.ValidatedPeers.Remove(peer.m_rpc); } } } [<44ee33d9-48e7-4664-a04b-1c08524d7599>Nullable(0)] [<8616eba4-8be3-4cbf-a6ec-66b489381601>NullableContext(1)] public static class RpcHandlers { public static readonly List<ZRpc> ValidatedPeers = new List<ZRpc>(); public static void RPC_AzuEPI_Version(ZRpc rpc, ZPackage pkg) { string text = pkg.ReadString(); AzuExtendedPlayerInventoryPlugin.AzuExtendedPlayerInventoryLogger.LogInfo((object)("Version check, local: 1.4.6, remote: " + text)); if (text != "1.4.6") { AzuExtendedPlayerInventoryPlugin.ConnectionError = "AzuExtendedPlayerInventory Installed: 1.4.6\n Needed: " + text; if (ZNet.instance.IsServer()) { AzuExtendedPlayerInventoryPlugin.AzuExtendedPlayerInventoryLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") has incompatible version, disconnecting...")); rpc.Invoke("Error", new object[1] { 3 }); } } else if (!ZNet.instance.IsServer()) { AzuExtendedPlayerInventoryPlugin.AzuExtendedPlayerInventoryLogger.LogInfo((object)"Received same version from server!"); } else { AzuExtendedPlayerInventoryPlugin.AzuExtendedPlayerInventoryLogger.LogInfo((object)("Adding peer (" + rpc.m_socket.GetHostName() + ") to validated list")); ValidatedPeers.Add(rpc); } } } [HarmonyPatch(typeof(Terminal), "InitTerminal")] internal static class TerminalInitTerminalPatch { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Predicate<ItemData> <>9__0_6; public static ConsoleEvent <>9__0_0; public static ConsoleEvent <>9__0_1; public static Func<ItemData, bool> <>9__0_7