Decompiled source of GunBodyRecoilPatch v0.1.0

GunBodyRecoilPatch.dll

Decompiled a year ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnboundLib;
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("GunBodyRecoilPatch")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GunBodyRecoilPatch")]
[assembly: AssemblyTitle("GunBodyRecoilPatch")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace GunBodyRecoilPatch;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("Root.Gun.bodyRecoil.Patch", "GunBodyRecoilPatch", "0.1.0")]
[BepInProcess("Rounds.exe")]
public class Main : BaseUnityPlugin
{
	private const string ModId = "Root.Gun.bodyRecoil.Patch";

	private const string ModName = "GunBodyRecoilPatch";

	public const string Version = "0.1.0";

	public static Main instance { get; private set; }

	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Harmony val = new Harmony("Root.Gun.bodyRecoil.Patch");
		val.PatchAll();
	}

	private void Start()
	{
		instance = this;
	}
}
[HarmonyPatch(typeof(Gun), "Start")]
public class PatchGunStart
{
	public static void Postfix(Gun __instance)
	{
		if (!((Object)(object)((Component)__instance).GetComponent<CardInfo>() != (Object)null))
		{
			__instance.bodyRecoil = 0f;
		}
	}
}
[HarmonyPatch(typeof(Gun), "ResetStats")]
public class PatchGunReset
{
	public static void Postfix(Gun __instance)
	{
		__instance.bodyRecoil = 0f;
	}
}
[HarmonyPatch(typeof(Gun), "DoAttack")]
public class PatchGunAttack
{
	public static void Postfix(Gun __instance)
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		Player player = __instance.player;
		if (player == null)
		{
			return;
		}
		PlayerVelocity component = ((Component)player).GetComponent<PlayerVelocity>();
		if (component != null)
		{
			float num = (float)ExtensionMethods.GetFieldValue((object)component, "mass");
			Vector2 val = (Vector2)ExtensionMethods.GetFieldValue((object)component, "velocity");
			float num2 = num / 100f;
			float num3 = 25f * __instance.recoilMuiltiplier;
			float num4 = 1f;
			if (__instance.useCharge)
			{
				num4 = __instance.currentCharge * __instance.chargeRecoilTo;
			}
			player.data.healthHandler.CallTakeForce(Vector2.op_Implicit(-player.data.input.aimDirection * num3 * num2 * __instance.bodyRecoil * num4), (ForceMode2D)1, false, false, 0f);
		}
	}
}
[HarmonyPatch(typeof(ApplyCardStats), "CopyGunStats")]
public class PatchCopyGunStats
{
	public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
	{
		List<CodeInstruction> list = instructions.ToList();
		int i;
		for (i = 0; i < list.Count; i++)
		{
			if (list[i].opcode == OpCodes.Ldfld && list[i].operand.ToString().Contains("bodyRecoil"))
			{
				i -= 2;
				break;
			}
		}
		list.RemoveRange(i, 7);
		return list;
	}

	public static void Postfix(Gun copyFromGun, Gun copyToGun)
	{
		copyToGun.recoilMuiltiplier *= copyFromGun.recoilMuiltiplier;
		copyToGun.bodyRecoil += copyFromGun.bodyRecoil;
	}
}