using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ComfyLib;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("AssemblyLine")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AssemblyLine")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("36a1739a-1b97-41dd-a553-cb6423df9a2a")]
[assembly: AssemblyFileVersion("1.2.1")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.1.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 ComfyLib
{
public static class CodeMatcherExtensions
{
public static CodeMatcher SaveInstruction(this CodeMatcher matcher, out CodeInstruction instruction)
{
instruction = matcher.Instruction;
return matcher;
}
}
public static class ConfigFileExtensions
{
internal sealed class ConfigurationManagerAttributes
{
public Action<ConfigEntryBase> CustomDrawer;
public bool? Browsable;
public bool? HideDefaultButton;
public bool? HideSettingName;
public bool? IsAdvanced;
public int? Order;
public bool? ReadOnly;
}
private static readonly Dictionary<string, int> _sectionToSettingOrder = new Dictionary<string, int>();
private static int GetSettingOrder(string section)
{
if (!_sectionToSettingOrder.TryGetValue(section, out var value))
{
value = 0;
}
_sectionToSettingOrder[section] = value - 1;
return value;
}
public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false)
{
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected O, but got Unknown
return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, new object[1]
{
new ConfigurationManagerAttributes
{
Browsable = browsable,
CustomDrawer = null,
HideDefaultButton = hideDefaultButton,
HideSettingName = hideSettingName,
IsAdvanced = isAdvanced,
Order = GetSettingOrder(section),
ReadOnly = readOnly
}
}));
}
public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, Action<ConfigEntryBase> customDrawer = null, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false)
{
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected O, but got Unknown
return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Browsable = browsable,
CustomDrawer = customDrawer,
HideDefaultButton = hideDefaultButton,
HideSettingName = hideSettingName,
IsAdvanced = isAdvanced,
Order = GetSettingOrder(section),
ReadOnly = readOnly
}
}));
}
public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action settingChangedHandler)
{
configEntry.SettingChanged += delegate
{
settingChangedHandler();
};
}
public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<T> settingChangedHandler)
{
configEntry.SettingChanged += delegate(object _, EventArgs eventArgs)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
settingChangedHandler((T)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue);
};
}
public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<ConfigEntry<T>> settingChangedHandler)
{
configEntry.SettingChanged += delegate(object _, EventArgs eventArgs)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
settingChangedHandler((ConfigEntry<T>)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue);
};
}
}
public static class ChatExtensions
{
public static void AddMessage(this Chat chat, object obj)
{
if (Object.op_Implicit((Object)(object)chat))
{
((Terminal)chat).AddString($"{obj}");
chat.m_hideTimer = 0f;
}
}
}
public static class ObjectExtensions
{
public static T FirstByNameOrThrow<T>(this IEnumerable<T> unityObjects, string name) where T : Object
{
foreach (T unityObject in unityObjects)
{
if (((Object)unityObject).name == name)
{
return unityObject;
}
}
throw new InvalidOperationException($"Could not find Unity object of type {typeof(T)} with name: {name}");
}
public static T Ref<T>(this T unityObject) where T : Object
{
if (!Object.op_Implicit((Object)(object)unityObject))
{
return default(T);
}
return unityObject;
}
}
}
namespace AssemblyLine
{
[BepInPlugin("bruce.valheim.comfy.assemblyline", "AssemblyLine", "1.2.1")]
public sealed class AssemblyLine : BaseUnityPlugin
{
public const string PluginGuid = "bruce.valheim.comfy.assemblyline";
public const string PluginName = "AssemblyLine";
public const string PluginVersion = "1.2.1";
private static ManualLogSource _logger;
private void Awake()
{
_logger = ((BaseUnityPlugin)this).Logger;
PluginConfig.BindConfig(((BaseUnityPlugin)this).Config);
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "bruce.valheim.comfy.assemblyline");
}
public static void LogInfo(object obj)
{
_logger.LogInfo((object)$"[{DateTime.Now.ToString(DateTimeFormatInfo.InvariantInfo)}] {obj}");
Chat.m_instance.AddMessage(obj);
}
}
public static class CraftingManager
{
public static int MaxCraftAmount = 1;
public static Dictionary<string, int> RequirementAmountByName = new Dictionary<string, int>();
public static Dictionary<string, int> MaxAmountByName = new Dictionary<string, int>();
public static Dictionary<string, Transform> RequirementTransformByName = new Dictionary<string, Transform>();
public static int CraftsRemaining = 0;
public static RectTransform IncrementButtonTransform { get; private set; }
public static RectTransform DecrementButtonTransform { get; private set; }
public static RectTransform CountText { get; private set; }
public static Button CraftButton { get; private set; }
public static Button IncrementButton { get; private set; }
public static Button DecrementButton { get; private set; }
public static TMP_Text CountLabel { get; private set; }
public static int CountValue { get; private set; }
public static void SetCountValue(int value)
{
CountLabel.SetText(value.ToString());
CountValue = value;
}
public static void CreateOrSetupUI(InventoryGui inventoryGui)
{
if (!Object.op_Implicit((Object)(object)CraftButton))
{
CreateUI(inventoryGui);
}
}
private static void CreateUI(InventoryGui inventoryGui)
{
CraftButton = inventoryGui.m_craftButton;
ScaleCraftButton(CraftButton);
CreateIncrementDecrementButtons(CraftButton);
CreateCountText(CraftButton);
SetCraftAmountToMin();
}
private static void CreateIncrementDecrementButtons(Button craftButton)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: 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)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: 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_009e: Expected O, but got Unknown
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Expected O, but got Unknown
IncrementButtonTransform = CreateButton(craftButton, "Increment", "+");
IncrementButtonTransform.anchoredPosition = new Vector2(0f, -7.5f);
IncrementButtonTransform.anchorMin = Vector2.one;
IncrementButtonTransform.anchorMax = Vector2.one;
IncrementButtonTransform.pivot = Vector2.one;
IncrementButtonTransform.sizeDelta = new Vector2(40f, 30f);
IncrementButton = ((Component)IncrementButtonTransform).GetComponent<Button>();
((UnityEvent)IncrementButton.onClick).AddListener(new UnityAction(OnIncrementPressed));
DecrementButtonTransform = CreateButton(craftButton, "Decrement", "-");
DecrementButtonTransform.anchoredPosition = new Vector2(0f, 2.5f);
DecrementButtonTransform.anchorMin = Vector2.right;
DecrementButtonTransform.anchorMax = Vector2.right;
DecrementButtonTransform.pivot = Vector2.right;
DecrementButtonTransform.sizeDelta = new Vector2(40f, 30f);
DecrementButton = ((Component)DecrementButtonTransform).GetComponent<Button>();
((UnityEvent)DecrementButton.onClick).AddListener(new UnityAction(OnDecrementPressed));
}
private static void CreateCountText(Button craftButton)
{
//IL_0015: 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_002f: Expected O, but got Unknown
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = (RectTransform)((Component)((Component)craftButton).transform).transform.Find("Text");
CountText = Object.Instantiate<RectTransform>(val, ((Component)((Transform)val).parent).transform.parent);
((Object)CountText).name = "Count";
CountText.anchoredPosition = new Vector2(-45f, 0f);
CountText.anchorMin = Vector2.right;
CountText.anchorMax = Vector2.one;
CountText.pivot = Vector2.right;
CountText.sizeDelta = new Vector2(50f, -5f);
CountLabel = ((Component)CountText).GetComponent<TMP_Text>();
}
private static RectTransform CreateButton(Button craftButton, string name, string text)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: 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)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Expected O, but got Unknown
Transform obj = Object.Instantiate<Transform>(((Component)craftButton).transform, ((Component)((Component)craftButton).transform).transform.parent);
((Object)obj).name = name;
RectTransform val = (RectTransform)obj.Find("Text");
val.anchoredPosition = Vector2.op_Implicit(Vector3.zero);
val.anchorMin = Vector2.zero;
val.anchorMax = Vector2.one;
val.pivot = new Vector2(0.5f, 0.5f);
val.sizeDelta = Vector2.zero;
TMP_Text component = ((Component)val).GetComponent<TMP_Text>();
component.text = text;
component.enableAutoSizing = true;
return (RectTransform)obj;
}
public static void DecrementCraftAmount(int amount)
{
int num = CountValue - amount;
if (num < 1)
{
SetCraftAmountToMin();
}
else
{
SetCountValue(num);
}
}
public static int GetMaxCraftAmount(InventoryGui inventoryGui)
{
if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)((RecipeDataPair)(ref inventoryGui.m_selectedRecipe)).Recipe == (Object)null)
{
return 1;
}
if (Player.m_localPlayer.NoCostCheat())
{
return 500;
}
List<int> list = new List<int>();
Requirement[] resources = ((RecipeDataPair)(ref inventoryGui.m_selectedRecipe)).Recipe.m_resources;
foreach (Requirement val in resources)
{
if (Object.op_Implicit((Object)(object)val.m_resItem) && val.m_amount > 0)
{
int item = ((Humanoid)Player.m_localPlayer).GetInventory().CountItems(val.m_resItem.m_itemData.m_shared.m_name, -1, true) / val.m_amount;
list.Add(item);
}
}
if (list.Min() != 0)
{
return list.Min();
}
return 1;
}
public static bool HaveCraftRequirements(int newCount)
{
if (MaxCraftAmount >= newCount)
{
return true;
}
return false;
}
public static void IncrementCraftAmount(int amount)
{
int countValue = CountValue;
int num = countValue + amount;
if (PluginConfig.RoundToStackSize.Value && HaveCraftRequirements(10) && countValue == 1 && amount == 10)
{
SetCountValue(10);
}
else if (HaveCraftRequirements(num) && amount != -1)
{
SetCountValue(num);
}
}
public static bool IsCraftingMultiple()
{
if (CraftsRemaining > 0)
{
return true;
}
return false;
}
public static void OnDecrementPressed()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
KeyboardShortcut value = PluginConfig.MaxAmountChangeModifier.Value;
if (((KeyboardShortcut)(ref value)).IsPressed())
{
SetCraftAmountToMin();
SetRequirementText();
return;
}
value = PluginConfig.AmountChangeModifier.Value;
if (((KeyboardShortcut)(ref value)).IsPressed())
{
DecrementCraftAmount(10);
SetRequirementText();
}
else
{
DecrementCraftAmount(1);
SetRequirementText();
}
}
public static void OnIncrementPressed()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
SetMaxCraftAmount(InventoryGui.instance);
KeyboardShortcut value = PluginConfig.MaxAmountChangeModifier.Value;
if (((KeyboardShortcut)(ref value)).IsPressed())
{
SetCraftAmountToMax();
SetRequirementText();
return;
}
value = PluginConfig.AmountChangeModifier.Value;
if (((KeyboardShortcut)(ref value)).IsPressed())
{
if (!HaveCraftRequirements(10))
{
SetCraftAmountToMax();
}
IncrementCraftAmount(10);
SetRequirementText();
}
else
{
IncrementCraftAmount(1);
SetRequirementText();
}
}
private static void ScaleCraftButton(Button craftButton)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: 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)
RectTransform val = default(RectTransform);
if (((Component)craftButton).TryGetComponent<RectTransform>(ref val))
{
val.anchoredPosition = new Vector2(0f, 2.5f);
val.pivot = Vector2.zero;
val.sizeDelta = new Vector2(-100f, -10f);
}
}
public static void SetButtonInteractable(bool interactable)
{
if ((Object)(object)IncrementButton != (Object)null)
{
((Selectable)IncrementButton).interactable = interactable;
}
if ((Object)(object)DecrementButton != (Object)null)
{
((Selectable)DecrementButton).interactable = interactable;
}
}
public static void SetCraftAmountToMax()
{
SetCountValue(MaxCraftAmount);
}
public static void SetCraftAmountToMin()
{
SetCountValue(1);
}
public static void SetMaxCraftAmount(InventoryGui inventoryGui)
{
MaxCraftAmount = GetMaxCraftAmount(inventoryGui);
}
public static void SetRequirementText()
{
foreach (KeyValuePair<string, Transform> item in RequirementTransformByName)
{
MaxAmountByName[item.Key] = ((Humanoid)Player.m_localPlayer).GetInventory().CountItems(item.Key, -1, true);
((Component)((Component)item.Value).transform.Find("res_amount")).GetComponent<TMP_Text>().text = RequirementAmountByName[item.Key] * CountValue + "/" + MaxAmountByName[item.Key];
}
}
public static void UpdateMaxAmount()
{
foreach (KeyValuePair<string, int> item in RequirementAmountByName)
{
MaxAmountByName[item.Key] = MaxAmountByName[item.Key] - RequirementAmountByName[item.Key];
}
}
}
[HarmonyPatch(typeof(InventoryGui))]
internal static class InventoryGuiPatch
{
[HarmonyPostfix]
[HarmonyPatch("Show")]
private static void ShowPostfix(InventoryGui __instance, Container container)
{
CraftingManager.CreateOrSetupUI(__instance);
}
[HarmonyPostfix]
[HarmonyPatch("OnTabCraftPressed")]
private static void OnTabCraftPressedPostfix(InventoryGui __instance)
{
CraftingManager.SetButtonInteractable(interactable: true);
}
[HarmonyPostfix]
[HarmonyPatch("OnTabUpgradePressed")]
private static void OnTabUpgradePressedPostfix(InventoryGui __instance)
{
CraftingManager.SetButtonInteractable(interactable: false);
CraftingManager.SetCraftAmountToMin();
}
[HarmonyPostfix]
[HarmonyPatch("OnCraftPressed")]
private static void OnCraftPressedPostfix(InventoryGui __instance)
{
CraftingManager.CraftsRemaining = CraftingManager.CountValue - 1;
}
[HarmonyTranspiler]
[HarmonyPatch("OnCraftPressed")]
private static IEnumerable<CodeInstruction> OnCraftPressedTranspiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: 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_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Expected O, but got Unknown
return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[3]
{
new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(InventoryGui), "m_multiCrafting"), (string)null),
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null)
}).ThrowIfInvalid("Could not patch InventoryGui.OnCraftPressed()! (get-button-alt-place)")
.Advance(2)
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3]
{
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(InventoryGuiPatch), "SetIsMultiCraftingDelegate", (Type[])null, (Type[])null)),
new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(InventoryGui), "m_multiCrafting"))
})
.InstructionEnumeration();
}
[HarmonyPostfix]
[HarmonyPatch("OnCraftCancelPressed")]
private static void OnCraftCancelPressedPostfix(InventoryGui __instance)
{
CraftingManager.CraftsRemaining = 0;
}
[HarmonyPostfix]
[HarmonyPatch("Hide")]
private static void HidePostfix(InventoryGui __instance)
{
CraftingManager.CraftsRemaining = 0;
}
[HarmonyPostfix]
[HarmonyPatch("UpdateRecipe")]
private static void UpdateRecipePostfix(InventoryGui __instance, Player player, float dt)
{
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)((RecipeDataPair)(ref __instance.m_selectedRecipe)).Recipe))
{
return;
}
if (!((Humanoid)player).GetInventory().CanAddItem(((RecipeDataPair)(ref __instance.m_selectedRecipe)).Recipe.m_item.m_itemData, ((RecipeDataPair)(ref __instance.m_selectedRecipe)).Recipe.m_amount))
{
CraftingManager.DecrementCraftAmount(1);
CraftingManager.CraftsRemaining = 0;
}
else if (__instance.m_craftTimer < 0f && CraftingManager.CraftsRemaining > 0)
{
CraftingManager.CraftsRemaining--;
__instance.m_craftTimer = 0f;
CraftingManager.DecrementCraftAmount(1);
CraftingManager.UpdateMaxAmount();
CraftingManager.SetRequirementText();
CraftingStation currentCraftingStation = player.GetCurrentCraftingStation();
EffectList obj = (Object.op_Implicit((Object)(object)currentCraftingStation) ? currentCraftingStation.m_craftItemEffects : __instance.m_craftItemEffects);
if (obj != null)
{
obj.Create(((Component)player).transform.position, Quaternion.identity, (Transform)null, 1f, -1);
}
__instance.m_craftRecipe = ((RecipeDataPair)(ref __instance.m_selectedRecipe)).Recipe;
}
}
[HarmonyTranspiler]
[HarmonyPatch("UpdateRecipe")]
private static IEnumerable<CodeInstruction> UpdateRecipeTranspiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: 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
CodeInstruction instruction;
return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[4]
{
new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldloc_2, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Brtrue, (object)null, (string)null)
}).ThrowIfInvalid("Could not patch InventoryGui.UpdateRecipe()! (get-button-alt-place)")
.Advance(1)
.SaveInstruction(out instruction)
.Advance(1)
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2]
{
new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(InventoryGuiPatch), "SetIsMultiCraftingDelegate", (Type[])null, (Type[])null)),
instruction
})
.InstructionEnumeration();
}
private static bool SetIsMultiCraftingDelegate()
{
return false;
}
[HarmonyPostfix]
[HarmonyPatch("SetRecipe")]
private static void SetRecipePostfix(InventoryGui __instance, int index, bool center)
{
if (!CraftingManager.IsCraftingMultiple())
{
CraftingManager.RequirementAmountByName.Clear();
CraftingManager.MaxAmountByName.Clear();
CraftingManager.RequirementTransformByName.Clear();
CraftingManager.SetMaxCraftAmount(__instance);
if (Object.op_Implicit((Object)(object)CraftingManager.CountText))
{
CraftingManager.SetCraftAmountToMin();
}
}
}
[HarmonyPostfix]
[HarmonyPatch("SetupRequirement")]
private static void SetupRequirementPostfix(InventoryGui __instance, Transform elementRoot, Requirement req, Player player, bool craft, int quality)
{
if (InventoryGui.IsVisible())
{
string name = req.m_resItem.m_itemData.m_shared.m_name;
if (!CraftingManager.RequirementAmountByName.Keys.Contains(name))
{
CraftingManager.RequirementAmountByName.Add(name, req.GetAmount(quality));
CraftingManager.MaxAmountByName.Add(name, ((Humanoid)Player.m_localPlayer).GetInventory().CountItems(name, -1, true));
CraftingManager.RequirementTransformByName.Add(name, elementRoot);
}
CraftingManager.SetRequirementText();
}
}
[HarmonyPostfix]
[HarmonyPatch("UpdateCraftingPanel")]
private static void UpdateCraftingPanelPostfix(InventoryGui __instance)
{
CraftingManager.SetButtonInteractable(__instance.InCraftTab());
}
}
[HarmonyPatch(typeof(Inventory))]
internal static class InventoryPatch
{
[HarmonyPostfix]
[HarmonyPatch("Changed")]
private static void OnInventoryChangedPostfix(Inventory __instance)
{
if (!((Object)(object)Player.m_localPlayer == (Object)null) && ((Humanoid)Player.m_localPlayer).GetInventory() == __instance && InventoryGui.IsVisible())
{
CraftingManager.SetRequirementText();
}
}
}
public static class PluginConfig
{
public static ConfigEntry<KeyboardShortcut> AmountChangeModifier { get; private set; }
public static ConfigEntry<KeyboardShortcut> MaxAmountChangeModifier { get; private set; }
public static ConfigEntry<bool> RoundToStackSize { get; private set; }
public static void BindConfig(ConfigFile config)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
AmountChangeModifier = config.BindInOrder<KeyboardShortcut>("Modifiers", "amountChangeModifier", new KeyboardShortcut((KeyCode)304, Array.Empty<KeyCode>()), "Keyboard shortcut to increment or decrement craft amount by 10.");
MaxAmountChangeModifier = config.BindInOrder<KeyboardShortcut>("Modifiers", "maxAmountChangeModifier", new KeyboardShortcut((KeyCode)306, Array.Empty<KeyCode>()), "Keyboard shortcut to increment or decrement craft amount to maximum or minimum.");
RoundToStackSize = config.BindInOrder("Toggles", "roundToStackSize", defaultValue: false, "Changes first increment with account change modifier from 1 to 11 to 1 to 10 to make even stacks.");
}
}
}