Decompiled source of BiggerChests v1.1.0

ValheimBiggerChests.dll

Decompiled 2 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using JetBrains.Annotations;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ValheimBiggerChests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ValheimBiggerChests")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f6e755ee-cc8b-4bf1-a2a0-f33b35973b6d")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyVersion("1.1.0.0")]
namespace ValheimBiggerChests;

[HarmonyPatch(typeof(Container), "Awake")]
public class ContainerSizePatch
{
	public static void Prefix(ref Container __instance)
	{
		PatchContainerSize(__instance);
	}

	private static void PatchContainerSize(Container instance)
	{
		if (Object.op_Implicit((Object)(object)instance.m_wagon))
		{
			instance.m_width = 8;
			instance.m_height = 4;
			return;
		}
		Transform parent = ((Component)instance).gameObject.transform.parent;
		Ship val = ((parent != null) ? ((Component)parent).GetComponent<Ship>() : null);
		if ((Object)(object)val != (Object)null)
		{
			if (((Object)val).name.StartsWith("VikingShip"))
			{
				instance.m_width = 7;
				instance.m_height = 4;
			}
			else if (((Object)val).name.StartsWith("Karve"))
			{
				instance.m_width = 3;
				instance.m_height = 3;
			}
		}
		else if (((Object)instance).name.StartsWith("piece_chest_wood"))
		{
			instance.m_height = 3;
		}
		else if (((Object)instance).name.StartsWith("piece_chest_private"))
		{
			instance.m_width = 5;
		}
		else if (!((Object)instance).name.StartsWith("piece_chest_blackmetal") && ((Object)instance).name.StartsWith("piece_chest("))
		{
			instance.m_width = 7;
			instance.m_height = 4;
		}
	}
}
[BepInPlugin("dev.cytraen.valheim.biggerchests", "Bigger Chests", "1.1.0")]
public class BiggerChests : BaseUnityPlugin
{
	public const string PluginId = "dev.cytraen.valheim.biggerchests";

	private Harmony _harmony;

	[UsedImplicitly]
	private void Awake()
	{
		_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "dev.cytraen.valheim.biggerchests");
	}

	[UsedImplicitly]
	private void OnDestroy()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}
}