using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ChestButler.Core; using HarmonyLib; using Jotunn.Utils; using MultiUserChest; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = "")] [assembly: AssemblyCompany("ChestButler")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0")] [assembly: AssemblyProduct("ChestButler")] [assembly: AssemblyTitle("ChestButler")] [assembly: AssemblyVersion("1.1.0.0")] namespace ChestButler { [BepInPlugin("eksolutions.chestbutler", "ChestButler", "1.1.0")] [BepInProcess("valheim.exe")] [BepInProcess("valheim_server.exe")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string ModGuid = "eksolutions.chestbutler"; public const string ModName = "ChestButler"; public const string ModVersion = "1.1.0"; internal static Plugin Instance; internal static ManualLogSource Log; internal static ConfigEntry SorterRadius; internal static ConfigEntry TransferInterval; internal static ConfigEntry StacksPerTick; internal static ConfigEntry ContainsFallback; internal static ConfigEntry OrganizeMovesPerTick; internal static ConfigEntry StationRange; private Harmony _harmony; private void Awake() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_008f: 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_009c: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown //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_015a: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Expected O, but got Unknown //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Expected O, but got Unknown //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; SorterRadius = ((BaseUnityPlugin)this).Config.Bind("Sorting", "Radius", 32f, new ConfigDescription("Radius (m) around a sorter chest in which target chests are searched.", (AcceptableValueBase)(object)new AcceptableValueRange(5f, 60f), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); TransferInterval = ((BaseUnityPlugin)this).Config.Bind("Sorting", "TransferInterval", 1f, new ConfigDescription("Seconds between transfer ticks per sorter.", (AcceptableValueBase)(object)new AcceptableValueRange(0.2f, 10f), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); StacksPerTick = ((BaseUnityPlugin)this).Config.Bind("Sorting", "StacksPerTick", 2, new ConfigDescription("How many item stacks a sorter moves per tick.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 8), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); ContainsFallback = ((BaseUnityPlugin)this).Config.Bind("Sorting", "ContainsFallback", true, new ConfigDescription("Route items to chests that already contain them when no explicit filter matches.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); OrganizeMovesPerTick = ((BaseUnityPlugin)this).Config.Bind("Organize", "MovesPerTick", 4, new ConfigDescription("How many item moves the Organize sweep performs per frame (higher = faster, more hitch).", (AcceptableValueBase)(object)new AcceptableValueRange(1, 16), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); StationRange = ((BaseUnityPlugin)this).Config.Bind("Organize", "StationRange", 8f, new ConfigDescription("Max distance (m) from a chest to a crafting station for the chest to inherit that station's item groups during Organize. Nearest mapped station wins.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 20f), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); Groups.Init(((BaseUnityPlugin)this).Config); Stations.Init(((BaseUnityPlugin)this).Config); _harmony = new Harmony("eksolutions.chestbutler"); _harmony.PatchAll(); Log.LogInfo((object)"ChestButler 1.1.0 loaded"); } } } namespace ChestButler.Patches { [HarmonyPatch(typeof(Container), "Awake")] internal static class Container_Awake_Patch { private static void Postfix(Container __instance) { ContainerTracker.Register(__instance); if ((Object)(object)((Component)__instance).GetComponent() == (Object)null && (Object)(object)((Component)__instance).GetComponentInParent() != (Object)null) { ((Component)__instance).gameObject.AddComponent(); } } } [HarmonyPatch(typeof(Container), "OnDestroyed")] internal static class Container_OnDestroyed_Patch { private static void Prefix(Container __instance) { ContainerTracker.Unregister(__instance); } } [HarmonyPatch(typeof(InventoryGui))] internal static class GuiPatch { private static RectTransform _bar; private static Button _sorterBtn; private static Button _pinBtn; private static Button _clearBtn; private static Button _pullBtn; private static Button _organizeBtn; private static TMP_Text _sorterLabel; private static TMP_Text _pinLabel; private static TMP_Text _clearLabel; private static TMP_Text _pullLabel; private static TMP_Text _organizeLabel; private static Container _current; private const float ConfirmWindow = 5f; private const float MinConfirmDelay = 0.3f; private static OrganizePlan _pendingPlan; private static Container _pendingChest; private static float _pendingAt; [HarmonyPostfix] [HarmonyPatch("Show")] private static void ShowPostfix(InventoryGui __instance, Container container) { if ((Object)(object)container != (Object)(object)_pendingChest) { ClearPending(); } _current = container; EnsureBar(__instance); Refresh(); } [HarmonyPostfix] [HarmonyPatch("Hide")] private static void HidePostfix() { _current = null; ClearPending(); if ((Object)(object)_bar != (Object)null) { ((Component)_bar).gameObject.SetActive(false); } } [HarmonyPostfix] [HarmonyPatch("Update")] private static void UpdatePostfix() { if (_pendingPlan != null && Time.time - _pendingAt > 5f) { ClearPending(); } } private static void EnsureBar(InventoryGui gui) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0069: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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) //IL_00b2: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Expected O, but got Unknown //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Expected O, but got Unknown //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Expected O, but got Unknown //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Expected O, but got Unknown //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Expected O, but got Unknown if ((Object)(object)_bar != (Object)null) { return; } Button takeAllButton = gui.m_takeAllButton; if (!((Object)(object)takeAllButton == (Object)null)) { RectTransform component = ((Component)takeAllButton).GetComponent(); Transform parent = ((Transform)component).parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); if (!((Object)(object)val == (Object)null)) { GameObject val2 = new GameObject("psort_bar", new Type[1] { typeof(RectTransform) }); _bar = (RectTransform)val2.transform; ((Transform)_bar).SetParent(((Transform)component).parent, false); Rect rect = val.rect; Rect rect2 = component.rect; float width = ((Rect)(ref rect2)).width; rect2 = component.rect; float height = ((Rect)(ref rect2)).height; float num = ((Rect)(ref rect)).x + ((Rect)(ref rect)).width * component.anchorMin.x; float num2 = ((Rect)(ref rect)).y + ((Rect)(ref rect)).height * component.anchorMin.y; float num3 = num + component.anchoredPosition.x + (0.5f - component.pivot.x) * width; float num4 = num2 + component.anchoredPosition.y + (0.5f - component.pivot.y) * height; float num5 = num3 - width * 0.5f - ((Rect)(ref rect)).xMin; float num6 = ((Rect)(ref rect)).yMax - (num4 + height * 0.5f); _bar.anchorMin = new Vector2(0f, 0f); _bar.anchorMax = new Vector2(0f, 0f); _bar.pivot = new Vector2(0f, 0f); _bar.anchoredPosition = new Vector2(num5, num6); HorizontalLayoutGroup obj = val2.AddComponent(); ((HorizontalOrVerticalLayoutGroup)obj).spacing = 8f; ((LayoutGroup)obj).childAlignment = (TextAnchor)6; ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false; ContentSizeFitter obj2 = val2.AddComponent(); obj2.horizontalFit = (FitMode)2; obj2.verticalFit = (FitMode)2; _sorterBtn = MakeButton(takeAllButton, "psort_toggle", new UnityAction(OnSorterClick), out _sorterLabel); _pinBtn = MakeButton(takeAllButton, "psort_pin", new UnityAction(OnPinClick), out _pinLabel); _clearBtn = MakeButton(takeAllButton, "psort_clear", new UnityAction(OnClearClick), out _clearLabel); _pullBtn = MakeButton(takeAllButton, "psort_pull", new UnityAction(OnPullClick), out _pullLabel); _organizeBtn = MakeButton(takeAllButton, "psort_organize", new UnityAction(OnOrganizeClick), out _organizeLabel); } } } private static Button MakeButton(Button template, string name, UnityAction onClick, out TMP_Text label) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) Button val = Object.Instantiate