Decompiled source of KeepAdrenalineLonger v1.0.0

KeepAdrenalineLonger.dll

Decompiled 7 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("KeepAdrenalineLonger")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+414eace1918fa8824db9ae59e55164baa505ef4a")]
[assembly: AssemblyProduct("KeepAdrenalineLonger")]
[assembly: AssemblyTitle("KeepAdrenalineLonger")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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("zopthemop.keepadrenalinelonger", "Keep Adrenaline Longer", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Player), "AddAdrenaline")]
	internal static class Player_AddAdrenaline_Patch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			FieldInfo objB = AccessTools.Field(typeof(Player), "m_adrenalineDegenDelay");
			MethodInfo objB2 = AccessTools.Method(typeof(AnimationCurve), "Evaluate", new Type[1] { typeof(float) }, (Type[])null);
			for (int i = 0; i <= list.Count - 4; i++)
			{
				if (list[i].opcode == OpCodes.Ldarg_0 && list[i + 1].opcode == OpCodes.Ldfld && object.Equals(list[i + 1].operand, objB) && IsLdloc(list[i + 2]) && (list[i + 3].opcode == OpCodes.Callvirt || list[i + 3].opcode == OpCodes.Call) && object.Equals(list[i + 3].operand, objB2))
				{
					list[i].opcode = OpCodes.Ldc_R4;
					list[i].operand = 15f;
					list.RemoveRange(i + 1, 3);
				}
			}
			return list;
		}

		private static bool IsLdloc(CodeInstruction instruction)
		{
			return instruction.opcode == OpCodes.Ldloc || instruction.opcode == OpCodes.Ldloc_S || instruction.opcode == OpCodes.Ldloc_0 || instruction.opcode == OpCodes.Ldloc_1 || instruction.opcode == OpCodes.Ldloc_2 || instruction.opcode == OpCodes.Ldloc_3;
		}
	}

	public const string ModGUID = "zopthemop.keepadrenalinelonger";

	public const string ModName = "Keep Adrenaline Longer";

	public const string ModVersion = "1.0.0";

	public const string ModDescription = "Increases the delay until adrenaline starts draining from 6-10 seconds to 15 seconds";

	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("zopthemop.keepadrenalinelonger");
		val.PatchAll();
	}
}