Decompiled source of LcAdrenalineMod v1.0.1

LC Adrenaline Mod.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 BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LC_Adrenaline_Mod.Patches;
using LethalCompanyInputUtils.Api;
using StaticNetcodeLib;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LC Adrenaline Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LC Adrenaline Mod")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ad3922ac-8aa3-49ba-ad8e-1b889e62c85e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LC_Adrenaline_Mod
{
	[BepInPlugin("Fury.AdrenalineMod", "AdrenalineMod", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class AdrenalineModBase : BaseUnityPlugin
	{
		public class InputClass : LcInputActions
		{
			[InputAction(/*Could not decode attribute arguments.*/)]
			public InputAction AdrenalineModExplodeKey { get; set; }
		}

		private const string modGUID = "Fury.AdrenalineMod";

		private const string modName = "AdrenalineMod";

		private const string modVersion = "1.0.1";

		internal static InputClass InputActionsInstance;

		private readonly Harmony harmony = new Harmony("Fury.AdrenalineMod");

		private static AdrenalineModBase Instance;

		internal ManualLogSource mls;

		private ConfigEntry<bool> configCanKillOtherPlayers;

		public static bool canKillOtherPlayers;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Fury.AdrenalineMod");
			mls.LogInfo((object)"The adrenaline mod has awoken :)");
			harmony.PatchAll(typeof(AdrenalineModBase));
			harmony.PatchAll(typeof(AdrenalineModPlayerControllerBPatch));
			configCanKillOtherPlayers = ((BaseUnityPlugin)this).Config.Bind<bool>("Adrenaline Overdose", "Can kill other players", true, "Determines if the adrenaline overdose explosion can kill other players.");
			canKillOtherPlayers = configCanKillOtherPlayers.Value;
			InputActionsInstance = new InputClass();
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
}
namespace LC_Adrenaline_Mod.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	[StaticNetcode]
	internal class AdrenalineModPlayerControllerBPatch : NetworkBehaviour
	{
		private static float adrenalineTimer;

		private static float adrenalineCooldown;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void adrenalinePatch(ref int ___health, ref float ___sprintMultiplier, ref bool ___isSprinting, PlayerControllerB __instance)
		{
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			adrenalineCooldown = Mathf.Clamp(adrenalineCooldown - Time.deltaTime, 0f, 100f);
			if (adrenalineTimer > 0f)
			{
				if (___isSprinting)
				{
					___sprintMultiplier = Mathf.Lerp(2.25f, 3f, adrenalineTimer);
				}
				else
				{
					___sprintMultiplier = Mathf.Lerp(1f, 1.5f, adrenalineTimer);
				}
				adrenalineTimer -= Time.deltaTime;
				adrenalineCooldown = 5f;
			}
			if (AdrenalineModBase.InputActionsInstance.AdrenalineModExplodeKey.triggered && ((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled && __instance.AllowPlayerDeath() && !__instance.isTestingPlayer && !__instance.inTerminalMenu && !__instance.isTypingChat)
			{
				AdrenalineModExplodeServerRpc(((Component)__instance).transform.position, AdrenalineModBase.canKillOtherPlayers);
				if (!AdrenalineModBase.canKillOtherPlayers)
				{
					Landmine.SpawnExplosion(((Component)__instance).transform.position + Vector3.up, false, 0f, 10f, 100000, 0f, (GameObject)null, false);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public static void AdrenalineModExplodeServerRpc(Vector3 pos, bool canKillOtherPlayers)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			AdrenalineModExplodeClientRpc(pos, canKillOtherPlayers);
		}

		[ClientRpc]
		public static void AdrenalineModExplodeClientRpc(Vector3 pos, bool canKillOtherPlayers)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			if (canKillOtherPlayers)
			{
				Landmine.SpawnExplosion(pos + Vector3.up, true, 0f, 10f, 100000, 0f, (GameObject)null, false);
			}
			else
			{
				Landmine.SpawnExplosion(pos + Vector3.up, true, 0f, 0f, 0, 0f, (GameObject)null, false);
			}
		}

		[HarmonyPatch("DamagePlayer")]
		[HarmonyPostfix]
		private static void setAdrenalineTimer()
		{
			if (adrenalineCooldown <= 0f)
			{
				adrenalineTimer = 3f;
			}
		}
	}
}