Decompiled source of HeavyBugfix v1.0.0

BepInEx/plugins/HeavyBugfix.dll

Decompiled 2 weeks 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 Pigeon.Math;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("HeavyBugfix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HeavyBugfix")]
[assembly: AssemblyTitle("HeavyBugfix")]
[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;
		}
	}
}
[BepInPlugin("sparroh.heavybugfix", "HeavyBugfix", "1.0.0")]
[MycoMod(/*Could not decode attribute arguments.*/)]
public class HeavyBugfixPlugin : BaseUnityPlugin
{
	public const string PluginGUID = "sparroh.heavybugfix";

	public const string PluginName = "HeavyBugfix";

	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.heavybugfix");
		_harmony.PatchAll(typeof(FireIntervalGetStatDataPatch));
		Log.LogInfo((object)"HeavyBugfix v1.0.0 loaded — fire-interval range display stabilized.");
	}

	private void OnDestroy()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}
}
[HarmonyPatch(typeof(UpgradeProperty_FireInterval), "GetStatData")]
internal static class FireIntervalGetStatDataPatch
{
	private static bool Prefix(UpgradeProperty_FireInterval __instance, Random rand, IUpgradable gear, UpgradeInstance upgrade, ref IEnumerator<StatData> __result)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		__result = BuildStatData(__instance, rand, gear, upgrade);
		return false;
	}

	private static IEnumerator<StatData> BuildStatData(UpgradeProperty_FireInterval instance, Random rand, IUpgradable gear, UpgradeInstance upgrade)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		OverrideData<Range<float>> additiveData = instance.fireInterval.GetAdditiveData(0);
		float prefabFireInterval = GetPrefabFireInterval(gear);
		yield return StatData.CreateInverse(TextBlocks.GetString("firerate"), additiveData, upgrade, ref rand, prefabFireInterval, BoostParams.MinIsBetter);
	}

	private static float GetPrefabFireInterval(IUpgradable gear)
	{
		IUpgradable val = gear;
		try
		{
			if (gear != null)
			{
				IUpgradable prefab = gear.GetPrefab();
				if (prefab != null)
				{
					val = prefab;
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource log = HeavyBugfixPlugin.Log;
			if (log != null)
			{
				log.LogDebug((object)("GetPrefab failed, using provided gear: " + ex.Message));
			}
		}
		IWeapon val2 = (IWeapon)(object)((val is IWeapon) ? val : null);
		if (val2 != null)
		{
			return val2.GunData.fireInterval;
		}
		IWeapon val3 = (IWeapon)(object)((gear is IWeapon) ? gear : null);
		if (val3 != null)
		{
			return val3.GunData.fireInterval;
		}
		return 1f;
	}
}
namespace HeavyBugfix
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "HeavyBugfix";

		public const string PLUGIN_NAME = "HeavyBugfix";

		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)
		{
		}
	}
}