using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx.Logging; using Mono.Cecil; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("BlueprintTweaksPatcher")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+bea75e70a80ddddc8e37b3062edab6f7534f7966")] [assembly: AssemblyProduct("BlueprintTweaksPatcher")] [assembly: AssemblyTitle("BlueprintTweaksPatcher")] [assembly: AssemblyVersion("1.0.0.0")] namespace BlueprintTweaks; public static class Preloader { public static ManualLogSource logSource; public static IEnumerable TargetDLLs { get; } = new string[1] { "Assembly-CSharp.dll" }; public static void Initialize() { logSource = Logger.CreateLogSource("BlueprintTweaks Preloader"); } public static MethodReference DefaultCtorFor(TypeReference type) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown TypeDefinition val = type.Resolve(); if (val == null) { return null; } MethodDefinition val2 = ((IEnumerable)val.Methods).SingleOrDefault((Func)((MethodDefinition m) => m.IsConstructor && ((MethodReference)m).Parameters.Count == 0 && !m.IsStatic)); if (val2 == null) { return DefaultCtorFor(val.BaseType); } return new MethodReference(".ctor", ((MemberReference)type).Module.TypeSystem.Void, type) { HasThis = true }; } public static void Patch(AssemblyDefinition assembly) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown try { ModuleDefinition mainModule = assembly.MainModule; TypeDefinition val = ((IEnumerable)mainModule.Types).First((TypeDefinition t) => ((MemberReference)t).FullName == "BlueprintData"); TypeDefinition val2 = ((IEnumerable)mainModule.Types).First((TypeDefinition t) => ((MemberReference)t).FullName == "AssemblerComponent"); TypeDefinition val3 = ((IEnumerable)mainModule.Types).First((TypeDefinition t) => ((MemberReference)t).FullName == "LabComponent"); val.Fields.Add(new FieldDefinition("anchorType", (FieldAttributes)6, mainModule.ImportReference(typeof(int)))); val.Fields.Add(new FieldDefinition("autoReformMode", (FieldAttributes)6, mainModule.ImportReference(typeof(int)))); val2.Fields.Add(new FieldDefinition("recipeIsLocked", (FieldAttributes)6, mainModule.ImportReference(typeof(bool)))); val3.Fields.Add(new FieldDefinition("recipeIsLocked", (FieldAttributes)6, mainModule.ImportReference(typeof(bool)))); logSource.LogInfo((object)"Preloader patching is successful!"); } catch (Exception) { logSource.LogError((object)"Preloader patching failed!"); throw; } } }