Decompiled source of ExpandedCartStorage v1.0.1

ExpandedCartStorage.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using SSSGame;
using SandSailorStudio.Inventory;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("blacks7ar")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ExpandedCartStorage")]
[assembly: AssemblyTitle("ExpandedCartStorage")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
namespace ExpandedCartStorage;

[BepInPlugin("blacks7ar.ExpandedCartStorage", "ExpandedCartStorage", "1.0.1")]
public class Plugin : BasePlugin
{
	[HarmonyPatch]
	private static class Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(ItemContainer), "GetStackSize", new Type[] { typeof(ItemInfo) })]
		private static void ItemContainer_GetStackSize_Postfix(ItemContainer __instance, ItemInfo itemInfo, ref int __result)
		{
			if (((__instance != null) ? __instance.Inventory : null) == null || (Object)(object)__instance.Inventory.Owner == (Object)null)
			{
				return;
			}
			CartStructure componentInParent = __instance.Inventory.Owner.GetComponentInParent<CartStructure>();
			if (!((Object)(object)componentInParent == (Object)null))
			{
				if (((Object)((Component)componentInParent).gameObject).name.Contains("Sled"))
				{
					__result = Helper.ApplyMultiplier(__instance, itemInfo, __result, 3);
				}
				if (((Object)((Component)componentInParent).gameObject).name.Contains("Cart"))
				{
					__result = Helper.ApplyMultiplier(__instance, itemInfo, __result, 5);
				}
			}
		}
	}

	private static class Helper
	{
		public static int ApplyMultiplier(ItemContainer container, ItemInfo itemInfo, int baseStack, int multiplier)
		{
			if (((container != null) ? container.Inventory : null) == null)
			{
				return baseStack;
			}
			int result = baseStack;
			if ((Object)(object)container.containerType == (Object)null)
			{
				return baseStack;
			}
			if (((Object)container.containerType).name.Contains("LargeItems"))
			{
				return baseStack * multiplier;
			}
			if (((Object)container.containerType).name.Contains("MediumItems"))
			{
				return baseStack * 10 * multiplier;
			}
			if (((Object)container.containerType).name.Contains("SmallItems"))
			{
				if ((Object)(object)itemInfo == (Object)null)
				{
					return baseStack;
				}
				if (itemInfo.stackSize == 1)
				{
					return baseStack * 10 * multiplier;
				}
				return baseStack * multiplier;
			}
			return result;
		}
	}

	private const string modGUID = "blacks7ar.ExpandedCartStorage";

	public const string modName = "ExpandedCartStorage";

	public const string modAuthor = "blacks7ar";

	public const string modVersion = "1.0.1";

	private static ManualLogSource ELogger;

	public override void Load()
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		ELogger = ((BasePlugin)this).Log;
		ELogger.LogInfo((object)"Mod loaded!");
		new Harmony("blacks7ar.ExpandedCartStorage").PatchAll();
	}
}