Decompiled source of Custom Chest Size v1.0.32

CustomChestSizeMod.dll

Decompiled 3 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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 HarmonyLib;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("CustomChestSizeMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CustomChestSizeMod")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5a8f8254-fb10-40e9-84cc-b5dc94098a30")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace holybananapants.customchestsize;

[BepInPlugin("holybananapants.customchestsize", "Custom Chest Size", "1.0.3")]
[BepInProcess("valheim.exe")]
public class CustomChestSizeMod : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Container), "Awake")]
	public static class ContainerAwakePrefix
	{
		[HarmonyPrefix]
		public static void Prefix(Container __instance)
		{
			string text = ((Object)__instance).name.ToLower();
			if (text.StartsWith("piece_chest_barrel"))
			{
				ContainerWidthRef.Invoke(__instance) = Barrel_Width.Value;
				ContainerHeightRef.Invoke(__instance) = Barrel_Height.Value;
			}
			else if (text.StartsWith("piece_chest_blackmetal"))
			{
				ContainerWidthRef.Invoke(__instance) = BlackMetalChest_Width.Value;
				ContainerHeightRef.Invoke(__instance) = BlackMetalChest_Height.Value;
			}
			else if (text.StartsWith("piece_chest_private"))
			{
				ContainerWidthRef.Invoke(__instance) = PersonalChest_Width.Value;
				ContainerHeightRef.Invoke(__instance) = PersonalChest_Height.Value;
			}
			else if (text.StartsWith("piece_chest_wood"))
			{
				ContainerWidthRef.Invoke(__instance) = Chest_Width.Value;
				ContainerHeightRef.Invoke(__instance) = Chest_Height.Value;
			}
			else if (text.StartsWith("piece_chest"))
			{
				ContainerWidthRef.Invoke(__instance) = ReinforcedChest_Width.Value;
				ContainerHeightRef.Invoke(__instance) = ReinforcedChest_Height.Value;
			}
		}
	}

	[HarmonyPatch(typeof(InventoryGui), "UpdateContainer")]
	public static class InventoryGuiLayoutPatch
	{
		private static readonly FieldRef<InventoryGui, RectTransform> ContainerRectRef = AccessTools.FieldRefAccess<InventoryGui, RectTransform>("m_container");

		private static readonly FieldRef<InventoryGui, Button> TakeAllButtonRef = AccessTools.FieldRefAccess<InventoryGui, Button>("m_takeAllButton");

		private static readonly FieldRef<InventoryGui, Button> StackAllButtonRef = AccessTools.FieldRefAccess<InventoryGui, Button>("m_stackAllButton");

		[HarmonyPostfix]
		public static void Postfix(InventoryGui __instance)
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: 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_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = ContainerRectRef.Invoke(__instance);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Button val2 = TakeAllButtonRef.Invoke(__instance);
			Button val3 = StackAllButtonRef.Invoke(__instance);
			if ((Object)(object)val2 != (Object)null && (Object)(object)val3 != (Object)null)
			{
				Transform transform = ((Component)val2).transform;
				RectTransform val4 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
				if (val4 != null)
				{
					Transform transform2 = ((Component)val3).transform;
					RectTransform val5 = (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null);
					if (val5 != null)
					{
						val4.anchorMin = new Vector2(0f, 1f);
						val4.anchorMax = new Vector2(0f, 1f);
						val4.pivot = new Vector2(0f, 1f);
						val4.anchoredPosition = new Vector2(10f, 0f);
						val5.anchorMin = new Vector2(1f, 1f);
						val5.anchorMax = new Vector2(1f, 1f);
						val5.pivot = new Vector2(1f, 1f);
						val5.anchoredPosition = new Vector2(-10f, 0f);
					}
				}
			}
			ScrollRect componentInChildren = ((Component)val).GetComponentInChildren<ScrollRect>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				Scrollbar verticalScrollbar = componentInChildren.verticalScrollbar;
				if ((Object)(object)verticalScrollbar != (Object)null)
				{
					Transform transform3 = ((Component)verticalScrollbar).transform;
					RectTransform val6 = (RectTransform)(object)((transform3 is RectTransform) ? transform3 : null);
					if (val6 != null)
					{
						val6.anchoredPosition = new Vector2(285f, -28f);
					}
				}
			}
			InventoryGrid componentInChildren2 = ((Component)val).GetComponentInChildren<InventoryGrid>();
			Transform obj = ((componentInChildren2 != null) ? ((Component)componentInChildren2).transform : null);
			RectTransform val7 = (RectTransform)(object)((obj is RectTransform) ? obj : null);
			if ((Object)(object)val7 != (Object)null)
			{
				val7.offsetMax = new Vector2(val7.offsetMax.x, -60f);
			}
			LayoutRebuilder.ForceRebuildLayoutImmediate(val);
		}
	}

	[HarmonyPatch(typeof(InventoryGrid), "UpdateGamepad")]
	public static class InventoryGridUpdateGamepadTranspiler
	{
		private static readonly FieldInfo m_widthField = AccessTools.Field(typeof(InventoryGrid), "m_width");

		private static readonly FieldInfo m_heightField = AccessTools.Field(typeof(InventoryGrid), "m_height");

		private static readonly MethodInfo Mathf_Min_Int = AccessTools.Method(typeof(Mathf), "Min", new Type[2]
		{
			typeof(int),
			typeof(int)
		}, (Type[])null);

		public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			bool flag = false;
			if (m_widthField == null || m_heightField == null || Mathf_Min_Int == null)
			{
				ModLogger.LogError((object)"Transpiler failed: Could not find required fields (m_width/m_height) or method (Mathf.Min).");
				return instructions;
			}
			for (int i = 0; i < list.Count; i++)
			{
				if (!(list[i].opcode == OpCodes.Call) || !(list[i].operand is MethodInfo methodInfo) || !(methodInfo == Mathf_Min_Int))
				{
					continue;
				}
				int num = -1;
				int num2 = i - 1;
				while (true)
				{
					if (num2 >= 0)
					{
						if (list[num2].opcode == OpCodes.Nop || list[num2].opcode.OpCodeType == OpCodeType.Prefix || list[num2].opcode.FlowControl == FlowControl.Branch || list[num2].opcode.FlowControl == FlowControl.Return)
						{
							goto IL_02df;
						}
						if (!(list[num2].opcode == OpCodes.Ldfld) || !(list[num2].operand is FieldInfo fieldInfo) || !(fieldInfo == m_widthField))
						{
							if (list[num2].opcode == OpCodes.Call || list[num2].opcode == OpCodes.Callvirt || (list[num2].opcode.OpCodeType == OpCodeType.Macro && (list[num2].opcode.Name.StartsWith("stloc") || list[num2].opcode.Name.StartsWith("starg"))) || (list[num2].opcode.OpCodeType == OpCodeType.Primitive && (list[num2].opcode == OpCodes.Stloc || list[num2].opcode == OpCodes.Starg)) || list[num2].opcode == OpCodes.Newobj || list[num2].opcode == OpCodes.Throw || list[num2].opcode == OpCodes.Ret)
							{
								ModLogger.LogWarning((object)$"Transpiler (Revised): Encountered potential interrupting opcode {list[num2].opcode.Name} at index {num2} during backward search. Aborting search for this Mathf.Min instance.");
								num = -1;
								break;
							}
							goto IL_02df;
						}
						num = num2;
						ModLogger.LogInfo((object)$"Transpiler (Revised): Found ldfld m_width at index {num2} preceding Mathf.Min");
					}
					if (num != -1)
					{
						list[num].operand = m_heightField;
						flag = true;
					}
					else
					{
						ModLogger.LogWarning((object)("Transpiler (Revised): Could not find ldfld m_width preceding the Mathf.Min call at index " + i + ". Patch failed for this instance."));
					}
					break;
					IL_02df:
					num2--;
				}
			}
			if (!flag)
			{
				ModLogger.LogWarning((object)"InventoryGrid.UpdateGamepad Transpiler (Revised) finished, but no relevant Mathf.Min call and preceding ldfld m_width pattern was found to patch. Controller selection may still be clamped.");
			}
			return list.AsEnumerable();
		}
	}

	[HarmonyPatch(typeof(InventoryGrid), "UpdateGamepad")]
	public static class InventoryGridUpdateGamepadPostfix
	{
		private static readonly FieldRef<InventoryGrid, Inventory> InventoryRef = AccessTools.FieldRefAccess<InventoryGrid, Inventory>("m_inventory");

		private static readonly FieldRef<InventoryGui, InventoryGrid> InventoryGuiContainerGridRef = AccessTools.FieldRefAccess<InventoryGui, InventoryGrid>("m_containerGrid");

		private static readonly FieldRef<InventoryGui, Animator> InventoryGuiAnimatorRef = AccessTools.FieldRefAccess<InventoryGui, Animator>("m_animator");

		private static readonly FieldRef<InventoryGrid, Vector2i> GamepadSelectionRef = AccessTools.FieldRefAccess<InventoryGrid, Vector2i>("m_selected");

		private const string ElementsFieldName = "m_elements";

		private static FieldInfo s_elementsField = AccessTools.Field(typeof(InventoryGrid), "m_elements");

		[HarmonyPostfix]
		public static void Postfix(InventoryGrid __instance)
		{
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_0084: 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_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)InventoryGui.instance == (Object)null)
			{
				return;
			}
			InventoryGrid val = null;
			try
			{
				val = InventoryGuiContainerGridRef.Invoke(InventoryGui.instance);
			}
			catch (Exception ex)
			{
				ModLogger.LogError((object)("[GAMEPAD_SCROLL_DEBUG] Failed to get InventoryGui.m_containerGrid: " + ex.Message));
				return;
			}
			if ((Object)(object)__instance != (Object)(object)val)
			{
				return;
			}
			Vector2i zero = Vector2i.zero;
			int num = 0;
			int num2 = 0;
			int num3 = -1;
			try
			{
				zero = GamepadSelectionRef.Invoke(__instance);
				num = AccessTools.FieldRefAccess<InventoryGrid, int>("m_width").Invoke(__instance);
				num2 = AccessTools.FieldRefAccess<InventoryGrid, int>("m_height").Invoke(__instance);
				if (s_elementsField != null)
				{
					try
					{
						if (s_elementsField.GetValue(__instance) is IList list)
						{
							num3 = list.Count;
						}
						else
						{
							ModLogger.LogWarning((object)"[GAMEPAD_SCROLL_DEBUG] Field 'm_elements' found, but value is not an IList.");
						}
					}
					catch (Exception ex2)
					{
						ModLogger.LogWarning((object)("[GAMEPAD_SCROLL_DEBUG] Error accessing field 'm_elements': " + ex2.Message));
					}
				}
				else
				{
					ModLogger.LogWarning((object)"[GAMEPAD_SCROLL_DEBUG] Field 'm_elements' not found in InventoryGrid.");
				}
				long num4 = (long)zero.y * (long)num + zero.x;
				if (num3 <= 0)
				{
					if (num4 < 0 || num4 >= (long)num * (long)num2)
					{
						ModLogger.LogError((object)$"[GAMEPAD_SCROLL_DEBUG] Detected out-of-bounds selection ({zero.x},{zero.y}) for size ({num}x{num2}) even with ElementCount={num3}. Selection logic might need adjustment.");
					}
					return;
				}
				if (num3 != num * num2)
				{
					ModLogger.LogWarning((object)$"[GAMEPAD_SCROLL_DEBUG] Element count ({num3}) does not match calculated size ({num * num2}). Potential UI creation issue.");
				}
				RectTransform gamepadSelectedElement = __instance.GetGamepadSelectedElement();
				if ((Object)(object)gamepadSelectedElement == (Object)null)
				{
					return;
				}
				ScrollRect componentInParent = ((Component)gamepadSelectedElement).GetComponentInParent<ScrollRect>();
				if ((Object)(object)componentInParent == (Object)null)
				{
					return;
				}
				Inventory val2 = InventoryRef.Invoke(__instance);
				if (val2 == null)
				{
					return;
				}
				int height = val2.GetHeight();
				int num5 = 4;
				if (height <= num5)
				{
					if (Mathf.Abs(componentInParent.verticalNormalizedPosition - 1f) > 0.001f)
					{
						componentInParent.verticalNormalizedPosition = 1f;
					}
					return;
				}
				zero = GamepadSelectionRef.Invoke(__instance);
				num = AccessTools.FieldRefAccess<InventoryGrid, int>("m_width").Invoke(__instance);
				num2 = AccessTools.FieldRefAccess<InventoryGrid, int>("m_height").Invoke(__instance);
				int y = zero.y;
				float verticalNormalizedPosition = componentInParent.verticalNormalizedPosition;
				float num6 = ((height > 1) ? (1f - (float)y / (float)(height - 1)) : 1f);
				int num7 = Mathf.Max(0, y - num5 + 1);
				float num8 = ((height > 1) ? (1f - (float)num7 / (float)(height - 1)) : 1f);
				float num9 = verticalNormalizedPosition;
				int num10 = Mathf.FloorToInt((1f - verticalNormalizedPosition) * (float)Mathf.Max(0, height - num5));
				int num11 = num10 + num5 - 1;
				if (y < num10)
				{
					num9 = 1f - (float)y / (float)Mathf.Max(1, height - num5);
				}
				else if (y > num11)
				{
					num9 = 1f - (float)(y - num5 + 1) / (float)Mathf.Max(1, height - num5);
					num9 = Mathf.Max(0f, num9);
				}
				num9 = Mathf.Clamp01(num9);
				if (Mathf.Abs(num9 - verticalNormalizedPosition) > 0.005f)
				{
					componentInParent.verticalNormalizedPosition = num9;
				}
			}
			catch (Exception ex3)
			{
				ModLogger.LogError((object)("[GAMEPAD_SCROLL_DEBUG] Error in Postfix logic: " + ex3.ToString()));
			}
		}
	}

	public static ConfigEntry<int> Chest_Width;

	public static ConfigEntry<int> Chest_Height;

	public static ConfigEntry<int> ReinforcedChest_Width;

	public static ConfigEntry<int> ReinforcedChest_Height;

	public static ConfigEntry<int> Barrel_Width;

	public static ConfigEntry<int> Barrel_Height;

	public static ConfigEntry<int> BlackMetalChest_Width;

	public static ConfigEntry<int> BlackMetalChest_Height;

	public static ConfigEntry<int> PersonalChest_Width;

	public static ConfigEntry<int> PersonalChest_Height;

	private static Harmony _harmony;

	private static readonly FieldRef<Container, int> ContainerWidthRef = AccessTools.FieldRefAccess<Container, int>("m_width");

	private static readonly FieldRef<Container, int> ContainerHeightRef = AccessTools.FieldRefAccess<Container, int>("m_height");

	private static readonly FieldRef<InventoryGui, Container> InventoryGuiCurrentContainerRef = AccessTools.FieldRefAccess<InventoryGui, Container>("m_currentContainer");

	public static CustomChestSizeMod Instance { get; private set; }

	public static ManualLogSource ModLogger { get; private set; }

	private void Awake()
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Expected O, but got Unknown
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Expected O, but got Unknown
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Expected O, but got Unknown
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Expected O, but got Unknown
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Expected O, but got Unknown
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Expected O, but got Unknown
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Expected O, but got Unknown
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Expected O, but got Unknown
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Expected O, but got Unknown
		//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b7: Expected O, but got Unknown
		Instance = this;
		ModLogger = ((BaseUnityPlugin)this).Logger;
		Chest_Width = ((BaseUnityPlugin)this).Config.Bind<int>("Chest", "Width", 5, new ConfigDescription("Width for Chest (piece_chest_wood) (max 8)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), Array.Empty<object>()));
		Chest_Height = ((BaseUnityPlugin)this).Config.Bind<int>("Chest", "Height", 3, new ConfigDescription("Height for Chest (piece_chest_wood) (max 20)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>()));
		ReinforcedChest_Width = ((BaseUnityPlugin)this).Config.Bind<int>("Reinforced Chest", "Width", 8, new ConfigDescription("Width for Reinforced Chest (piece_chest) (max 8)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), Array.Empty<object>()));
		ReinforcedChest_Height = ((BaseUnityPlugin)this).Config.Bind<int>("Reinforced Chest", "Height", 4, new ConfigDescription("Height for Reinforced Chest (piece_chest) (max 20)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>()));
		Barrel_Width = ((BaseUnityPlugin)this).Config.Bind<int>("Barrel", "Width", 6, new ConfigDescription("Width for Barrel (piece_chest_barrel) (max 8)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), Array.Empty<object>()));
		Barrel_Height = ((BaseUnityPlugin)this).Config.Bind<int>("Barrel", "Height", 4, new ConfigDescription("Height for Barrel (piece_chest_barrel) (max 20)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>()));
		BlackMetalChest_Width = ((BaseUnityPlugin)this).Config.Bind<int>("Black Metal Chest", "Width", 8, new ConfigDescription("Width for Black Metal Chest (piece_chest_blackmetal) (max 8)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), Array.Empty<object>()));
		BlackMetalChest_Height = ((BaseUnityPlugin)this).Config.Bind<int>("Black Metal Chest", "Height", 8, new ConfigDescription("Height for Black Metal Chest (piece_chest_blackmetal) (max 20)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>()));
		PersonalChest_Width = ((BaseUnityPlugin)this).Config.Bind<int>("Personal Chest", "Width", 8, new ConfigDescription("Width for Personal Chest (piece_chest_private) (max 8)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), Array.Empty<object>()));
		PersonalChest_Height = ((BaseUnityPlugin)this).Config.Bind<int>("Personal Chest", "Height", 20, new ConfigDescription("Height for Personal Chest (piece_chest_private) (max 20)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>()));
		Chest_Width.SettingChanged += delegate
		{
			UpdateAllContainers();
		};
		Chest_Height.SettingChanged += delegate
		{
			UpdateAllContainers();
		};
		ReinforcedChest_Width.SettingChanged += delegate
		{
			UpdateAllContainers();
		};
		ReinforcedChest_Height.SettingChanged += delegate
		{
			UpdateAllContainers();
		};
		Barrel_Width.SettingChanged += delegate
		{
			UpdateAllContainers();
		};
		Barrel_Height.SettingChanged += delegate
		{
			UpdateAllContainers();
		};
		BlackMetalChest_Width.SettingChanged += delegate
		{
			UpdateAllContainers();
		};
		BlackMetalChest_Height.SettingChanged += delegate
		{
			UpdateAllContainers();
		};
		PersonalChest_Width.SettingChanged += delegate
		{
			UpdateAllContainers();
		};
		PersonalChest_Height.SettingChanged += delegate
		{
			UpdateAllContainers();
		};
		_harmony = new Harmony("holybananapants.customchestsize");
		_harmony.PatchAll();
		ModLogger.LogInfo((object)"Custom Chest Size Mod loaded!");
		UpdateAllContainers();
	}

	public static void UpdateAllContainers()
	{
		if ((Object)(object)ZNet.instance != (Object)null && !ZNet.instance.IsServer())
		{
			ModLogger.LogInfo((object)"Not host; skipping chest updates.");
			return;
		}
		Container[] array = Object.FindObjectsOfType<Container>();
		Container[] array2 = array;
		foreach (Container val in array2)
		{
			string text = ((Object)val).name.ToLower();
			bool flag = false;
			if (text.StartsWith("piece_chest_barrel"))
			{
				ContainerWidthRef.Invoke(val) = Barrel_Width.Value;
				ContainerHeightRef.Invoke(val) = Barrel_Height.Value;
				flag = true;
			}
			else if (text.StartsWith("piece_chest_blackmetal"))
			{
				ContainerWidthRef.Invoke(val) = BlackMetalChest_Width.Value;
				ContainerHeightRef.Invoke(val) = BlackMetalChest_Height.Value;
				flag = true;
			}
			else if (text.StartsWith("piece_chest_private"))
			{
				ContainerWidthRef.Invoke(val) = PersonalChest_Width.Value;
				ContainerHeightRef.Invoke(val) = PersonalChest_Height.Value;
				flag = true;
			}
			else if (text.StartsWith("piece_chest_wood"))
			{
				ContainerWidthRef.Invoke(val) = Chest_Width.Value;
				ContainerHeightRef.Invoke(val) = Chest_Height.Value;
				flag = true;
			}
			else if (text.StartsWith("piece_chest"))
			{
				ContainerWidthRef.Invoke(val) = ReinforcedChest_Width.Value;
				ContainerHeightRef.Invoke(val) = ReinforcedChest_Height.Value;
				flag = true;
			}
			if (flag)
			{
				ModLogger.LogInfo((object)$"Updated {((Object)val).name} to {ContainerWidthRef.Invoke(val)} x {ContainerHeightRef.Invoke(val)}");
				if ((Object)(object)InventoryGui.instance != (Object)null && (Object)(object)InventoryGuiCurrentContainerRef.Invoke(InventoryGui.instance) == (Object)(object)val)
				{
					InventoryGui.instance.UpdateContainer(Player.m_localPlayer);
				}
			}
		}
	}
}