Decompiled source of TempStorageBugfix v1.0.0

BepInEx/plugins/TempStorageBugfix.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Sparroh")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TempStorageBugfix")]
[assembly: AssemblyTitle("TempStorageBugfix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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;
		}
	}
}
[HarmonyPatch(typeof(GearDetailsWindow), "AddUpgradeToTempStorage")]
internal static class AddUpgradeToTempStoragePatch
{
	private const int MaxTempStorageSlots = 12;

	private static bool Prefix(GearDetailsWindow __instance, UpgradeInstance upgrade, ref bool __result)
	{
		if (__instance.tempStoredUpgrades == null)
		{
			__instance.tempStoredUpgrades = new List<GearUpgradeUI>();
		}
		List<GearUpgradeUI> tempStoredUpgrades = __instance.tempStoredUpgrades;
		int num = 0;
		GearUpgradeUI val = null;
		for (int i = 0; i < tempStoredUpgrades.Count; i++)
		{
			GearUpgradeUI val2 = tempStoredUpgrades[i];
			if ((Object)(object)val2 == (Object)null)
			{
				continue;
			}
			if (((Component)val2).gameObject.activeSelf)
			{
				num++;
				if (((HoverInfoUpgrade)val2).Upgrade == upgrade)
				{
					__result = false;
					return false;
				}
			}
			else if ((Object)(object)val == (Object)null)
			{
				val = val2;
			}
		}
		if (num >= 12)
		{
			__result = false;
			return false;
		}
		if ((Object)(object)val != (Object)null)
		{
			val.SetUpgrade(upgrade, false);
			((Component)val).gameObject.SetActive(true);
			__result = true;
			return false;
		}
		GearUpgradeUI val3 = Object.Instantiate<GearUpgradeUI>(__instance.upgradeUIPrefab, (Transform)(object)__instance.tempStorageParent);
		val3.IsTempStorage = true;
		tempStoredUpgrades.Add(val3);
		val3.SetUpgrade(upgrade, false);
		val3.EnableGridView(true);
		__result = true;
		return false;
	}
}
[BepInPlugin("sparroh.tempstoragebugfix", "TempStorageBugfix", "1.0.0")]
[MycoMod(/*Could not decode attribute arguments.*/)]
public class TempStorageBugfixPlugin : BaseUnityPlugin
{
	public const string PluginGUID = "sparroh.tempstoragebugfix";

	public const string PluginName = "TempStorageBugfix";

	public const string PluginVersion = "1.0.0";

	internal static ManualLogSource Log;

	private Harmony _harmony;

	private void Awake()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		_harmony = new Harmony("sparroh.tempstoragebugfix");
		_harmony.PatchAll(typeof(AddUpgradeToTempStoragePatch));
		Log.LogInfo((object)"TempStorageBugfix v1.0.0 loaded — temp storage capacity uses active slots.");
	}

	private void OnDestroy()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}
}
namespace TempStorageBugfix
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "TempStorageBugfix";

		public const string PLUGIN_NAME = "TempStorageBugfix";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}