Decompiled source of LCTripleJumpMod v1.0.0

LCTripleJumpMod.dll

Decompiled a day 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 BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LCTripleJumpMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LCTripleJumpMod")]
[assembly: AssemblyTitle("LCTripleJumpMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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;
		}
	}
}
namespace LCTripleJumpMod
{
	[BepInPlugin("local.SimonTendo.LCTripleJumpMod", "LCTripleJumpMod", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public class Config
		{
			public static ConfigEntry<float> doubleJumpMultiplier;

			public static ConfigEntry<float> tripleJumpMultiplier;

			public static ConfigEntry<bool> sprintForTripleJump;

			public static ConfigEntry<float> timeBetweenJumps;

			public Config(ConfigFile cfg)
			{
				doubleJumpMultiplier = cfg.Bind<float>("Customization", "Double Jump Multiplier", 1.5f, "Set by how much the second jump multiplies the height of the first jump.");
				tripleJumpMultiplier = cfg.Bind<float>("Customization", "Triple Jump Multiplier", 2f, "Set by how much the third jump multiplies the height of the first jump.");
				sprintForTripleJump = cfg.Bind<bool>("Customization", "Sprint For Triple Jump", true, "Set whether or not you need to be sprinting in order to get the third jump.");
				timeBetweenJumps = cfg.Bind<float>("Customization", "Time Between Jumps", 0.33f, "Set how much time in seconds you have between jumps in order to get higher jumps.");
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB))]
		public class NewPlayerControllerB
		{
			[HarmonyPostfix]
			[HarmonyPatch("ConnectClientToPlayerObject")]
			public static void ConnectClientToPlayerObjectPostfix(PlayerControllerB __instance)
			{
				if (!((Object)(object)__instance == (Object)null))
				{
					defaultJumpForce = __instance.jumpForce;
					Logger.LogInfo((object)$"Player {__instance.playerUsername} started playing with defaultJumpForce {defaultJumpForce}!");
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("PlayerHitGroundEffects")]
			public static void PlayerHitGroundEffectsPostfix(PlayerControllerB __instance)
			{
				if (!((Object)(object)__instance == (Object)null))
				{
					Logger.LogDebug((object)(__instance.playerUsername + " hit ground"));
					lastTimeHittingGround = Time.realtimeSinceStartup;
				}
			}

			[HarmonyPrefix]
			[HarmonyPatch("PlayJumpAudio")]
			public static void PlayJumpAudioPrefix(PlayerControllerB __instance)
			{
				if ((Object)(object)__instance == (Object)null || (Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController)
				{
					return;
				}
				Logger.LogDebug((object)(__instance.playerUsername + " jumped"));
				float num = Time.realtimeSinceStartup - lastTimeHittingGround;
				Logger.LogDebug((object)$"timeSinceLastJump: {num}");
				if (num < Config.timeBetweenJumps.Value)
				{
					if (consecutiveJumps == 0)
					{
						consecutiveJumps = 1;
					}
					else if (consecutiveJumps == 1 && (!Config.sprintForTripleJump.Value || __instance.isSprinting))
					{
						consecutiveJumps = 2;
					}
					else
					{
						consecutiveJumps = 0;
					}
				}
				else
				{
					consecutiveJumps = 0;
				}
				Logger.LogDebug((object)$"consecutiveJumps: {consecutiveJumps}");
				switch (consecutiveJumps)
				{
				case 0:
					__instance.jumpForce = defaultJumpForce;
					break;
				case 1:
					__instance.jumpForce = defaultJumpForce * Config.doubleJumpMultiplier.Value;
					break;
				case 2:
					__instance.jumpForce = defaultJumpForce * Config.tripleJumpMultiplier.Value;
					break;
				}
				Logger.LogDebug((object)$"jumpForce: {__instance.jumpForce}");
			}
		}

		internal static ManualLogSource Logger;

		public static float lastTimeHittingGround;

		public static int consecutiveJumps;

		public static float defaultJumpForce;

		public static Config myConfig { get; internal set; }

		private void Awake()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin LCTripleJumpMod is loaded!");
			new Harmony("LCTripleJumpMod").PatchAll();
			myConfig = new Config(((BaseUnityPlugin)this).Config);
			DisplayConfigs();
		}

		private static void DisplayConfigs()
		{
			Logger.LogInfo((object)$"Config [Double Jump Multiplier] is set to a value of {Config.doubleJumpMultiplier.Value}");
			Logger.LogInfo((object)$"Config [Triple Jump Multiplier] is set to a value of {Config.tripleJumpMultiplier.Value}");
			string text = (Config.sprintForTripleJump.Value ? "TRUE" : "FALSE");
			Logger.LogInfo((object)("Config [Sprint For Triple Jump] is set to " + text));
			Logger.LogInfo((object)$"Config [Time Between Jumps] is set to a value of {Config.timeBetweenJumps.Value}");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LCTripleJumpMod";

		public const string PLUGIN_NAME = "LCTripleJumpMod";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}