using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DSP_AssemblerUI.AssemblerSpeedUI.Patchers;
using DSP_AssemblerUI.AssemblerSpeedUI.Util;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("DSP_AssemblerUI")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DSP_AssemblerUI")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7ede0ba0-773b-43c0-8f28-a448a54dca31")]
[assembly: AssemblyFileVersion("3.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("3.0.0.0")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 DSP_AssemblerUI
{
public static class PluginInfo
{
public const string PLUGIN_GUID = "DSP_AssemblerUI";
public const string PLUGIN_NAME = "DSP_AssemblerUI";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace DSP_AssemblerUI.AssemblerSpeedUI
{
[BepInPlugin("dsp.assemblerUI.speedMod", "Assembler UI Speed Info Mod", "3.0.0.0")]
public class AssemblerSpeedUIMod : BaseUnityPlugin
{
internal Harmony harmony = new Harmony("dsp.assemblerUI.speedMod");
internal static readonly ManualLogSource Logger = Logger.CreateLogSource("Assembler UI Speed Info Mod");
public static ConfigEntry<bool> configEnableOutputSpeeds = null;
public static ConfigEntry<bool> configEnableInputSpeeds = null;
public static ConfigEntry<bool> configInputSpeedsPerSecond = null;
public static ConfigEntry<bool> configOutputSpeedsPerSecond = null;
public static ConfigEntry<bool> configShowLiveSpeed = null;
public static ConfigEntry<uint> configShownDecimalPlaces = null;
public static ConfigEntry<bool> configShowMinerSpeed = null;
public static ConfigEntry<bool> configShowMinerLiveSpeed = null;
public static ConfigEntry<bool> configMinerSpeedsPerSecond = null;
[Conditional("DEBUG")]
internal static void LogDebug(string message)
{
Logger.LogInfo((object)message);
}
internal void Awake()
{
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Expected O, but got Unknown
configEnableOutputSpeeds = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableOutputSpeedInfo", true, "Enables the speed information below the output area in the Assembler Window.");
configEnableInputSpeeds = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableInputSpeedInfo", true, "Enables the speed information above the input area in the Assembler Window.");
configOutputSpeedsPerSecond = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableOutputSpeedInfoPerSecond", false, "Sets the output speeds shown in Assemblers to items/s (default: items/min).");
configInputSpeedsPerSecond = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableInputSpeedInfoPerSecond", false, "Sets the input speeds shown in Assemblers to items/s (default: items/min).");
configShowLiveSpeed = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowLiveSpeedInfo", false, "True: shows current speed of production building. False: shows regular recipe speed of production building.");
configShownDecimalPlaces = ((BaseUnityPlugin)this).Config.Bind<uint>("General", "NumberOfDecimalsShown", 1u, new ConfigDescription($"Sets the number of decimal places shown for speed values. Value must be in range [{0u},{3u}].", (AcceptableValueBase)(object)new AcceptableValueRange<uint>(0u, 3u), Array.Empty<object>()));
configShowMinerSpeed = ((BaseUnityPlugin)this).Config.Bind<bool>("Miner", "EnableMinerSpeedInfo", true, "Enables the speed information below the output area in the Miner Window.");
configShowMinerLiveSpeed = ((BaseUnityPlugin)this).Config.Bind<bool>("Miner", "ShowMinerLiveSpeedInfo", false, "True: shows current speed of production building. False: shows regular recipe speed of production building.");
configMinerSpeedsPerSecond = ((BaseUnityPlugin)this).Config.Bind<bool>("Miner", "EnableMinerOutputSpeedInfoPerSecond", false, "Sets the output speeds shown in Miners to items/s (default: items/min).");
UIAssemblerWindowPatch.additionalSpeedLabels = new AdditionalSpeedLabels(configEnableOutputSpeeds.Value, configEnableInputSpeeds.Value, Constants.AssemblerWindowSpeedTextPath);
UIMinerWindowPatch.additionalSpeedLabels = new AdditionalSpeedLabels(configShowMinerSpeed.Value, setupInputLabels: false, Constants.MinerWindowSpeedTextPath);
try
{
harmony.PatchAll(typeof(UIAssemblerWindowPatch));
harmony.PatchAll(typeof(UIMinerWindowPatch));
}
catch (Exception ex)
{
Logger.LogError((object)ex.Message);
Logger.LogError((object)ex.StackTrace);
}
}
internal void OnDestroy()
{
Harmony obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
UIAssemblerWindowPatch.additionalSpeedLabels.Destroy();
UIMinerWindowPatch.additionalSpeedLabels.Destroy();
}
}
internal static class Constants
{
public static readonly string BaseWindowsPath = "UI Root/Overlay Canvas/In Game/Windows";
public static readonly string AssemblerWindowPath = BaseWindowsPath + "/Assembler Window";
public static readonly string AssemblerWindowSpeedTextPath = AssemblerWindowPath + "/produce/speed/speed-text";
public static readonly string MinerWindowPath = BaseWindowsPath + "/Miner Window";
public static readonly string MinerWindowSpeedTextPath = MinerWindowPath + "/produce/speed/speed-text";
public const uint MIN_DECIMAL_PLACES = 0u;
public const uint MAX_DECIMAL_PLACES = 3u;
public const float INPUT_YPOS = 25f;
public const float OUTPUT_YPOS = -50f;
public const float INPUT_FIRST_X_OFFSET = 130f;
public const float OUTPUT_FIRST_X_OFFSET = 1f;
public const float INPUT_X_ITEMSIZE = 50f;
public const float OUTPUT_X_ITEMSIZE = 64f;
public const float INPUT_MAXWIDTH = 48f;
public const float OUTPUT_MAXWIDTH = 62f;
public const int MAX_FONTSIZE = 12;
}
public static class ModInfo
{
public const string ModID = "dsp.assemblerUI.speedMod";
public const string ModName = "Assembler UI Speed Info Mod";
public const string majorVersion = "3";
public const string minorVersion = "0";
public const string hotfixVersion = "0";
public const string buildVersion = "0";
public const string VersionString = "3.0.0.0";
}
}
namespace DSP_AssemblerUI.AssemblerSpeedUI.Util
{
public class AdditionalSpeedLabels
{
[CompilerGenerated]
private sealed class <PositionSpeedLabel>d__21 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public ItemSpeedInfoLabel labelData;
public int ofNum;
public AdditionalSpeedLabels <>4__this;
private RectTransform <targetTransform>5__2;
private float <sizeLimit>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <PositionSpeedLabel>d__21(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<targetTransform>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
//IL_00c6: 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_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: 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_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
AdditionalSpeedLabels additionalSpeedLabels = <>4__this;
Rect rect;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<targetTransform>5__2 = (RectTransform)((Component)labelData.Fitter).transform;
<sizeLimit>5__3 = (labelData.IsInput ? 48f : 62f);
<>2__current = null;
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
goto IL_00c0;
case 2:
<>1__state = -1;
goto IL_00c0;
case 3:
{
<>1__state = -1;
break;
}
IL_00c0:
rect = <targetTransform>5__2.rect;
if (((Rect)(ref rect)).width < <sizeLimit>5__3 - 5f && labelData.Value.fontSize < 12)
{
labelData.Value.fontSize = Math.Min(12, labelData.Value.fontSize + 4);
<>2__current = null;
<>1__state = 2;
return true;
}
break;
}
rect = <targetTransform>5__2.rect;
if (((Rect)(ref rect)).width > <sizeLimit>5__3)
{
Text value = labelData.Value;
value.fontSize -= 1;
<>2__current = null;
<>1__state = 3;
return true;
}
int index = labelData.Index;
int num2 = ofNum;
bool isInput = labelData.IsInput;
float z = additionalSpeedLabels.vanillaSpeedPos.z;
rect = <targetTransform>5__2.rect;
Vector3 pos = GetPos(index, num2, isInput, z, ((Rect)(ref rect)).width);
((Transform)<targetTransform>5__2).localPosition = pos;
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private readonly string speedTextPath;
private const string OutputKeyBase = "assembler-speed-out-item";
private const string InputKeyBase = "assembler-speed-in-item";
private const int safetyIndexLimit = 5;
private readonly Dictionary<string, ItemSpeedInfoLabel> speedInfos;
private int speedInfosOutCount;
private int speedInfosInCount;
private Vector3 vanillaSpeedPos;
private int currentOutputs;
private int currentInputs;
private readonly bool setupOutputLabels;
private readonly bool setupInputLabels;
private string DecimalFormatString => "F" + AssemblerSpeedUIMod.configShownDecimalPlaces.Value;
public AdditionalSpeedLabels(bool setupOutputLabels, bool setupInputLabels, string speedTextPath)
{
//IL_0013: 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)
this.speedTextPath = speedTextPath;
speedInfos = new Dictionary<string, ItemSpeedInfoLabel>();
vanillaSpeedPos = Vector3.zero;
currentOutputs = 1;
currentInputs = (setupInputLabels ? 1 : 0);
this.setupOutputLabels = setupOutputLabels;
this.setupInputLabels = setupInputLabels;
base..ctor();
}
private string MakeFormattedPaddedLabelString(float f)
{
return " " + f.ToString(DecimalFormatString);
}
private static string ItemInputKey(int index)
{
return "assembler-speed-in-item" + index;
}
private static string ItemOutputKey(int index)
{
return "assembler-speed-out-item" + index;
}
public void SetupLabels(int? productCount, int? inputCount)
{
if (setupOutputLabels && productCount.HasValue)
{
SetupSidedLabels(productCount.Value, isInput: false);
}
if (setupInputLabels && inputCount.HasValue)
{
SetupSidedLabels(inputCount.Value, isInput: true);
}
}
public void SetupSidedLabels(int itemCount, bool isInput)
{
Func<int, string> func = (isInput ? new Func<int, string>(ItemInputKey) : new Func<int, string>(ItemOutputKey));
int num = Math.Min(itemCount, 5);
if (isInput)
{
currentInputs = num;
}
else
{
currentOutputs = num;
}
for (int i = 0; i < num; i++)
{
if (!speedInfos.ContainsKey(func(i)))
{
AddSpeedLabel(func(i), i, num, isInput);
if (isInput)
{
speedInfosInCount++;
}
else
{
speedInfosOutCount++;
}
}
}
string text = Localization.Translate("每分钟");
int num2 = (isInput ? speedInfosInCount : speedInfosOutCount);
for (int j = 0; j < num2; j++)
{
if (j < itemCount)
{
speedInfos[func(j)].Value.text = MakeFormattedPaddedLabelString(0f) + text;
speedInfos[func(j)].GameObject.SetActive(true);
TryStartPositioningOnLabel(speedInfos[func(j)], num);
}
else
{
speedInfos[func(j)].GameObject.SetActive(false);
}
}
}
public void AddSpeedLabel(string id, int num, int ofNum, bool input)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.Find(speedTextPath) ?? throw new InvalidOperationException("Assembler speed base entry is not present");
val.GetComponent<Text>();
GameObject val2 = Object.Instantiate<GameObject>(val, val.transform.position, Quaternion.identity);
Object.Destroy((Object)(object)val2.GetComponentInChildren<Localizer>());
ContentSizeFitter val3 = val2.AddComponent<ContentSizeFitter>();
val3.horizontalFit = (FitMode)2;
val3.verticalFit = (FitMode)2;
((Object)val2).name = id;
val2.transform.SetParent(val.transform.parent);
Text value = val2.GetComponentsInChildren<Text>()[0];
vanillaSpeedPos = val.transform.localPosition;
val2.transform.localScale = new Vector3(1f, 1f, 1f);
val2.transform.right = val.transform.right;
ItemSpeedInfoLabel itemSpeedInfoLabel = new ItemSpeedInfoLabel
{
GameObject = val2,
Value = value,
Index = num,
IsInput = input,
Fitter = val3
};
speedInfos.Add(id, itemSpeedInfoLabel);
TryStartPositioningOnLabel(itemSpeedInfoLabel, ofNum);
}
[IteratorStateMachine(typeof(<PositionSpeedLabel>d__21))]
private IEnumerator PositionSpeedLabel(ItemSpeedInfoLabel labelData, int ofNum)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <PositionSpeedLabel>d__21(0)
{
<>4__this = this,
labelData = labelData,
ofNum = ofNum
};
}
private void TryStartPositioningOnLabel(ItemSpeedInfoLabel labelData, int ofNum)
{
if (labelData.GameObject.activeInHierarchy)
{
((MonoBehaviour)labelData.Fitter).StartCoroutine(PositionSpeedLabel(labelData, ofNum));
}
}
private static Vector3 GetPos(int num, int ofNum, bool input, float z, float width)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
float num2 = (input ? 25f : (-50f));
return new Vector3(GetXShift(num, ofNum, input, width), num2, z);
}
private static float GetXShift(int num, int ofNum, bool input, float width)
{
if (input)
{
float num2 = 50f;
return 130f - width / 2f + (float)num * num2;
}
float num3 = -64f;
return 1f - width / 2f + (float)(ofNum - 1 - num) * num3;
}
public void UpdateSpeedLabel(string id, float value, bool perSecond)
{
string text = Localization.Translate("每分钟");
string text2 = "/s";
string text3 = ((!perSecond) ? (MakeFormattedPaddedLabelString(value) + text) : (MakeFormattedPaddedLabelString(value / 60f) + text2));
if (text3 != speedInfos[id].Value.text)
{
speedInfos[id].Value.text = text3;
TryStartPositioningOnLabel(speedInfos[id], speedInfos[id].IsInput ? currentInputs : currentOutputs);
}
}
public void UpdateSpeedLabels(float baseSpeed, int[] productCounts, int[] requireCounts)
{
if (setupOutputLabels)
{
for (int i = 0; i < Math.Min(productCounts.Length, 5); i++)
{
UpdateSpeedLabel(ItemOutputKey(i), (float)productCounts[i] * baseSpeed, AssemblerSpeedUIMod.configOutputSpeedsPerSecond.Value);
}
}
if (setupInputLabels)
{
for (int j = 0; j < Math.Min(requireCounts.Length, 5); j++)
{
UpdateSpeedLabel(ItemInputKey(j), (float)requireCounts[j] * baseSpeed, AssemblerSpeedUIMod.configInputSpeedsPerSecond.Value);
}
}
}
public void Destroy()
{
foreach (KeyValuePair<string, ItemSpeedInfoLabel> speedInfo in speedInfos)
{
Object.Destroy((Object)(object)speedInfo.Value.GameObject);
}
}
}
public class FieldIndexFinder
{
public static (int a, int b, int c)? FindRelevantFieldIndicesUIMinerWindow(IEnumerable<CodeInstruction> instructions)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: 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_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Expected O, but got Unknown
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Expected O, but got Unknown
int num = -1;
int second = -1;
int num2 = -1;
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldc_R4 && CodeInstructionExtensions.OperandIs(i, (object)60f)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldloc_S && i.operand is LocalBuilder), (string)null),
new CodeMatch((OpCode?)OpCodes.Div, (object)null, (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Stloc_S && i.operand is LocalBuilder), (string)null)
});
if (val.IsValid)
{
val.Advance(1);
num = ((LocalBuilder)val.Instruction.operand).LocalIndex;
val.Advance(2);
second = ((LocalBuilder)val.Instruction.operand).LocalIndex;
val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldloc_S && i.operand is LocalBuilder localBuilder2 && localBuilder2.LocalIndex == second), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldloc_S && i.operand is LocalBuilder), (string)null),
new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Stloc_S && i.operand is LocalBuilder localBuilder && localBuilder.LocalIndex == second), (string)null)
});
if (val.IsValid)
{
val.Advance(1);
num2 = ((LocalBuilder)val.Instruction.operand).LocalIndex;
return (num, second, num2);
}
return null;
}
return null;
}
public static (int a, int b)? FindRelevantFieldIndicesUIAssemblerWindow(IEnumerable<CodeInstruction> instructions)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Expected O, but got Unknown
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Expected O, but got Unknown
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Expected O, but got Unknown
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Expected O, but got Unknown
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Expected O, but got Unknown
int num = -1;
int second = -1;
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldc_R4 && CodeInstructionExtensions.OperandIs(i, (object)60f)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldloc_S && i.operand is LocalBuilder), (string)null),
new CodeMatch((OpCode?)OpCodes.Div, (object)null, (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Stloc_S && i.operand is LocalBuilder), (string)null)
});
if (val.IsValid)
{
val.Advance(1);
num = ((LocalBuilder)val.Instruction.operand).LocalIndex;
val.Advance(2);
second = ((LocalBuilder)val.Instruction.operand).LocalIndex;
val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
{
new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Stloc_S && i.operand is LocalBuilder localBuilder && localBuilder.LocalIndex == second), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldarg_0), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldfld && i.operand is FieldInfo fieldInfo && fieldInfo.Name == typeof(UIAssemblerWindow).GetField("speedText").Name), (string)null)
});
if (val.IsValid)
{
return (num, second);
}
return null;
}
return null;
}
}
internal class ItemSpeedInfoLabel
{
public GameObject GameObject { get; set; }
public Text Value { get; set; }
public int Index { get; set; }
public bool IsInput { get; set; }
public ContentSizeFitter Fitter { get; set; }
}
}
namespace DSP_AssemblerUI.AssemblerSpeedUI.Patchers
{
public static class UIAssemblerWindowPatch
{
internal static AdditionalSpeedLabels additionalSpeedLabels;
public static void UpdateSpeedLabels(float baseSpeed, RecipeExecuteData red)
{
additionalSpeedLabels.UpdateSpeedLabels(baseSpeed, red.productCounts, red.requireCounts);
}
private static void SetupLabels(UIAssemblerWindow? window)
{
additionalSpeedLabels.SetupLabels(window?.factorySystem?.assemblerPool[window.assemblerId].recipeExecuteData?.productCounts?.Length, window?.factorySystem?.assemblerPool[window.assemblerId].recipeExecuteData?.requireCounts?.Length);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(UIAssemblerWindow), "OnAssemblerIdChange")]
public static void OnAssemblerIdChangePostfix(ref UIAssemblerWindow __instance)
{
SetupLabels(__instance);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(AssemblerComponent), "SetRecipe")]
public static void SetRecipePostfix(ref AssemblerComponent __instance)
{
if (((ManualBehaviour)UIRoot.instance.uiGame.assemblerWindow).active && UIRoot.instance.uiGame.assemblerWindow.assemblerId == __instance.id)
{
SetupLabels(UIRoot.instance.uiGame.assemblerWindow);
}
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(UIAssemblerWindow), "_OnUpdate")]
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator codeGen)
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Expected O, but got Unknown
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Expected O, but got Unknown
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Expected O, but got Unknown
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Expected O, but got Unknown
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: 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_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Expected O, but got Unknown
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Expected O, but got Unknown
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Expected O, but got Unknown
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Expected O, but got Unknown
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Expected O, but got Unknown
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Expected O, but got Unknown
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Expected O, but got Unknown
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Expected O, but got Unknown
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Expected O, but got Unknown
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Expected O, but got Unknown
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Expected O, but got Unknown
//IL_0290: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Expected O, but got Unknown
//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Expected O, but got Unknown
//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
//IL_02c2: Expected O, but got Unknown
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_02d0: Expected O, but got Unknown
//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
//IL_02e3: Expected O, but got Unknown
//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0304: Expected O, but got Unknown
//IL_0321: Unknown result type (might be due to invalid IL or missing references)
//IL_0327: Expected O, but got Unknown
LocalBuilder localBuilder = codeGen.DeclareLocal(typeof(float));
localBuilder.SetLocalSymInfo("baseSpeedValue");
Label label = codeGen.DefineLabel();
(int, int)? tuple = FieldIndexFinder.FindRelevantFieldIndicesUIAssemblerWindow(instructions);
if (tuple.HasValue)
{
(int, int) value = tuple.Value;
int divisor60 = value.Item1;
int speedvalue = value.Item2;
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[4]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldc_R4 && CodeInstructionExtensions.OperandIs(i, (object)60f)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldloc_S && i.operand is LocalBuilder localBuilder4 && localBuilder4.LocalIndex == divisor60), (string)null),
new CodeMatch((OpCode?)OpCodes.Div, (object)null, (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Stloc_S && i.operand is LocalBuilder localBuilder3 && localBuilder3.LocalIndex == speedvalue), (string)null)
});
val.Advance(1);
val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[8]
{
new CodeInstruction(OpCodes.Ldloc_S, (object)(byte)speedvalue),
new CodeInstruction(OpCodes.Ldloc_0, (object)null),
new CodeInstruction(OpCodes.Ldfld, (object)typeof(AssemblerComponent).GetField("speedOverride")),
new CodeInstruction(OpCodes.Conv_R4, (object)null),
new CodeInstruction(OpCodes.Ldc_R4, (object)0.0001f),
new CodeInstruction(OpCodes.Mul, (object)null),
new CodeInstruction(OpCodes.Mul, (object)null),
new CodeInstruction(OpCodes.Stloc_S, (object)localBuilder)
});
val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
{
new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Stloc_S && i.operand is LocalBuilder localBuilder2 && localBuilder2.LocalIndex == speedvalue), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldarg_0), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldfld && i.operand is FieldInfo fieldInfo && fieldInfo.Name == typeof(UIAssemblerWindow).GetField("speedText").Name), (string)null)
});
val.Advance(2);
CodeInstruction val2 = new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder);
val2.labels.Add(label);
val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[9]
{
new CodeInstruction(OpCodes.Ldsfld, (object)typeof(AssemblerSpeedUIMod).GetField("configShowLiveSpeed")),
new CodeInstruction(OpCodes.Callvirt, (object)typeof(ConfigEntry<bool>).GetProperty("Value").GetGetMethod()),
new CodeInstruction(OpCodes.Brfalse, (object)label),
new CodeInstruction(OpCodes.Ldloc_S, (object)(byte)speedvalue),
new CodeInstruction(OpCodes.Stloc_S, (object)localBuilder),
val2,
new CodeInstruction(OpCodes.Ldloc_0, (object)null),
new CodeInstruction(OpCodes.Ldfld, (object)typeof(AssemblerComponent).GetField("recipeExecuteData")),
new CodeInstruction(OpCodes.Call, (object)typeof(UIAssemblerWindowPatch).GetMethod("UpdateSpeedLabels", BindingFlags.Static | BindingFlags.Public))
});
return val.InstructionEnumeration();
}
AssemblerSpeedUIMod.Logger.LogError((object)"[UIAssemblerWindow] Could not find the desired fields for patching the update logic.");
return instructions;
}
}
public static class UIMinerWindowPatch
{
internal static AdditionalSpeedLabels additionalSpeedLabels;
[HarmonyPostfix]
[HarmonyPatch(typeof(UIMinerWindow), "OnMinerIdChange")]
public static void OnMinerIdChangePostfix()
{
additionalSpeedLabels.SetupLabels(1, null);
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(UIMinerWindow), "_OnUpdate")]
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator codeGen)
{
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: 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_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Expected O, but got Unknown
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Expected O, but got Unknown
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Expected O, but got Unknown
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Expected O, but got Unknown
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Expected O, but got Unknown
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Expected O, but got Unknown
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Expected O, but got Unknown
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: 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_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: Expected O, but got Unknown
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Expected O, but got Unknown
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Expected O, but got Unknown
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_0237: Expected O, but got Unknown
//IL_0240: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: 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_029f: Unknown result type (might be due to invalid IL or missing references)
//IL_02a5: Expected O, but got Unknown
//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Expected O, but got Unknown
//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
//IL_02d8: Expected O, but got Unknown
//IL_0309: Unknown result type (might be due to invalid IL or missing references)
//IL_030f: Expected O, but got Unknown
//IL_0331: Unknown result type (might be due to invalid IL or missing references)
//IL_0337: Expected O, but got Unknown
//IL_0359: Unknown result type (might be due to invalid IL or missing references)
//IL_035f: Expected O, but got Unknown
//IL_0381: Unknown result type (might be due to invalid IL or missing references)
//IL_0387: Expected O, but got Unknown
//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
//IL_03ac: Expected O, but got Unknown
//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
//IL_03ba: Expected O, but got Unknown
//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
//IL_03de: Expected O, but got Unknown
//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
//IL_03f3: Expected O, but got Unknown
//IL_0401: Unknown result type (might be due to invalid IL or missing references)
//IL_0407: Expected O, but got Unknown
//IL_0416: Unknown result type (might be due to invalid IL or missing references)
//IL_041c: Expected O, but got Unknown
//IL_0428: Unknown result type (might be due to invalid IL or missing references)
//IL_042f: Expected O, but got Unknown
//IL_0442: Unknown result type (might be due to invalid IL or missing references)
//IL_0449: Expected O, but got Unknown
//IL_047b: Unknown result type (might be due to invalid IL or missing references)
//IL_0481: Expected O, but got Unknown
//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
//IL_04a7: Expected O, but got Unknown
//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
//IL_04ba: Expected O, but got Unknown
//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
//IL_04d3: Expected O, but got Unknown
//IL_04db: Unknown result type (might be due to invalid IL or missing references)
//IL_04e1: Expected O, but got Unknown
//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
//IL_04f5: Expected O, but got Unknown
//IL_0502: Unknown result type (might be due to invalid IL or missing references)
//IL_0508: Expected O, but got Unknown
//IL_0510: Unknown result type (might be due to invalid IL or missing references)
//IL_0516: Expected O, but got Unknown
//IL_051f: Unknown result type (might be due to invalid IL or missing references)
//IL_0525: Expected O, but got Unknown
//IL_055a: Unknown result type (might be due to invalid IL or missing references)
//IL_0560: Expected O, but got Unknown
LocalBuilder localBuilder = codeGen.DeclareLocal(typeof(float));
localBuilder.SetLocalSymInfo("baseSpeedValue");
LocalBuilder localBuilder2 = codeGen.DeclareLocal(typeof(float));
localBuilder.SetLocalSymInfo("miningSpeedFactor");
Label label = codeGen.DefineLabel();
Label label2 = codeGen.DefineLabel();
(int, int, int)? tuple = FieldIndexFinder.FindRelevantFieldIndicesUIMinerWindow(instructions);
if (tuple.HasValue)
{
(int, int, int) value = tuple.Value;
int divisor60 = value.Item1;
int speedvalue = value.Item2;
int outputstringFactor = value.Item3;
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[4]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldc_R4 && CodeInstructionExtensions.OperandIs(i, (object)60f)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldloc_S && i.operand is LocalBuilder localBuilder7 && localBuilder7.LocalIndex == divisor60), (string)null),
new CodeMatch((OpCode?)OpCodes.Div, (object)null, (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Stloc_S && i.operand is LocalBuilder localBuilder6 && localBuilder6.LocalIndex == speedvalue), (string)null)
});
val.Advance(1);
val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[13]
{
new CodeInstruction(OpCodes.Ldc_R4, (object)0.0001f),
new CodeInstruction(OpCodes.Ldloc_0, (object)null),
new CodeInstruction(OpCodes.Ldfld, (object)typeof(MinerComponent).GetField("speed")),
new CodeInstruction(OpCodes.Conv_R4, (object)null),
new CodeInstruction(OpCodes.Mul, (object)null),
new CodeInstruction(OpCodes.Call, (object)typeof(GameMain).GetProperty("history").GetGetMethod()),
new CodeInstruction(OpCodes.Ldfld, (object)typeof(GameHistoryData).GetField("miningSpeedScale")),
new CodeInstruction(OpCodes.Mul, (object)null),
new CodeInstruction(OpCodes.Ldloc_S, (object)(byte)speedvalue),
new CodeInstruction(OpCodes.Mul, (object)null),
new CodeInstruction(OpCodes.Stloc_S, (object)localBuilder),
new CodeInstruction(OpCodes.Ldc_R4, (object)1f),
new CodeInstruction(OpCodes.Stloc_S, (object)localBuilder2)
});
val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldfld && i.operand is FieldInfo fieldInfo2 && fieldInfo2.Name == "veinCount" && fieldInfo2.FieldType == typeof(int)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Conv_R4), (string)null)
});
val.Advance(1);
val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2]
{
new CodeInstruction(OpCodes.Stloc_S, (object)localBuilder2),
new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder2)
});
val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[4]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldsfld && i.operand is FieldInfo fieldInfo && fieldInfo.Name == "oilSpeedMultiplier" && fieldInfo.FieldType == typeof(float)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Conv_R8), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Mul), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Conv_R4), (string)null)
});
val.Advance(1);
val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2]
{
new CodeInstruction(OpCodes.Stloc_S, (object)localBuilder2),
new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder2)
});
val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[4]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldloc_S && i.operand is LocalBuilder localBuilder5 && localBuilder5.LocalIndex == speedvalue), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldloc_S && i.operand is LocalBuilder localBuilder4 && localBuilder4.LocalIndex == outputstringFactor), (string)null),
new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Stloc_S && i.operand is LocalBuilder localBuilder3 && localBuilder3.LocalIndex == speedvalue), (string)null)
});
CodeInstruction val2 = new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder);
val2.labels.Add(label);
CodeInstruction val3 = new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder);
val3.labels.Add(label2);
val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[12]
{
new CodeInstruction(OpCodes.Ldsfld, (object)typeof(AssemblerSpeedUIMod).GetField("configShowMinerLiveSpeed")),
new CodeInstruction(OpCodes.Callvirt, (object)typeof(ConfigEntry<bool>).GetProperty("Value").GetGetMethod()),
new CodeInstruction(OpCodes.Brfalse, (object)label),
new CodeInstruction(OpCodes.Ldloc_S, (object)(byte)speedvalue),
new CodeInstruction(OpCodes.Stloc_S, (object)localBuilder),
new CodeInstruction(OpCodes.Br, (object)label2),
val2,
new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder2),
new CodeInstruction(OpCodes.Mul, (object)null),
new CodeInstruction(OpCodes.Stloc_S, (object)localBuilder),
val3,
new CodeInstruction(OpCodes.Call, (object)typeof(UIMinerWindowPatch).GetMethod("UpdateSpeedLabel", new Type[1] { typeof(float) }))
});
return val.Instructions();
}
AssemblerSpeedUIMod.Logger.LogError((object)"[UIMinerWindow] Could not find the desired fields for patching the update logic.");
return instructions;
}
public static void UpdateSpeedLabel(float baseSpeed)
{
additionalSpeedLabels.UpdateSpeedLabel("assembler-speed-out-item0", baseSpeed, AssemblerSpeedUIMod.configMinerSpeedsPerSecond.Value);
}
}
}