Decompiled source of KikinsChanges v1.0.0

BepInEx/plugins/KikinsChanges.dll

Decompiled 2 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 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("KikinsChanges")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("KikinsChanges")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e6de81d2-5857-4444-9786-083bdf3a7819")]
[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")]
[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)
	{
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		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)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Expected O, but got Unknown
		if (!((Object)__instance == (Object)null))
		{
			__instance.sprintMeter = Mathf.Clamp(__instance.sprintMeter + 0.08f, 0f, 1f);
		}
	}
}
namespace KikinsChanges;

[BepInPlugin("IamKikin.KikinsChanges", "Kikins Changes", "1.0.0")]
public class ChangesModBase : BaseUnityPlugin
{
	private const string modGUID = "IamKikin.KikinsChanges";

	private const string modName = "Kikins Changes";

	private const string modVersion = "1.0.0";

	private readonly Harmony harmony = new Harmony("IamKikin.KikinsChanges");

	private static ChangesModBase Instance;

	internal ManualLogSource mls;

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		mls = Logger.CreateLogSource("IamKikin.KikinsChanges");
		mls.LogInfo((object)"Kikin's Changes Loaded! Patching...");
		harmony.PatchAll(typeof(ChangesModBase));
		harmony.PatchAll(typeof(PlayerControlerBPatch));
	}
}