Decompiled source of FunMod1 v1.0.2

FunMod1.dll

Decompiled 9 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using FunMod1.Patches;
using GameNetcodeStuff;
using HarmonyLib;
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("FunMod1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FunMod1")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4c9e7479-86ac-4948-93e4-a0b7b8822d7c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace FunMod1
{
	[BepInPlugin("Juggernaut.FunMod1", "Fun Mod 1", "1.0.1.0")]
	public class ModBase : BaseUnityPlugin
	{
		private const string modGUID = "Juggernaut.FunMod1";

		private const string modName = "Fun Mod 1";

		private const string modVersion = "1.0.1.0";

		private readonly Harmony harmony = new Harmony("Juggernaut.FunMod1");

		private static ModBase Instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Juggernaut.FunMod1");
			mls.LogInfo((object)"TestMod Test1 Awakened");
			harmony.PatchAll(typeof(ModBase));
			harmony.PatchAll(typeof(PlayerControlerBPatch));
		}
	}
}
namespace FunMod1.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControlerBPatch
	{
		private static int jumpCount;

		[HarmonyPatch("Jump_performed")]
		[HarmonyPrefix]
		public static bool Jump_performed_Prefix(PlayerControllerB __instance)
		{
			if ((GameNetworkManager.Instance?.localPlayerController?.isTypingChat).GetValueOrDefault())
			{
				Debug.Log((object)"Player is typing in the chat. Cannot jump.");
				return false;
			}
			if (!__instance.thisController.isGrounded || true)
			{
				PerformCustomJump(__instance);
				jumpCount++;
				return false;
			}
			return true;
		}

		private static void PerformCustomJump(PlayerControllerB instance)
		{
			Traverse.Create((object)instance).Field("playerSlidingTimer").SetValue((object)0f);
			Traverse.Create((object)instance).Field("isJumping").SetValue((object)true);
			((MonoBehaviour)instance).StartCoroutine("PlayerJump");
		}

		[HarmonyPatch(typeof(PlayerControllerB), "ResetFallGravity")]
		[HarmonyPrefix]
		public static void ResetFallGravity_Prefix(PlayerControllerB instance)
		{
			jumpCount = 0;
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void InfiniteSprintPatch(ref PlayerControllerB __instance)
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				__instance.sprintMeter = Mathf.Clamp(__instance.sprintMeter + 0.08f, 0f, 1f);
			}
		}
	}
}