Decompiled source of Balanced HellDivers v1.0.1

BalancedHellDivers.dll

Decompiled 3 weeks ago
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 HarmonyLib;
using Photon.Pun;
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("AnotherTestMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AnotherTestMod")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("63d550f7-2e30-444b-8e75-9061c166f488")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace DiveMod;

[BepInPlugin("Rissoe.DiverMod", "DiverMod", "1.0.0")]
public class DiverMod : BaseUnityPlugin
{
	public const string modGUID = "Rissoe.DiverMod";

	public const string modName = "DiverMod";

	public const string modVersion = "1.0.0";

	public static float DiveCharge = 0f;

	public static ManualLogSource Logs = Logger.CreateLogSource("Rissoe.DiverMod");

	private readonly Harmony harmony = new Harmony("Rissoe.DiverMod");

	public static ConfigEntry<KeyCode> ConfigDiveKey;

	public static ConfigEntry<float> ConfigDiveStamina;

	public static ConfigEntry<float> ConfigDiveStrength;

	public static ConfigEntry<bool> ConfigDiveInstant;

	public static ConfigEntry<float> ConfigDiveSpeed;

	public static ConfigEntry<int> ConfigDiveShake;

	private void Awake()
	{
		ConfigDiveKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Dive Key", (KeyCode)102, "The key you use to Dive");
		ConfigDiveStamina = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Stamina Usage", 1f, "Stamina to use while diving, higher number = less stamina (must be inbetween 0.5-2)");
		ConfigDiveStrength = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Dive Strength", 1f, "Dive Strength, keep in mind, further dives make you ragdoll longer! (must be inbetween 0.5-1.5)");
		ConfigDiveInstant = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Instant Dive", false, "Makes you dive instantly, at the penalty of having more ragdoll time. Also disables the 2 next settings.");
		ConfigDiveSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Charge Speed", 2f, "Speed to charge, lower is slower (must be 1-4)");
		ConfigDiveShake = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Screen Shake", 15, "Higher number = less screenshake when charging (0 = off, must be 1-100)");
		harmony.PatchAll(typeof(DiverMod));
		Logs.LogMessage((object)"Rissoe.DiverMod dives into the game.");
	}

	[HarmonyPatch(typeof(PerlinShake))]
	[HarmonyPatch("Update")]
	[HarmonyPostfix]
	private static void Dive(PerlinShake __instance)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_035b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_030a: Unknown result type (might be due to invalid IL or missing references)
		//IL_030f: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		if (UnityInput.Current.GetKeyDown(ConfigDiveKey.Value))
		{
			DiveCharge = 0f;
			if (ConfigDiveInstant.Value && Player.localPlayer.data.fallTime <= 0f)
			{
				DiveCharge = 10f;
				Player.localPlayer.data.isGrounded = false;
				PlayerData data = Player.localPlayer.data;
				data.currentStamina -= DiveCharge / 1.5f / Mathf.Clamp(ConfigDiveStamina.Value, 0.5f, 2f);
				if (Player.localPlayer.data.currentStamina < 0f)
				{
					DiveCharge += Player.localPlayer.data.currentStamina;
					Player.localPlayer.data.currentStamina = 0f;
				}
				Mathf.Max(DiveCharge, 0f);
				CallTakeDamageAndAddForceAndFall(0f, Vector3.up * DiveCharge * Mathf.Clamp(ConfigDiveStrength.Value, 0.5f, 1.5f) + Vector3Extensions.Flat(Player.localPlayer.data.lookDirection) * DiveCharge * Mathf.Clamp(ConfigDiveStrength.Value, 0.5f, 1.5f), DiveCharge * Mathf.Clamp(ConfigDiveStrength.Value, 0.5f, 1.5f) / 2f);
			}
		}
		else if (UnityInput.Current.GetKeyUp(ConfigDiveKey.Value) && !ConfigDiveInstant.Value && Player.localPlayer.data.fallTime <= 0f && DiveCharge > 1.5f)
		{
			Player.localPlayer.data.isGrounded = false;
			PlayerData data2 = Player.localPlayer.data;
			data2.currentStamina -= DiveCharge / 1.5f / Mathf.Clamp(ConfigDiveStamina.Value, 0.5f, 5f);
			if (Player.localPlayer.data.currentStamina < 0f)
			{
				DiveCharge += Player.localPlayer.data.currentStamina;
				Player.localPlayer.data.currentStamina = 0f;
			}
			Mathf.Max(DiveCharge, 0f);
			CallTakeDamageAndAddForceAndFall(0f, Vector3.up * DiveCharge * Mathf.Clamp(ConfigDiveStrength.Value, 0.5f, 1.5f) + Vector3Extensions.Flat(Player.localPlayer.data.lookDirection) * DiveCharge * Mathf.Clamp(ConfigDiveStrength.Value, 0.5f, 1.5f), DiveCharge * Mathf.Clamp(ConfigDiveStrength.Value, 0.5f, 1.5f) / 4f);
		}
		else if (!ConfigDiveInstant.Value && UnityInput.Current.GetKey(ConfigDiveKey.Value))
		{
			DiveCharge = Mathf.Lerp(DiveCharge, 10f, Time.deltaTime / Mathf.Clamp(ConfigDiveSpeed.Value, 1f, 4f));
			if (ConfigDiveShake.Value > 0)
			{
				__instance.AddShake(DiveCharge / (float)Mathf.Clamp(ConfigDiveShake.Value, 1, 100), 0.2f, 10f);
			}
		}
	}

	public static void CallTakeDamageAndAddForceAndFall(float damage, Vector3 force, float fall)
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		Player.localPlayer.refs.view.RPC("RPCA_TakeDamageAndAddForce", (RpcTarget)0, new object[3] { damage, force, fall });
	}
}