Decompiled source of Schloppin Company v1.0.0

BepInEx/plugins/SchloppinCompany.dll

Decompiled a month 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 GameNetcodeStuff;
using HarmonyLib;
using SchloppingCompany;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("SchloppinCompany")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SchloppinCompany")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f76d99aa-dc3a-413e-9146-2212771bc405")]
[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 SchloppinCompany
{
	[HarmonyPatch(typeof(PlayerControllerB), "Update")]
	public static class PlayerControllerB_Update_Patch
	{
		private static bool isEnabled;

		private static bool displayOnce;

		private static int state;

		public static bool Prefix(PlayerControllerB __instance)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			if (((ButtonControl)Keyboard.current[SchloppingCompanyMod.KeyBinding1]).isPressed && !isEnabled)
			{
				isEnabled = true;
				if (state > 0)
				{
					state--;
					SetAnimationState(state);
				}
			}
			if (((ButtonControl)Keyboard.current[SchloppingCompanyMod.KeyBinding2]).isPressed && !isEnabled)
			{
				isEnabled = true;
				if (state < 2)
				{
					state++;
					SetAnimationState(state);
				}
			}
			if (!((ButtonControl)Keyboard.current[SchloppingCompanyMod.KeyBinding2]).isPressed && !((ButtonControl)Keyboard.current[SchloppingCompanyMod.KeyBinding1]).isPressed && isEnabled)
			{
				isEnabled = false;
			}
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)localPlayerController != (Object)null && !localPlayerController.isPlayerDead && localPlayerController.isPlayerControlled && (Object)(object)HUDManager.Instance != (Object)null && !displayOnce)
			{
				displayOnce = true;
				HUDManager.Instance.DisplayTip("Schloppin Guide", "use Numpad+/- to increase/decrease schloppin speed", true, true, "LC_Schloppin");
			}
			return true;
		}

		private static void SetAnimationState(int state)
		{
			GameNetworkManager instance = GameNetworkManager.Instance;
			if ((Object)(object)instance != (Object)null && (Object)(object)instance.localPlayerController != (Object)null)
			{
				instance.localPlayerController.playerBodyAnimator.SetInteger("RockBaby", state);
			}
		}
	}
}
namespace SchloppingCompany
{
	[BepInPlugin("com.RonkestDonk.SchloppinCompany", "Schloppin Company", "1.0.0")]
	public class SchloppingCompanyMod : BaseUnityPlugin
	{
		private ConfigEntry<string> keyBinding1Config;

		private ConfigEntry<string> keyBinding2Config;

		public static Key KeyBinding1 { get; private set; }

		public static Key KeyBinding2 { get; private set; }

		private void Awake()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Schloppin Company Mod Loaded!");
			SetupKeybindings();
			new Harmony("com.RonkestDonk.SchloppinCompany").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Harmony Patches Applied");
		}

		private void SetupKeybindings()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			keyBinding1Config = ((BaseUnityPlugin)this).Config.Bind<string>("General", "KeyBinding1", "NumpadMinus", "First key used to trigger mod functionality (use UnityEngine.InputSystem.Key names)");
			keyBinding2Config = ((BaseUnityPlugin)this).Config.Bind<string>("General", "KeyBinding2", "NumpadPlus", "Second key used to trigger additional mod functionality (use UnityEngine.InputSystem.Key names)");
			if (Enum.TryParse<Key>(keyBinding1Config.Value, ignoreCase: true, out Key result))
			{
				KeyBinding1 = result;
			}
			else
			{
				KeyBinding1 = (Key)81;
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Invalid key binding for KeyBinding1: '" + keyBinding1Config.Value + "', defaulting to NumpadMinus."));
			}
			if (Enum.TryParse<Key>(keyBinding2Config.Value, ignoreCase: true, out Key result2))
			{
				KeyBinding2 = result2;
				return;
			}
			KeyBinding2 = (Key)80;
			((BaseUnityPlugin)this).Logger.LogWarning((object)("Invalid key binding for KeyBinding2: '" + keyBinding2Config.Value + "', defaulting to NumpadMinus."));
		}
	}
}