Decompiled source of CrusherPerformanceBoost v1.0.2

CrusherPerformanceBoost.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("CrusherImprovements")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CrusherImprovements")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2ea8d49a-d71a-4791-8dab-061f5509d37d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Jinx666.CrusherPerformanceBoost;

[BepInPlugin("jinx666.techtonica.crusherperformanceboost", "Crusher Performance Boost", "1.0")]
public class Patch : BaseUnityPlugin
{
	public const string pluginGuid = "jinx666.techtonica.crusherperformanceboost";

	public const string pluginName = "Crusher Performance Boost";

	public const string pluginVersion = "1.0";

	private static List<int> _cachedCrushable;

	public void Awake()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Expected O, but got Unknown
		//IL_006e: Expected O, but got Unknown
		_cachedCrushable = new List<int>();
		Harmony val = new Harmony("jinx666.techtonica.crusherperformanceboost");
		MethodInfo methodInfo = AccessTools.Method(typeof(GameDefines), "IsResourceCrushable", (Type[])null, (Type[])null);
		MethodInfo methodInfo2 = AccessTools.Method(typeof(Patch), "Prefix", (Type[])null, (Type[])null);
		MethodInfo methodInfo3 = AccessTools.Method(typeof(Patch), "Postfix", (Type[])null, (Type[])null);
		val.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), new HarmonyMethod(methodInfo3), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}

	public static bool Prefix(int resId, ref bool __result, out int __state)
	{
		__state = resId;
		if (_cachedCrushable.Contains(resId))
		{
			__result = true;
			__state = -666;
			return false;
		}
		return true;
	}

	public static void Postfix(ref bool __result, ref int __state)
	{
		if (__result && __state != -666)
		{
			_cachedCrushable.Add(__state);
		}
	}
}