Decompiled source of AllCrestWillCrit v1.1.0

AllCrestsCrit.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AllCrestsCrit")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AllCrestsCrit")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("330a93f5-1e0e-476d-85b3-7f2c3e98325d")]
[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")]
[BepInPlugin("arbaz9234.allcrests.crit", "All Crests Critical Hits", "1.0.0")]
public class AllCrestsCrit : BaseUnityPlugin
{
	internal static AllCrestsCrit Instance;

	internal ConfigEntry<bool> EnableMod;

	internal ConfigEntry<float> CritChanceAdd;

	private void Awake()
	{
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Expected O, but got Unknown
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		Instance = this;
		EnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("Critical Hits", "Enable", true, "Enable critical hits for all crests");
		CritChanceAdd = ((BaseUnityPlugin)this).Config.Bind<float>("Critical Hits", "Crit Chance Bonus", 0.25f, new ConfigDescription("Additional crit chance (0.25 = +25%)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		new Harmony("silksong.allcrests.crit").PatchAll();
	}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
public static class Patch_IsWandererLucky
{
	[HarmonyPostfix]
	public static void Postfix(ref bool __result)
	{
		if (!AllCrestsCrit.Instance.EnableMod.Value)
		{
			return;
		}
		PlayerData instance = PlayerData.instance;
		if (instance != null)
		{
			if (HeroController.instance.cState.isMaggoted)
			{
				__result = false;
			}
			else if (instance.silk < 9)
			{
				__result = false;
			}
			else
			{
				__result = true;
			}
		}
	}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
public static class Patch_WandererCritChance
{
	[HarmonyPostfix]
	public static void Postfix(ref float __result)
	{
		float value = AllCrestsCrit.Instance.CritChanceAdd.Value;
		if (!(value <= 0f))
		{
			__result = Mathf.Clamp01(__result + value);
		}
	}
}