Decompiled source of LargeResourceCap v1.0.1

LargeResoureCap.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 LargeResoureCap
{
	[BepInPlugin("com.coloron.largeresourecap", "No Resource Cap", "1.0.0")]
	[MycoMod(/*Could not decode attribute arguments.*/)]
	public class LargeResoureCapPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.coloron.largeresourecap";

		public const string PluginName = "No Resource Cap";

		public const string PluginVersion = "1.0.0";

		public const int CapValue = 99999;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			_harmony = new Harmony("com.coloron.largeresourecap");
			_harmony.PatchAll(typeof(LargeResoureCapPlugin).Assembly);
			((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("[{0}] Loaded. Resource/item cap overridden to {1}.", "No Resource Cap", 99999));
		}

		private void OnDestroy()
		{
			if (_harmony != null)
			{
				_harmony.UnpatchSelf();
			}
		}
	}
	[HarmonyPatch(typeof(PlayerResource), "get_Max")]
	public static class Patch_PlayerResource_Max
	{
		private static bool Prefix(PlayerResource __instance, ref int __result)
		{
			__result = 99999;
			return false;
		}
	}
	[HarmonyPatch(typeof(PlayerData), "AddResource", new Type[]
	{
		typeof(PlayerResource),
		typeof(int),
		typeof(bool)
	})]
	public static class Patch_PlayerData_AddResource
	{
		private static void Postfix(PlayerData __instance, PlayerResource resource, int amount, bool invokeMissionUpdate)
		{
			if (amount > 0 && !((Object)(object)resource == (Object)null))
			{
				int resource2 = __instance.GetResource(resource);
				int value = Mathf.Min(resource2 + amount, 99999);
				Traverse val = Traverse.Create((object)__instance).Field("resources");
				Dictionary<string, int> value2 = val.GetValue<Dictionary<string, int>>();
				if (value2 != null)
				{
					value2[resource.ID] = value;
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerData), "AddItem", new Type[]
	{
		typeof(IInventoryItem),
		typeof(int)
	})]
	public static class Patch_PlayerData_AddItem
	{
		private static void Postfix(PlayerData __instance, IInventoryItem item, int count)
		{
			if (count > 0 && item != null && !(item is PlayerResource))
			{
				int item2 = __instance.GetItem(item);
				int value = Mathf.Min(item2 + count, 99999);
				Traverse val = Traverse.Create((object)__instance).Field("items");
				Dictionary<string, int> value2 = val.GetValue<Dictionary<string, int>>();
				if (value2 != null)
				{
					value2[item.ID] = value;
				}
			}
		}
	}
}