Decompiled source of UXAssist v1.1.6
UXAssist.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using CommonAPI; using CommonAPI.Systems; using HarmonyLib; using Microsoft.CodeAnalysis; using UXAssist.Common; using UXAssist.UI; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Serialization; using UnityEngine.UI; using crecheng.DSPModSave; [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("UXAssist")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("DSP MOD - UXAssist")] [assembly: AssemblyFileVersion("1.1.6.0")] [assembly: AssemblyInformationalVersion("1.1.6+241c9ee605995a407a481202abdefb7907adacb3")] [assembly: AssemblyProduct("UXAssist")] [assembly: AssemblyTitle("UXAssist")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.6.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace UXAssist { public static class AuxilaryfunctionWrapper { private const string AuxilaryfunctionGuid = "cn.blacksnipe.dsp.Auxilaryfunction"; public static ConfigEntry<bool> ShowStationInfo; public static void Init(Harmony harmony) { if (!Chainloader.PluginInfos.TryGetValue("cn.blacksnipe.dsp.Auxilaryfunction", out var value)) { return; } Assembly assembly = ((object)value.Instance).GetType().Assembly; try { ShowStationInfo = (ConfigEntry<bool>)AccessTools.Field(assembly.GetType("Auxilaryfunction.Auxilaryfunction"), "ShowStationInfo").GetValue(value.Instance); } catch { UXAssist.Logger.LogWarning((object)"Failed to get ShowStationInfo from Auxilaryfunction"); } } } public static class DysonSpherePatch { private static class StopEjectOnNodeComplete { private static Harmony _patch; private static HashSet<int>[] _nodeForAbsorb; private static bool _initialized; public static void Enable(bool on) { if (on) { InitNodeForAbsorb(); if (_patch == null) { _patch = Harmony.CreateAndPatchAll(typeof(StopEjectOnNodeComplete), (string)null); } GameLogic.OnGameBegin = (Action)Delegate.Combine(GameLogic.OnGameBegin, new Action(GameMain_Begin_Postfix)); GameLogic.OnGameEnd = (Action)Delegate.Combine(GameLogic.OnGameEnd, new Action(GameMain_End_Postfix)); return; } GameLogic.OnGameEnd = (Action)Delegate.Remove(GameLogic.OnGameEnd, new Action(GameMain_End_Postfix)); GameLogic.OnGameBegin = (Action)Delegate.Remove(GameLogic.OnGameBegin, new Action(GameMain_Begin_Postfix)); Harmony patch = _patch; if (patch != null) { patch.UnpatchSelf(); } _patch = null; _initialized = false; _nodeForAbsorb = null; } private static void InitNodeForAbsorb() { _initialized = false; _nodeForAbsorb = null; GameData data = GameMain.data; GalaxyData val = data?.galaxy; if (val == null) { return; } int starCount = val.starCount; _nodeForAbsorb = new HashSet<int>[starCount]; DysonSphere[] dysonSpheres = data.dysonSpheres; if (dysonSpheres == null) { return; } DysonSphere[] array = dysonSpheres; foreach (DysonSphere val2 in array) { if (val2?.layersSorted == null) { continue; } int index = val2.starData.index; if (index >= starCount) { continue; } DysonSphereLayer[] layersSorted = val2.layersSorted; foreach (DysonSphereLayer val3 in layersSorted) { if (val3 == null) { continue; } for (int num = val3.nodeCursor - 1; num > 0; num--) { DysonNode val4 = val3.nodePool[num]; if (val4 != null && val4.id == num && val4.sp >= val4.spMax && val4.cpReqOrder != 0) { SetNodeForAbsorb(index, val3.id, val4.id, canAbsorb: true); } } } } _initialized = true; } private static void SetNodeForAbsorb(int index, int layerId, int nodeId, bool canAbsorb) { ref HashSet<int> reference = ref _nodeForAbsorb[index]; if (reference == null) { reference = new HashSet<int>(); } int item = nodeId * 10 + layerId; if (canAbsorb) { reference.Add(item); } else { reference.Remove(item); } } private static void UpdateNodeForAbsorbOnSpChange(DysonNode node) { if (_initialized && node.sp >= node.spMax && node.cpReqOrder > 0) { List<DysonShell> shells = node.shells; if (shells.Count != 0) { SetNodeForAbsorb(shells[0].dysonSphere.starData.index, node.layerId, node.id, canAbsorb: true); } } } private static void UpdateNodeForAbsorbOnCpChange(DysonNode node) { if (_initialized && node.sp >= node.spMax && node.cpReqOrder <= 0) { List<DysonShell> shells = node.shells; if (shells.Count != 0) { SetNodeForAbsorb(shells[0].dysonSphere.starData.index, node.layerId, node.id, canAbsorb: false); } } } private static bool AnyNodeForAbsorb(int starIndex) { HashSet<int> hashSet = _nodeForAbsorb[starIndex]; if (hashSet != null) { return hashSet.Count > 0; } return false; } private static void GameMain_Begin_Postfix() { InitNodeForAbsorb(); } private static void GameMain_End_Postfix() { _initialized = false; _nodeForAbsorb = null; } [HarmonyPostfix] [HarmonyPatch(typeof(DysonNode), "RecalcCpReq")] private static void DysonNode_RecalcCpReq_Postfix(DysonNode __instance) { UpdateNodeForAbsorbOnCpChange(__instance); } [HarmonyPrefix] [HarmonyPatch(typeof(DysonSphereLayer), "RemoveDysonNode")] private static void DysonSphereLayer_RemoveDysonNode_Prefix(DysonSphereLayer __instance, int nodeId) { if (_initialized) { SetNodeForAbsorb(__instance.starData.index, __instance.id, nodeId, canAbsorb: false); } } [HarmonyPrefix] [HarmonyPatch(typeof(DysonSphere), "ResetNew")] private static void DysonSphere_ResetNew_Prefix(DysonSphere __instance) { if (_nodeForAbsorb != null) { int index = __instance.starData.index; if (index < _nodeForAbsorb.Length && _nodeForAbsorb[index] != null) { _nodeForAbsorb[index].Clear(); _nodeForAbsorb[index] = null; } } } [HarmonyTranspiler] [HarmonyPatch(typeof(EjectorComponent), "InternalUpdate")] private static IEnumerable<CodeInstruction> EjectorComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(EjectorComponent), "orbitId"), (string)null), new CodeMatch((OpCode?)OpCodes.Brtrue, (object)null, (string)null) }).Advance(2).Insert((CodeInstruction[])(object)new CodeInstruction[7] { new CodeInstruction(OpCodes.Ldc_I4_0, (object)null), new CodeInstruction(OpCodes.Cgt, (object)null), new CodeInstruction(OpCodes.Ldarg_2, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(DysonSwarm), "starData")), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(StarData), "index")), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(StopEjectOnNodeComplete), "AnyNodeForAbsorb", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.And, (object)null) }); return val.InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch(typeof(DysonNode), "ConstructSp")] private static IEnumerable<CodeInstruction> DysonNode_ConstructSp_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.Start().MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(DysonNode), "sp"), (string)null) }).Advance(1); List<Label> labels = val.Labels; val.Labels = new List<Label>(); val.Insert((CodeInstruction[])(object)new CodeInstruction[2] { CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldarg_0, (object)null), (IEnumerable<Label>)labels), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(StopEjectOnNodeComplete), "UpdateNodeForAbsorbOnSpChange", (Type[])null, (Type[])null)) }); return val.InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch(typeof(DysonNode), "ConstructCp")] private static IEnumerable<CodeInstruction> DysonNode_ConstructCp_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchBack(false, (CodeMatch[])(object)new CodeMatch[6] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(DysonNode), "_cpReq"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Sub, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(DysonNode), "_cpReq"), (string)null) }).Advance(6).Insert((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(StopEjectOnNodeComplete), "UpdateNodeForAbsorbOnCpChange", (Type[])null, (Type[])null)) }); return val.InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch(typeof(UIEjectorWindow), "_OnUpdate")] private static IEnumerable<CodeInstruction> UIEjectorWindow__OnUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Expected O, but got Unknown //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); Label label = generator.DefineLabel(); Label label2 = generator.DefineLabel(); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"待机", (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Localization), "Translate", (Type[])null, (Type[])null), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.PropertySetter(typeof(Text), "text"), (string)null) }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[7] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(UIEjectorWindow), "factorySystem")), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(FactorySystem), "planet")), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(PlanetData), "star")), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(StarData), "index")), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(StopEjectOnNodeComplete), "AnyNodeForAbsorb", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Brfalse, (object)label) }).Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Br, (object)label2), CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldstr, (object)"[UXAssist] No node to fill"), new Label[1] { label }), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Localization), "Translate", (Type[])null, (Type[])null)) }) .Labels.Add(label2); return val.InstructionEnumeration(); } } private static class OnlyConstructNodes { private static Harmony _patch; public static void Enable(bool on) { if (on) { if (_patch == null) { _patch = Harmony.CreateAndPatchAll(typeof(OnlyConstructNodes), (string)null); } } else { Harmony patch = _patch; if (patch != null) { patch.UnpatchSelf(); } _patch = null; } DysonSphere[] array = GameMain.data?.dysonSpheres; if (array == null) { return; } DysonSphere[] array2 = array; foreach (DysonSphere val in array2) { if (val != null) { val.CheckAutoNodes(); if (val.autoNodeCount <= 0) { val.PickAutoNode(); val.PickAutoNode(); val.PickAutoNode(); val.PickAutoNode(); } } } } [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static IEnumerable<CodeInstruction> DysonNode_spReqOrder_Getter_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(DysonNode), "_spReq"), (string)null) }).Advance(1).SetInstructionAndAdvance(new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(DysonNode), "spMax"))) .Insert((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(DysonNode), "sp")), new CodeInstruction(OpCodes.Sub, (object)null) }); return val.InstructionEnumeration(); } } public static ConfigEntry<bool> StopEjectOnNodeCompleteEnabled; public static ConfigEntry<bool> OnlyConstructNodesEnabled; public static ConfigEntry<int> AutoConstructMultiplier; private static Harmony _dysonSpherePatch; private static FieldInfo _totalNodeSpInfo; private static FieldInfo _totalFrameSpInfo; private static FieldInfo _totalCpInfo; public static void Init() { I18N.Add("[UXAssist] No node to fill", "[UXAssist] No node to fill", "[UXAssist] 无可建造节点"); if (_dysonSpherePatch == null) { _dysonSpherePatch = Harmony.CreateAndPatchAll(typeof(DysonSpherePatch), (string)null); } StopEjectOnNodeCompleteEnabled.SettingChanged += delegate { StopEjectOnNodeComplete.Enable(StopEjectOnNodeCompleteEnabled.Value); }; OnlyConstructNodesEnabled.SettingChanged += delegate { OnlyConstructNodes.Enable(OnlyConstructNodesEnabled.Value); }; StopEjectOnNodeComplete.Enable(StopEjectOnNodeCompleteEnabled.Value); OnlyConstructNodes.Enable(OnlyConstructNodesEnabled.Value); _totalNodeSpInfo = AccessTools.Field(typeof(DysonSphereLayer), "totalNodeSP"); _totalFrameSpInfo = AccessTools.Field(typeof(DysonSphereLayer), "totalFrameSP"); _totalCpInfo = AccessTools.Field(typeof(DysonSphereLayer), "totalCP"); } public static void Uninit() { StopEjectOnNodeComplete.Enable(on: false); OnlyConstructNodes.Enable(on: false); Harmony dysonSpherePatch = _dysonSpherePatch; if (dysonSpherePatch != null) { dysonSpherePatch.UnpatchSelf(); } _dysonSpherePatch = null; } public static void InitCurrentDysonSphere(int index) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown StarData localStar = GameMain.localStar; if (localStar == null) { return; } DysonSphere[] array = GameMain.data?.dysonSpheres; if (array == null) { return; } if (index < 0) { if (array[localStar.index] != null) { DysonSphere val = new DysonSphere(); array[localStar.index] = val; val.Init(GameMain.data, localStar); val.ResetNew(); } return; } DysonSphere val2 = array[localStar.index]; if (((val2 != null) ? val2.layersIdBased[index] : null) == null) { return; } DysonRocket[] rocketPool = val2.rocketPool; for (int num = val2.rocketCursor - 1; num > 0; num--) { if (rocketPool[num].id == num && rocketPool[num].nodeLayerId == index) { val2.RemoveDysonRocket(num); } } val2.RemoveLayer(index); } [HarmonyPrefix] [HarmonyPatch(typeof(DysonSwarm), "AutoConstruct")] private static bool DysonSwarm_AutoConstruct_Prefix(DysonSwarm __instance) { return __instance.dysonSphere.autoNodeCount == 0; } [HarmonyPrefix] [HarmonyPatch(typeof(DysonSphere), "AutoConstruct")] private static bool DysonSphere_AutoConstruct_Prefix(DysonSphere __instance) { int num = AutoConstructMultiplier.Value * 6; DysonSphereLayer[] layersIdBased = __instance.layersIdBased; foreach (DysonSphereLayer val in layersIdBased) { if (val == null) { continue; } for (int num2 = val.nodePool.Length - 1; num2 >= 0; num2--) { DysonNode val2 = val.nodePool[num2]; if (val2 != null && val2.id == num2) { int num3 = val2._spReq - val2.spOrdered; if (num3 > 0) { if (num3 > num) { num3 = num; } int num4 = num3; if (val2.sp < val2.spMax) { int num5; if (val2.sp + num3 > val2.spMax) { num5 = val2.spMax - val2.sp; num3 -= num5; val2._spReq -= num5; val2.sp = val2.spMax; } else { num5 = num3; val2._spReq -= num5; val2.sp += num5; num3 = 0; } if (_totalNodeSpInfo != null) { _totalNodeSpInfo.SetValue(val, (long)_totalNodeSpInfo.GetValue(val) + num5 - 1); } __instance.UpdateProgress(val2); } if (num3 > 0) { int count = val2.frames.Count; int num6 = val2.frameTurn % count; int num7 = count; while (num7 > 0 && num3 > 0) { DysonFrame val3 = val2.frames[num6]; int num8 = val3.spMax >> 1; if (val3.nodeA == val2 && val3.spA < num8) { int num9; if (val3.spA + num3 > num8) { num9 = num8 - val3.spA; num3 -= num9; val2._spReq -= num9; val3.spA = num8; } else { num9 = num3; val2._spReq -= num9; val3.spA += num9; num3 = 0; } if (_totalFrameSpInfo != null) { _totalFrameSpInfo.SetValue(val, (long)_totalFrameSpInfo.GetValue(val) + num9 - 1); } __instance.UpdateProgress(val3); } if (num3 > 0 && val3.nodeB == val2 && val3.spB < num8) { int num10; if (val3.spB + num3 > num8) { num10 = num8 - val3.spB; num3 -= num10; val2._spReq -= num10; val3.spB = num8; } else { num10 = num3; val2._spReq -= num10; val3.spB += num10; num3 = 0; } if (_totalFrameSpInfo != null) { _totalFrameSpInfo.SetValue(val, (long)_totalFrameSpInfo.GetValue(val) + num10 - 1); } __instance.UpdateProgress(val3); } num6 = (num6 + 1) % count; num7--; } val2.frameTurn = num6; } if (val2.spOrdered >= val2._spReq) { __instance.RemoveAutoNode(val2); __instance.PickAutoNode(); } int[] productRegister = __instance.productRegister; if (productRegister != null) { lock (productRegister) { productRegister[11902] += num4 - num3; } } } num3 = val2._cpReq - val2.cpOrdered; if (num3 > 0) { if (num3 > num) { num3 = num; } int num4 = num3; int count2 = val2.shells.Count; int num11 = val2.shellTurn % count2; int num12 = count2; while (num12 > 0 && num3 > 0) { DysonShell val4 = val2.shells[num11]; int num13 = val4.nodeIndexMap[val2.id]; int num14 = (val4.vertsqOffset[num13 + 1] - val4.vertsqOffset[num13]) * val4.cpPerVertex - val4.nodecps[num13]; if (num14 > num3) { num14 = num3; } num3 -= num14; val2._cpReq -= num14; val4.nodecps[num13] += num14; val4.nodecps[val4.nodecps.Length - 1] += num14; if (_totalCpInfo != null) { _totalCpInfo.SetValue(val, (long)_totalCpInfo.GetValue(val) + num14); val4.SetMaterialDynamicVars(); } num11 = (num11 + 1) % count2; num12--; } val2.shellTurn = num11; int num15 = num4 - num3; int[] productRegister = __instance.productRegister; if (productRegister != null) { lock (productRegister) { productRegister[11901] += num15; productRegister[11903] += num15; } } int[] consumeRegister = __instance.consumeRegister; if (consumeRegister != null) { lock (consumeRegister) { consumeRegister[11901] += num15; } } } } } } return false; } [HarmonyTranspiler] [HarmonyPriority(800)] [HarmonyPatch(typeof(DysonNode), "ConstructCp")] private static IEnumerable<CodeInstruction> DysonSpherePatch_DysonNode_ConstructCp_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchBack(false, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(DysonShell), "Construct", (Type[])null, (Type[])null), (string)null) }).Advance(3).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[6] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(DysonNode), "_cpReq")), new CodeInstruction(OpCodes.Ldc_I4_1, (object)null), new CodeInstruction(OpCodes.Sub, (object)null), new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(DysonNode), "_cpReq")) }); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(DysonNode), "RecalcCpReq", (Type[])null, (Type[])null), (string)null) }); List<Label> labels = val.Labels; val.RemoveInstructions(2).Labels.AddRange(labels); return val.InstructionEnumeration(); } } public static class FactoryPatch { public static class NightLight { private static Harmony _patch; private const float NightLightAngleX = -8f; private const float NightLightAngleY = -2f; public static bool Enabled; private static bool _nightlightInitialized; private static bool _mechaOnEarth; private static AnimationState _sail; private static Light _sunlight; public static void Enable(bool on) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (on) { Enabled = _mechaOnEarth; if (_patch == null) { _patch = Harmony.CreateAndPatchAll(typeof(NightLight), (string)null); } return; } Enabled = false; Harmony patch = _patch; if (patch != null) { patch.UnpatchSelf(); } _patch = null; if (!((Object)(object)_sunlight == (Object)null)) { ((Component)_sunlight).transform.localEulerAngles = new Vector3(0f, 180f); } } public static void LateUpdate() { if (_patch != null) { if (!_nightlightInitialized) { Ready(); } else { Go(); } } } private static void Ready() { if (GameMain.isRunning && ((Component)GameMain.mainPlayer.controller.model).gameObject.activeInHierarchy) { if ((TrackedReference)(object)_sail == (TrackedReference)null) { _sail = GameMain.mainPlayer.animator.sails[GameMain.mainPlayer.animator.sailAnimIndex]; } _nightlightInitialized = true; } } private static void Go() { //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) if (!GameMain.isRunning) { End(); return; } if (TrackedReference.op_Implicit((TrackedReference)(object)_sail) && _sail.enabled) { _mechaOnEarth = false; Enabled = false; if (Object.op_Implicit((Object)(object)_sunlight) && Object.op_Implicit((Object)(object)((Component)_sunlight).transform)) { ((Component)_sunlight).transform.localEulerAngles = new Vector3(0f, 180f); _sunlight = null; } return; } if (!_mechaOnEarth) { if (!Object.op_Implicit((Object)(object)_sunlight)) { UniverseSimulator universeSimulator = GameMain.universeSimulator; if (Object.op_Implicit((Object)(object)universeSimulator)) { _sunlight = universeSimulator.LocalStarSimulator()?.sunLight; } if (!Object.op_Implicit((Object)(object)_sunlight)) { return; } } _mechaOnEarth = true; Enabled = NightLightEnabled.Value; } if (Enabled && Object.op_Implicit((Object)(object)_sunlight)) { ((Component)_sunlight).transform.rotation = Quaternion.LookRotation(-GameMain.mainPlayer.transform.up + GameMain.mainPlayer.transform.forward * -8f / 10f + GameMain.mainPlayer.transform.right * -2f / 10f); } } private static void End() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) _mechaOnEarth = false; Enabled = false; if ((Object)(object)_sunlight != (Object)null) { ((Component)_sunlight).transform.localEulerAngles = new Vector3(0f, 180f); _sunlight = null; } _sail = null; _nightlightInitialized = false; } [HarmonyTranspiler] [HarmonyPatch(typeof(StarSimulator), "LateUpdate")] private static IEnumerable<CodeInstruction> StarSimulator_LateUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); Label label = generator.DefineLabel(); Label label2 = generator.DefineLabel(); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(Component), "transform"), (string)null) }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[7] { new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(NightLight), "Enabled")), new CodeInstruction(OpCodes.Brfalse_S, (object)label), new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(GameMain), "mainPlayer")), new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(Player), "transform")), new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(Transform), "up")), new CodeInstruction(OpCodes.Stloc_0, (object)null), new CodeInstruction(OpCodes.Br_S, (object)label2) }); val.Labels.Add(label); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null) }).Advance(1).Labels.Add(label2); return val.InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch(typeof(PlanetSimulator), "LateUpdate")] private static IEnumerable<CodeInstruction> PlanetSimulator_LateUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); Label label = generator.DefineLabel(); Label label2 = generator.DefineLabel(); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stloc_1, (object)null, (string)null) }).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[7] { new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(NightLight), "Enabled")), new CodeInstruction(OpCodes.Brfalse_S, (object)label), new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(GameMain), "mainPlayer")), new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(Player), "transform")), new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(Transform), "up")), new CodeInstruction(OpCodes.Stloc_2, (object)null), new CodeInstruction(OpCodes.Br_S, (object)label2) }); val.Labels.Add(label); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldsfld, (object)AccessTools.Field(typeof(FactoryModel), "whiteMode0"), (string)null) }).Labels.Add(label2); return val.InstructionEnumeration(); } } private static class UnlimitInteractive { private static Harmony _patch; public static void Enable(bool enable) { if (enable) { if (_patch == null) { _patch = Harmony.CreateAndPatchAll(typeof(UnlimitInteractive), (string)null); } return; } Harmony patch = _patch; if (patch != null) { patch.UnpatchSelf(); } _patch = null; } [HarmonyTranspiler] [HarmonyPatch(typeof(PlayerAction_Inspect), "GetObjectSelectDistance")] private static IEnumerable<CodeInstruction> PlayerAction_Inspect_GetObjectSelectDistance_Transpiler(IEnumerable<CodeInstruction> instructions) { yield return new CodeInstruction(OpCodes.Ldc_R4, (object)10000f); yield return new CodeInstruction(OpCodes.Ret, (object)null); } } private static class RemoveSomeConditionBuild { private static Harmony _patch; public static void Enable(bool on) { if (on) { if (_patch == null) { _patch = Harmony.CreateAndPatchAll(typeof(RemoveSomeConditionBuild), (string)null); } return; } Harmony patch = _patch; if (patch != null) { patch.UnpatchSelf(); } _patch = null; } [HarmonyTranspiler] [HarmonyPriority(800)] [HarmonyPatch(typeof(BuildTool_BlueprintPaste), "CheckBuildConditions")] [HarmonyPatch(typeof(BuildTool_Click), "CheckBuildConditions")] private static IEnumerable<CodeInstruction> BuildTool_Click_CheckBuildConditions_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); Label? label = default(Label?); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[6] { new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(BuildPreview), "desc"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(PrefabDesc), "isInserter"), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.Branches(ci, ref label)), (string)null), new CodeMatch((OpCode?)OpCodes.Ldloca_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(Vector3), "magnitude"), (string)null) }); object operand = val.InstructionAt(3).operand; List<Label> labels = val.Labels; val.Labels = new List<Label>(); val.Insert((CodeInstruction[])(object)new CodeInstruction[1] { CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Br, operand), (IEnumerable<Label>)labels) }); return val.InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPriority(800)] [HarmonyPatch(typeof(BuildTool_Path), "CheckBuildConditions")] private static IEnumerable<CodeInstruction> BuildTool_Path_CheckBuildConditions_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Expected O, but got Unknown //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Expected O, but got Unknown //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); Label? label2 = default(Label?); Label? label = default(Label?); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[7] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.IsLdloc(ci, (LocalBuilder)null)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.IsLdloc(ci, (LocalBuilder)null)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.Branches(ci, ref label2)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => ci.opcode == OpCodes.Ldc_I4_S && CodeInstructionExtensions.OperandIs(ci, (object)20)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.Branches(ci, ref label)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => ci.opcode == OpCodes.Ldc_I4_S && CodeInstructionExtensions.OperandIs(ci, (object)18)), (string)null), new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(BuildPreview), "condition"), (string)null) }); if (val.IsValid) { List<Label> labels = val.Labels; val.Labels = new List<Label>(); val.RemoveInstructions(7); OpCode opcode = val.Opcode; if (opcode == OpCodes.Br || opcode == OpCodes.Br_S) { val.RemoveInstruction(); } val.Labels.AddRange(labels); } val.Start().MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instr) => instr.opcode == OpCodes.Ldloc_S || instr.opcode == OpCodes.Ldloc), (string)null), new CodeMatch((Func<CodeInstruction, bool>)delegate(CodeInstruction instr) { if (instr.opcode == OpCodes.Ldc_I4_S || instr.opcode == OpCodes.Ldc_I4) { long num = Convert.ToInt64(instr.operand); if (num >= 16) { return num <= 21; } return false; } return false; }, (string)null), new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(BuildPreview), "condition"), (string)null) }); if (val.IsValid) { val.Repeat((Action<CodeMatcher>)delegate(CodeMatcher codeMatcher) { List<Label> labels2 = codeMatcher.Labels; codeMatcher.Labels = new List<Label>(); codeMatcher.RemoveInstructions(3); OpCode opcode2 = codeMatcher.Opcode; if (opcode2 == OpCodes.Br || opcode2 == OpCodes.Br_S) { codeMatcher.RemoveInstruction(); } codeMatcher.Labels.AddRange(labels2); }, (Action<string>)null); } return val.InstructionEnumeration(); } } private static class RemoveBuildRangeLimit { private static Harmony _patch; public static void Enable(bool enable) { if (enable) { if (_patch == null) { _patch = Harmony.CreateAndPatchAll(typeof(RemoveBuildRangeLimit), (string)null); } } else { Harmony patch = _patch; if (patch != null) { patch.UnpatchSelf(); } _patch = null; } Player mainPlayer = GameMain.mainPlayer; PlayerController val = ((mainPlayer != null) ? mainPlayer.controller : null); if ((Object)(object)val == (Object)null) { return; } PlayerAction_Build actionBuild = val.actionBuild; if (actionBuild != null) { BuildTool_Click clickTool = actionBuild.clickTool; if (clickTool != null) { ((BuildTool)clickTool)._OnInit(); } } } [HarmonyTranspiler] [HarmonyPatch(typeof(BuildTool_Click), "_OnInit")] private static IEnumerable<CodeInstruction> BuildTool_Click__OnInit_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => ci.opcode == OpCodes.Ldc_I4_S && CodeInstructionExtensions.OperandIs(ci, (object)15)), (string)null) }); val.Repeat((Action<CodeMatcher>)delegate(CodeMatcher m) { m.SetAndAdvance(OpCodes.Ldc_I4, (object)512); }, (Action<string>)null); return val.InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch(typeof(BuildTool_Addon), "CheckBuildConditions")] [HarmonyPatch(typeof(BuildTool_Click), "CheckBuildConditions")] [HarmonyPatch(typeof(BuildTool_Dismantle), "DetermineMoreChainTargets")] [HarmonyPatch(typeof(BuildTool_Dismantle), "DeterminePreviews")] [HarmonyPatch(typeof(BuildTool_Inserter), "CheckBuildConditions")] [HarmonyPatch(typeof(BuildTool_Path), "CheckBuildConditions")] [HarmonyPatch(typeof(BuildTool_Reform), "ReformAction")] [HarmonyPatch(typeof(BuildTool_Upgrade), "DetermineMoreChainTargets")] [HarmonyPatch(typeof(BuildTool_Upgrade), "DeterminePreviews")] private static IEnumerable<CodeInstruction> BuildAreaLimitRemoval_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[9] { new CodeMatch((OpCode?)null, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(BuildTool), "player"), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(Player), "mecha"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Mecha), "buildArea"), (string)null), new CodeMatch((OpCode?)null, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(BuildTool), "player"), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(Player), "mecha"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Mecha), "buildArea"), (string)null), new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null) }); val.Repeat((Action<CodeMatcher>)delegate(CodeMatcher m) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown m.RemoveInstructions(9).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_R4, (object)100000000f) }); }, (Action<string>)null); return val.InstructionEnumeration(); } } private static class LargerAreaForUpgradeAndDismantle { private static Harmony _patch; public static void Enable(bool enable) { if (enable) { if (_patch == null) { _patch = Harmony.CreateAndPatchAll(typeof(LargerAreaForUpgradeAndDismantle), (string)null); } return; } Harmony patch = _patch; if (patch != null) { patch.UnpatchSelf(); } _patch = null; } [HarmonyTranspiler] [HarmonyPatch(typeof(BuildTool_Dismantle), "DeterminePreviews")] [HarmonyPatch(typeof(BuildTool_Upgrade), "DeterminePreviews")] private static IEnumerable<CodeInstruction> BuildTools_CursorSizePatch_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => ci.opcode == OpCodes.Ldc_I4_S && CodeInstructionExtensions.OperandIs(ci, (object)11)), (string)null) }); val.Repeat((Action<CodeMatcher>)delegate(CodeMatcher m) { m.SetAndAdvance(OpCodes.Ldc_I4_S, (object)31); }, (Action<string>)null); return val.InstructionEnumeration(); } } private static class LargerAreaForTerraform { private static Harmony _patch; public static void Enable(bool enable) { if (enable) { if (_patch == null) { _patch = Harmony.CreateAndPatchAll(typeof(LargerAreaForTerraform), (string)null); } return; } Harmony patch = _patch; if (patch != null) { patch.UnpatchSelf(); } _patch = null; } [HarmonyTranspiler] [HarmonyPatch(typeof(BuildTool_Reform), "ReformAction")] private static IEnumerable<CodeInstruction> BuildTool_Reform_ReformAction_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(BuildTool_Reform), "brushSize"), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => ci.opcode == OpCodes.Ldc_I4_S && CodeInstructionExtensions.OperandIs(ci, (object)10)), (string)null) }); val.Repeat((Action<CodeMatcher>)delegate(CodeMatcher m) { m.Advance(1).SetAndAdvance(OpCodes.Ldc_I4_S, (object)30); }, (Action<string>)null); val.Start().MatchForward(false, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => ci.opcode == OpCodes.Ldc_I4_S && CodeInstructionExtensions.OperandIs(ci, (object)10)), (string)null), new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(BuildTool_Reform), "brushSize"), (string)null) }); val.Repeat((Action<CodeMatcher>)delegate(CodeMatcher m) { m.SetAndAdvance(OpCodes.Ldc_I4_S, (object)30); }, (Action<string>)null); return val.InstructionEnumeration(); } } public static class OffGridBuilding { private static Harmony _patch; private const float SteppedRotationDegrees = 15f; private static bool _initialized; private static PlanetData _lastPlanet; private static Vector3 _lastPos; private static string _lastOffsetText; public static void Enable(bool enable) { if (enable) { if (_patch == null) { _patch = Harmony.CreateAndPatchAll(typeof(OffGridBuilding), (string)null); } return; } Harmony patch = _patch; if (patch != null) { patch.UnpatchSelf(); } _patch = null; } [HarmonyPostfix] [HarmonyPatch(typeof(UIRoot), "_OnOpen")] public static void UIRoot__OnOpen_Postfix() { if (!_initialized) { UIGeneralTips.instance.buildCursorTextComp.supportRichText = true; UIGeneralTips.instance.entityBriefInfo.entityNameText.supportRichText = true; _initialized = true; } } private static void CalculateGridOffset(PlanetData planet, Vector3 pos, out float x, out float y, out float z) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) Vector3 normalized = ((Vector3)(ref pos)).normalized; int num = planet.aux.activeGrid?.segment ?? 200; float latitudeRadPerGrid = BlueprintUtils.GetLatitudeRadPerGrid(num); float longitudeRadPerGrid = BlueprintUtils.GetLongitudeRadPerGrid(BlueprintUtils.GetLongitudeSegmentCount(normalized, num), num); float latitudeRad = BlueprintUtils.GetLatitudeRad(normalized); float longitudeRad = BlueprintUtils.GetLongitudeRad(normalized); x = longitudeRad / longitudeRadPerGrid; y = latitudeRad / latitudeRadPerGrid; z = (((Vector3)(ref pos)).magnitude - planet.realRadius - 0.2f) / 1.3333333f; } private static string FormatOffsetFloat(float f) { return f.ToString("0.0000").TrimEnd(new char[1] { '0' }).TrimEnd(new char[1] { '.' }); } [HarmonyPostfix] [HarmonyPriority(0)] [HarmonyPatch(typeof(BuildTool_Click), "CheckBuildConditions")] [HarmonyPatch(typeof(BuildTool_Path), "CheckBuildConditions")] private static void BuildTool_Click_CheckBuildConditions_Postfix(BuildTool __instance) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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) int count = __instance.buildPreviews.Count; if (count == 0) { return; } BuildPreview val = __instance.buildPreviews[count - 1]; if (!val.desc.isInserter) { PlanetData planet = __instance.planet; if (_lastPlanet != planet || _lastPos != val.lpos) { CalculateGridOffset(__instance.planet, val.lpos, out var x, out var y, out var z); _lastPlanet = planet; _lastPos = val.lpos; _lastOffsetText = ((z < 0.001f && z > -0.001f) ? ("<color=#ffbfbfff>" + FormatOffsetFloat(x) + "</color>,<color=#bfffbfff>" + FormatOffsetFloat(y) + "</color>") : ("<color=#ffbfbfff>" + FormatOffsetFloat(x) + "</color>,<color=#bfffbfff>" + FormatOffsetFloat(y) + "</color>,<color=#bfbfffff>" + FormatOffsetFloat(z) + "</color>")); } __instance.actionBuild.model.cursorText = "(" + _lastOffsetText + ")\n" + __instance.actionBuild.model.cursorText; } } [HarmonyTranspiler] [HarmonyPatch(typeof(UIEntityBriefInfo), "_OnUpdate")] private static IEnumerable<CodeInstruction> UIEntityBriefInfo__OnUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(UIEntityBriefInfo), "entityNameText"), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(Text), "preferredWidth"), (string)null) }); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), Transpilers.EmitDelegate<Action<UIEntityBriefInfo>>((Action<UIEntityBriefInfo>)delegate(UIEntityBriefInfo entityBriefInfo) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) EntityData val2 = entityBriefInfo.factory.entityPool[entityBriefInfo.entityId]; if (val2.inserterId <= 0) { PlanetData planet = entityBriefInfo.factory.planet; if (_lastPlanet != planet || _lastPos != val2.pos) { CalculateGridOffset(planet, val2.pos, out var x, out var y, out var z); _lastPlanet = planet; _lastPos = val2.pos; _lastOffsetText = "<color=#ffbfbfff>" + FormatOffsetFloat(x) + "</color>,<color=#bfffbfff>" + FormatOffsetFloat(y) + "</color>,<color=#bfbfffff>" + FormatOffsetFloat(z) + "</color>"; } Text entityNameText = entityBriefInfo.entityNameText; entityNameText.text = entityNameText.text + " (" + _lastOffsetText + ")"; } }) }); return val.InstructionEnumeration(); } private static void MatchIgnoreGridAndCheckIfRotatable(CodeMatcher matcher, out Label? ifBlockEntryLabel, out Label? elseBlockEntryLabel) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Expected O, but got Unknown Label? thisIfBlockEntryLabel = null; Label? thisElseBlockEntryLabel = null; matcher.MatchForward(false, (CodeMatch[])(object)new CodeMatch[10] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.Calls(ci, AccessTools.PropertyGetter(typeof(VFInput), "_ignoreGrid"))), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.Branches(ci, ref thisElseBlockEntryLabel)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.IsLdarg(ci, (int?)null)), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.LoadsConstant(ci, (Enum)(object)(EMinerType)2)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.Branches(ci, ref thisIfBlockEntryLabel)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.IsLdarg(ci, (int?)null)), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null) }); ifBlockEntryLabel = thisIfBlockEntryLabel; elseBlockEntryLabel = thisElseBlockEntryLabel; } [HarmonyTranspiler] [HarmonyPatch(typeof(BuildTool_Click), "UpdateRaycast")] [HarmonyPatch(typeof(BuildTool_Click), "DeterminePreviews")] public static IEnumerable<CodeInstruction> AllowOffGridConstruction(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); MatchIgnoreGridAndCheckIfRotatable(val, out var ifBlockEntryLabel, out var _); if (val.IsInvalid) { return instructions; } val.Advance(2); val.Insert((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Br, (object)ifBlockEntryLabel.Value) }); return val.InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch(typeof(BuildTool_Click), "DeterminePreviews")] public static IEnumerable<CodeInstruction> PreventDraggingWhenOffGrid(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); Label? exitLabel = null; val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.Branches(ci, ref exitLabel)), (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.LoadsConstant(ci, 1L)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.StoresField(ci, AccessTools.Field(typeof(BuildTool_Click), "isDragging"))), (string)null) }); if (val.IsInvalid) { return instructions; } val.Advance(1); val.Insert((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(VFInput), "_ignoreGrid")), new CodeInstruction(OpCodes.Brtrue, (object)exitLabel) }); return val.InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch(typeof(BuildTool_Path), "UpdateRaycast")] public static IEnumerable<CodeInstruction> AllowOffGridConstructionForPath(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Expected O, but got Unknown //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Expected O, but got Unknown //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Expected O, but got Unknown //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Expected O, but got Unknown //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Expected O, but got Unknown //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Expected O, but got Unknown //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Expected O, but got Unknown //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Expected O, but got Unknown //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Expected O, but got Unknown //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Expected O, but got Unknown //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Expected O, but got Unknown //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Expected O, but got Unknown //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Expected O, but got Unknown //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Expected O, but got Unknown //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[10] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(BuildTool), "actionBuild"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(PlayerAction_Build), "planetAux"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(BuildTool_Path), "castGroundPos"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(BuildTool_Path), "castTerrain"), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(PlanetAuxData), "Snap", (Type[])null, (Type[])null), (string)null), new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(BuildTool_Path), "castGroundPosSnapped"), (string)null) }); if (val.IsInvalid) { return val.InstructionEnumeration(); } Label label = generator.DefineLabel(); Label label2 = generator.DefineLabel(); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[15] { new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(VFInput), "_switchModelStyle")), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(InputValue), "pressing")), new CodeInstruction(OpCodes.Brfalse, (object)label), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldflda, (object)AccessTools.Field(typeof(BuildTool_Path), "castGroundPos")), new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(Vector3), "normalized")), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(BuildTool_Path), "planet")), new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(PlanetData), "realRadius")), new CodeInstruction(OpCodes.Ldc_R4, (object)0.2f), new CodeInstruction(OpCodes.Add, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Vector3), "op_Multiply", new Type[2] { typeof(Vector3), typeof(float) }, (Type[])null)), new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(BuildTool_Path), "castGroundPosSnapped")), new CodeInstruction(OpCodes.Br, (object)label2) }).Labels.Add(label); val.Advance(10).Labels.Add(label2); return val.InstructionEnumeration(); } public static IEnumerable<CodeInstruction> PatchToPerformSteppedRotate(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); MatchIgnoreGridAndCheckIfRotatable(val, out var ifBlockEntryLabel, out var elseBlockEntryLabel); if (val.IsInvalid) { return instructions; } while (!val.Labels.Contains(elseBlockEntryLabel.Value)) { val.Advance(1); } Label? ifBlockExitLabel = null; val.MatchBack(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.Branches(ci, ref ifBlockExitLabel)), (string)null) }); if (val.IsInvalid) { return instructions; } while (!val.Labels.Contains(ifBlockEntryLabel.Value)) { val.Advance(-1); } CodeInstruction val2 = val.Instruction.Clone(); CodeInstruction val3 = CodeInstruction.LoadField(typeof(VFInput), "control", false); val.SetAndAdvance(val3.opcode, val3.operand); val.Insert((CodeInstruction[])(object)new CodeInstruction[1] { val2 }); Label label = default(Label); val.CreateLabel(ref label); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[4] { new CodeInstruction(OpCodes.Brfalse, (object)label), new CodeInstruction(OpCodes.Ldarg_0, (object)null), CodeInstruction.Call(typeof(OffGridBuilding), "RotateStepped", (Type[])null, (Type[])null), new CodeInstruction(OpCodes.Br, (object)ifBlockExitLabel) }); return val.InstructionEnumeration(); } public static void RotateStepped(BuildTool_Click instance) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) if (VFInput._rotate.onDown) { instance.yaw += 15f; instance.yaw = Mathf.Repeat(instance.yaw, 360f); instance.yaw = Mathf.Round(instance.yaw / 15f) * 15f; } if (VFInput._counterRotate.onDown) { instance.yaw -= 15f; instance.yaw = Mathf.Repeat(instance.yaw, 360f); instance.yaw = Mathf.Round(instance.yaw / 15f) * 15f; } } } public static class TreatStackingAsSingle { private static Harmony _patch; public static void Enable(bool enable) { if (enable) { if (_patch == null) { _patch = Harmony.CreateAndPatchAll(typeof(TreatStackingAsSingle), (string)null); } return; } Harmony patch = _patch; if (patch != null) { patch.UnpatchSelf(); } _patch = null; } [HarmonyTranspiler] [HarmonyPatch(typeof(MonitorComponent), "InternalUpdate")] private static IEnumerable<CodeInstruction> MonitorComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(MonitorComponent), "GetCargoAtIndexByFilter", (Type[])null, (Type[])null), (string)null) }); val.Advance(-3); object operand = val.Operand; val.Advance(4).Insert((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldloca, operand), new CodeInstruction(OpCodes.Ldc_I4_1, (object)null), new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(Cargo), "stack")) }); return val.InstructionEnumeration(); } } private static class QuickBuildAndDismantleLab { private static Harmony _patch; public static void Enable(bool enable) { if (enable) { if (_patch == null) { _patch = Harmony.CreateAndPatchAll(typeof(QuickBuildAndDismantleLab), (string)null); } return; } Harmony patch = _patch; if (patch != null) { patch.UnpatchSelf(); } _patch = null; } private static bool DetermineMoreLabsForDismantle(BuildTool dismantle, int id) { //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Expected O, but got Unknown //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown if (!VFInput._chainReaction) { return true; } PlanetFactory factory = dismantle.factory; ItemProto itemProto = dismantle.GetItemProto(id); int iD = ((Proto)itemProto).ID; PrefabDesc prefabDesc = itemProto.prefabDesc; if (!prefabDesc.isLab && !prefabDesc.isTank && (!prefabDesc.isStorage || prefabDesc.isBattleBase)) { return true; } bool flag = default(bool); int num2 = default(int); int num = default(int); factory.ReadObjectConn(id, 14, ref flag, ref num, ref num2); if (num > 0) { int num3 = default(int); while (true) { factory.ReadObjectConn(num, 14, ref flag, ref num3, ref num2); if (num3 <= 0) { break; } ItemProto itemProto2 = dismantle.GetItemProto(num); if (((Proto)itemProto2).ID != iD) { break; } PrefabDesc prefabDesc2 = itemProto2.prefabDesc; Pose objectPose = dismantle.GetObjectPose(num); BuildPreview item = new BuildPreview { item = itemProto2, desc = prefabDesc2, lpos = objectPose.position, lrot = objectPose.rotation, lpos2 = objectPose.position, lrot2 = objectPose.rotation, objId = num, needModel = (prefabDesc2.lodCount > 0 && (Object)(object)prefabDesc2.lodMeshes[0] != (Object)null), isConnNode = true }; dismantle.buildPreviews.Add(item); num = num3; } } num = id; int num4 = default(int); while (true) { factory.ReadObjectConn(num, 15, ref flag, ref num4, ref num2); if (num4 <= 0) { factory.ReadObjectConn(num, 13, ref flag, ref num4, ref num2); if (num4 <= 0) { break; } } num = num4; ItemProto itemProto3 = dismantle.GetItemProto(num); PrefabDesc prefabDesc3 = itemProto3.prefabDesc; Pose objectPose2 = dismantle.GetObjectPose(num); BuildPreview item2 = new BuildPreview { item = itemProto3, desc = prefabDesc3, lpos = objectPose2.position, lrot = objectPose2.rotation, lpos2 = objectPose2.position, lrot2 = objectPose2.rotation, objId = num, needModel = (prefabDesc3.lodCount > 0 && (Object)(object)prefabDesc3.lodMeshes[0] != (Object)null), isConnNode = true }; dismantle.buildPreviews.Add(item2); } return false; } private static void BuildLabsToTop(BuildTool_Click click) { if (!click.multiLevelCovering || !VFInput._chainReaction) { return; } PrefabDesc prefabDesc = ((BuildTool)click).GetPrefabDesc(click.castObjectId); if (!prefabDesc.isLab && !prefabDesc.isTank && (!prefabDesc.isStorage || prefabDesc.isBattleBase)) { return; } int num = (prefabDesc.isLab ? GameMain.history.labLevel : GameMain.history.storageLevel); PlanetFactory factory = ((BuildTool)click).factory; int i = 2; int castObjectId = click.castObjectId; bool flag = default(bool); int num2 = default(int); while (true) { factory.ReadObjectConn(castObjectId, 14, ref flag, ref castObjectId, ref num2); if (castObjectId <= 0) { break; } i++; } for (; i < num; i++) { click.UpdateRaycast(); click.DeterminePreviews(); ((BuildTool)click).UpdateCollidersForCursor(); click.UpdateCollidersForGiantBp(); BuildModel model = ((BuildTool)click).actionBuild.model; ((BuildTool)click).UpdatePreviewModels(model); if (!click.CheckBuildConditions()) { model.ClearAllPreviewsModels(); model.EarlyGameTickIgnoreActive(); break; } ((BuildTool)click).UpdatePreviewModelConditions(model); ((BuildTool)click).UpdateGizmos(model); click.CreatePrebuilds(); } } [HarmonyTranspiler] [HarmonyPatch(typeof(BuildTool_Dismantle), "DeterminePreviews")] private static IEnumerable<CodeInstruction> BuildTool_Dismantle_DeterminePreviews_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Ldloc_3, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(BuildPreview), "desc"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(PrefabDesc), "isBattleBase"), (string)null), new CodeMatch((OpCode?)OpCodes.Brfalse, (object)null, (string)null) }).Advance(-1); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[5] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldloc_3, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(BuildPreview), "objId")), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(QuickBuildAndDismantleLab), "DetermineMoreLabsForDismantle", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.And, (object)null) }); return val.InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch(typeof(BuildTool_Click), "_OnTick")] private static IEnumerable<CodeInstruction> BuildTool_Click__OnTick_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(BuildTool_Click), "CreatePrebuilds", (Type[])null, (Type[])null), (string)null) }).Advance(2); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(QuickBuildAndDismantleLab), "BuildLabsToTop", (Type[])null, (Type[])null)) }); return val.InstructionEnumeration(); } } public static class ProtectVeinsFromExhaustion { public static int KeepVeinAmount = 100; public static float KeepOilSpeed = 1f; private static int _keepOilAmount = Math.Max((int)(KeepOilSpeed / 4E-05f + 0.5f), 2500); private static Harmony _patch; public static void Enable(bool enable) { if (enable) { if (_patch == null) { _patch = Harmony.CreateAndPatchAll(typeof(ProtectVeinsFromExhaustion), (string)null); } return; } Harmony patch = _patch; if (patch != null) { patch.UnpatchSelf(); } _patch = null; } [HarmonyPrefix] [HarmonyPatch(typeof(MinerComponent), "InternalUpdate")] private static bool MinerComponent_InternalUpdate_Prefix(PlanetFactory factory, VeinData[] veinPool, float power, float miningRate, float miningSpeed, int[] productRegister, ref MinerComponent __instance, out uint __result) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected I4, but got Unknown //IL_076b: Unknown result type (might be due to invalid IL or missing references) //IL_0771: Invalid comparison between Unknown and I4 //IL_0784: Unknown result type (might be due to invalid IL or missing references) //IL_078a: Invalid comparison between Unknown and I4 //IL_0825: Unknown result type (might be due to invalid IL or missing references) //IL_082b: Invalid comparison between Unknown and I4 //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_05cf: Unknown result type (might be due to invalid IL or missing references) //IL_05d9: Expected I4, but got Unknown //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Expected I4, but got Unknown //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) if (power < 0.1f) { __result = 0u; return false; } uint num = 0u; EMinerType type = __instance.type; switch (type - 1) { case 1: { if (__instance.veinCount <= 0) { break; } if (__instance.time <= __instance.period) { __instance.time += (int)(power * __instance.speedDamper * (float)__instance.speed * miningSpeed * (float)__instance.veinCount); num = 1u; } if (__instance.time < __instance.period) { break; } int num3 = __instance.veins[__instance.currentVeinIndex]; lock (veinPool) { if (veinPool[num3].id == 0) { ((MinerComponent)(ref __instance)).RemoveVeinFromArray(__instance.currentVeinIndex); ((MinerComponent)(ref __instance)).GetMinimumVeinAmount(factory, veinPool); if (__instance.veinCount > 1) { __instance.currentVeinIndex %= __instance.veinCount; } else { __instance.currentVeinIndex = 0; } __instance.time += (int)(power * __instance.speedDamper * (float)__instance.speed * miningSpeed * (float)__instance.veinCount); __result = 0u; return false; } if (__instance.productCount >= 50 || (__instance.productId != 0 && __instance.productId != veinPool[num3].productId)) { break; } __instance.productId = veinPool[num3].productId; int num2 = __instance.time / __instance.period; int num4 = 0; int amount = veinPool[num3].amount; if (amount > KeepVeinAmount) { if (miningRate > 0f) { int num5 = 0; int num6 = amount - KeepVeinAmount; if (miningRate < 0.99999f) { for (int i = 0; i < num2; i++) { __instance.seed = (uint)((int)((ulong)((long)(__instance.seed % 2147483646 + 1) * 48271L) % 2147483647uL) - 1); num5 += (((double)__instance.seed / 2147483646.0 < (double)miningRate) ? 1 : 0); num4++; if (num5 == num6) { break; } } } else { num4 = ((num2 > num6) ? num6 : num2); num5 = num4; } if (num5 > 0) { int groupIndex = veinPool[num3].groupIndex; amount = (veinPool[num3].amount -= num5); if (amount < __instance.minimumVeinAmount) { __instance.minimumVeinAmount = amount; } factory.veinGroups[groupIndex].amount -= num5; factory.veinAnimPool[num3].time = ((amount >= 20000) ? 0f : 0.99995f); if (amount <= 0) { int num7 = (int)veinPool[num3].type; Vector3 pos = veinPool[num3].pos; factory.RemoveVeinWithComponents(num3); factory.RecalculateVeinGroup(groupIndex); factory.NotifyVeinExhausted(num7, pos); ((MinerComponent)(ref __instance)).RemoveVeinFromArray(__instance.currentVeinIndex); ((MinerComponent)(ref __instance)).GetMinimumVeinAmount(factory, veinPool); } else { __instance.currentVeinIndex++; } } } else { num4 = num2; } __instance.productCount += num4; lock (productRegister)