Decompiled source of BackstabRework v1.0.4

BackstabRework.dll

Decompiled 3 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using IL.RoR2;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using R2API;
using R2API.Utils;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BackstabRework")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BackstabRework")]
[assembly: AssemblyTitle("BackstabRework")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BackstabRework;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.Moffein.BackstabRework", "Backstab Rework", "1.0.4")]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class BackstabRework : BaseUnityPlugin
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static Func<Instruction, bool> <>9__2_1;

		public static Func<int, CharacterBody, int> <>9__2_2;

		public static Manipulator <>9__2_0;

		internal void <Awake>b__2_0(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "ConvertCritChanceToCritDamage")
			});
			val.Index += 2;
			val.Emit(OpCodes.Ldarg_0);
			val.EmitDelegate<Func<int, CharacterBody, int>>((Func<int, CharacterBody, int>)delegate(int cdCount, CharacterBody self)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				if (cdCount < 1 && self.bodyIndex == Bandit2Index && ((Enum)self.bodyFlags).HasFlag((Enum)(object)(BodyFlags)128))
				{
					cdCount = 1;
				}
				return cdCount;
			});
		}

		internal bool <Awake>b__2_1(Instruction x)
		{
			return ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "ConvertCritChanceToCritDamage");
		}

		internal int <Awake>b__2_2(int cdCount, CharacterBody self)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (cdCount < 1 && self.bodyIndex == Bandit2Index && ((Enum)self.bodyFlags).HasFlag((Enum)(object)(BodyFlags)128))
			{
				cdCount = 1;
			}
			return cdCount;
		}
	}

	public static BodyIndex Bandit2Index;

	public static float baseCritMultiplier = 1.5f;

	public void Awake()
	{
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Expected O, but got Unknown
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Expected O, but got Unknown
		baseCritMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Base Crit Multiplier", 1.5f, "Bandit's base crit multiplier. 2.0 is standard.").Value;
		LanguageAPI.Add("BackstabRework_BANDIT2_PASSIVE_DESC", "All attacks from <style=cIsDamage>behind</style> are <style=cIsDamage>Critical Strikes</style>. All <style=cIsDamage>Critical Strike Chance</style> is converted into <style=cIsDamage>Critical Strike Damage</style>.");
		GameObject val = LegacyResourcesAPI.Load<GameObject>("prefabs/characterbodies/bandit2body");
		val.GetComponent<SkillLocator>().passiveSkill.skillDescriptionToken = "BackstabRework_BANDIT2_PASSIVE_DESC";
		RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnLoad));
		object obj = <>c.<>9__2_0;
		if (obj == null)
		{
			Manipulator val2 = delegate(ILContext il)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Expected O, but got Unknown
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				ILCursor val3 = new ILCursor(il);
				val3.GotoNext(new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "ConvertCritChanceToCritDamage")
				});
				val3.Index += 2;
				val3.Emit(OpCodes.Ldarg_0);
				val3.EmitDelegate<Func<int, CharacterBody, int>>((Func<int, CharacterBody, int>)delegate(int cdCount, CharacterBody self)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0013: Unknown result type (might be due to invalid IL or missing references)
					if (cdCount < 1 && self.bodyIndex == Bandit2Index && ((Enum)self.bodyFlags).HasFlag((Enum)(object)(BodyFlags)128))
					{
						cdCount = 1;
					}
					return cdCount;
				});
			};
			<>c.<>9__2_0 = val2;
			obj = (object)val2;
		}
		CharacterBody.RecalculateStats += (Manipulator)obj;
		RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(RecalculateStatsAPI_GetStatCoefficients);
	}

	private void OnLoad()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		Bandit2Index = BodyCatalog.FindBodyIndex("Bandit2Body");
	}

	private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody sender, StatHookEventArgs args)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: 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)
		if (sender.bodyIndex == Bandit2Index && ((Enum)sender.bodyFlags).HasFlag((Enum)(object)(BodyFlags)128))
		{
			args.critDamageMultAdd -= 2f - baseCritMultiplier;
		}
	}
}