using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using CommonAPI; using CommonAPI.Systems; using CommonAPI.Systems.ModLocalization; using DSPCalculator.Logic; using DSPCalculator.UI; using HarmonyLib; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("starfi5h.plugin.BuildToolOpt")] [assembly: AssemblyProduct("BuildToolOpt")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.6.0")] [module: UnverifiableCode] namespace BuildToolOpt; public static class CameraFix_Patch { public static bool Enable; [HarmonyTranspiler] [HarmonyPatch(typeof(GameCamera), "Logic")] [HarmonyPatch(typeof(PlayerMove_Drift), "GameTick")] [HarmonyPatch(typeof(PlayerMove_Fly), "GameTick")] [HarmonyPatch(typeof(PlayerMove_Walk), "GameTick")] private static IEnumerable ModeReplace(IEnumerable instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(PlayerController), "actionBuild"), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(PlayerAction_Build), "get_blueprintMode", (Type[])null, (Type[])null), (string)null) }).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate>((Func)((EBlueprintMode mode) => Enable ? ((EBlueprintMode)0) : mode)) }) .InstructionEnumeration(); } } public static class UIBlueprintComponentItem_Patch { [HarmonyPostfix] [HarmonyPatch(typeof(UIBlueprintComponentItem), "_OnRegEvent")] public static void AddEvent(UIBlueprintComponentItem __instance) { __instance.button.onClick += GetAction(__instance.inspector); } [HarmonyPostfix] [HarmonyPatch(typeof(UIBlueprintComponentItem), "_OnUnregEvent")] public static void RemoveEvent(UIBlueprintComponentItem __instance) { __instance.button.onClick -= GetAction(__instance.inspector); } public static Action GetAction(UIBlueprintInspector inspector) { return OnClick; void OnClick(int itemId) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) UIItemPickerExtension.Popup(new Vector2(-300f, 238f), (Action)delegate(ItemProto proto) { if (proto != null) { SetBuildings(inspector, itemId, proto); } }, (Func)((ItemProto proto) => proto.Upgrades?.Contains(itemId) ?? false)); } } public static void SetBuildings(UIBlueprintInspector inspector, int oldItemId, ItemProto newItem) { //IL_0042: 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_0059: Invalid comparison between Unknown and I4 //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Invalid comparison between Unknown and I4 //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Invalid comparison between Unknown and I4 BlueprintBuilding[] buildings = inspector.blueprint.buildings; foreach (BlueprintBuilding val in buildings) { if (val.itemId == oldItemId) { val.itemId = (short)((Proto)newItem).ID; val.modelIndex = (short)newItem.ModelIndex; } } if ((int)inspector.usage == 0 || (int)inspector.usage == 2) { if ((int)inspector.usage == 2) { inspector.pasteBuildTool.ResetStates(); } } else if ((int)inspector.usage == 1) { _ = ((BuildTool)inspector.copyBuildTool).active; } inspector.Refresh(true, true, true, false); } } public class Compatibility { public static class Nebula_Patch { public const string GUID = "dsp.nebula-multiplayer"; public static void Init() { if (Chainloader.PluginInfos.TryGetValue("dsp.nebula-multiplayer", out var _)) { Plugin.EnableReplaceStation = false; Plugin.EnableHologram = false; Plugin.EnableStationBuildOptimize = false; Plugin.Log.LogDebug((object)"Nebula: Disable replace station and hologram function"); } } } public static class CheatEnabler_Patch { public const string GUID = "org.soardev.cheatenabler"; public static void Init(Harmony harmony) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown if (!Chainloader.PluginInfos.TryGetValue("org.soardev.cheatenabler", out var value)) { return; } try { Type type = ((object)value.Instance).GetType().Assembly.GetType("CheatEnabler.Patches.FactoryPatch"); harmony.Patch((MethodBase)AccessTools.Method(type, "ArrivePlanet", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.Method(typeof(CheatEnabler_Patch), "ArrivePlanet_Prefix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } catch (Exception ex) { Plugin.Log.LogWarning((object)"CheatEnabler compatibility failed! Last working version: 2.4.0"); Plugin.Log.LogWarning((object)ex); } } internal static bool ArrivePlanet_Prefix() { return !ReplaceStationLogic.IsReplacing; } } public static class DSPCalculator_Patch { private class Warpper { [HarmonyPostfix] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static void UIItemNode_Postfix(UIItemNode __instance) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown if (!((Object)(object)__instance.assemblerIconObj == (Object)null)) { ((UnityEvent)__instance.assemblerIconObj.GetComponent