Decompiled source of Lethal Enhanced v1.2.3

Lethal Enhanced.dll

Decompiled 8 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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 Lethal_Enhance;
using Lethal_Enhanced;
using Lethal_Enhanced.Patches;
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("Lethal Enhanced")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Lethal Enhanced")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6b777bb9-ad73-4418-b39b-e5188fd56d44")]
[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 Lethal_Enhance
{
	[BepInPlugin("Poseidon.Lethal_Enhance", "Lethal Enhanced", "1.2.3")]
	public class TutorialModBase : BaseUnityPlugin
	{
		private const string modGUID = "Poseidon.Lethal_Enhance";

		private const string modName = "Lethal Enhanced";

		private const string modVersion = "1.2.3";

		private readonly Harmony harmony = new Harmony("Poseidon.Lethal_Enhance");

		internal static TutorialModBase Instance;

		internal static ManualLogSource mls;

		internal ModMenu Menu;

		internal static List<AudioClip> SoundFX;

		internal static AssetBundle Bundle;

		private void Awake()
		{
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Poseidon.Lethal_Enhance");
			harmony.PatchAll(typeof(TutorialModBase));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
			harmony.PatchAll(typeof(JesterAudioPatch));
			harmony.PatchAll(typeof(BrackenAudioPatch));
			harmony.PatchAll(typeof(StartOfRoundPatch));
			harmony.PatchAll(typeof(PlayerAudioPatch));
			harmony.PatchAll(typeof(QuickMenuManagerPatch));
			mls = ((BaseUnityPlugin)this).Logger;
			SoundFX = new List<AudioClip>();
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("Lethal Enhanced.dll".ToCharArray());
			Bundle = AssetBundle.LoadFromFile(location + "audio");
			if ((Object)(object)Bundle != (Object)null)
			{
				mls.LogInfo((object)"All Sound Effects Have Been Loaded.");
				SoundFX = Bundle.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogError((object)"Oh noes the sound no work.");
			}
			GameObject val = new GameObject("ModMenu");
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)61;
			val.AddComponent<ModMenu>();
			Menu = (ModMenu)(object)val.GetComponent("ModMenu");
		}
	}
}
namespace Lethal_Enhanced
{
	internal class ModMenu : MonoBehaviour
	{
		internal static ModMenu Instance;

		internal bool Vidsible = false;

		private const int MENUWIDTH = 600;

		private const int MENUHEIGHT = 800;

		private int MENUX;

		private int MENUY;

		private int ITEMWIDTH = 300;

		private int CENTERX;

		internal bool toggleTxt = true;

		internal bool toggleTxtt = true;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			MENUX = 0;
			MENUY = 0;
			CENTERX = MENUX + (300 - ITEMWIDTH / 2);
		}

		private void Update()
		{
		}

		private void OnGUI()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			if (Vidsible)
			{
				GUI.Box(new Rect((float)MENUX, (float)MENUY, 600f, 800f), "Enhanced Console:");
				toggleTxt = GUI.Toggle(new Rect((float)MENUX, (float)(MENUY + 30), 600f, 40f), toggleTxt, ":Infinite Sprint");
				toggleTxtt = GUI.Toggle(new Rect((float)MENUX, (float)(MENUY + 60), 600f, 40f), toggleTxtt, ":Bee Hops");
			}
		}

		private Texture2D MakeTex(int width, int height, Color color)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			Color[] array = (Color[])(object)new Color[width * height];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = color;
			}
			Texture2D val = new Texture2D(width, height);
			val.SetPixels(array);
			val.Apply();
			return val;
		}
	}
}
namespace Lethal_Enhanced.Patches
{
	[HarmonyPatch(typeof(StartOfRound))]
	internal class PlayerAudioPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void patchUpdate(StartOfRound __instance)
		{
			for (int i = 0; i < __instance.footstepSurfaces.Length; i++)
			{
				int num = 0;
				for (int j = 0; j < __instance.footstepSurfaces[i].clips.Length; j++)
				{
					__instance.footstepSurfaces[i].clips[j] = TutorialModBase.SoundFX[3 + num];
					TutorialModBase.mls.LogInfo((object)"Sounds Replaced.");
					num++;
					if (num > 1)
					{
						num = 0;
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(QuickMenuManager))]
	internal class QuickMenuManagerPatch
	{
		[HarmonyPatch("OpenQuickMenu")]
		[HarmonyPrefix]
		public static void OpenMenu()
		{
			TutorialModBase.Instance.Menu.Vidsible = true;
		}

		[HarmonyPatch("CloseQuickMenu")]
		[HarmonyPrefix]
		public static void CloseMenu()
		{
			TutorialModBase.Instance.Menu.Vidsible = false;
		}

		[HarmonyPatch("LeaveGameConfirm")]
		[HarmonyPrefix]
		public static void CloseMenuOnLeaveGame()
		{
			TutorialModBase.Instance.Menu.Vidsible = false;
		}
	}
	[HarmonyPatch(typeof(FlowermanAI))]
	internal class BrackenAudioPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void OverrideAudio(FlowermanAI __instance)
		{
			__instance.creatureAngerVoice.clip = TutorialModBase.SoundFX[1];
			__instance.creatureAngerVoice.pitch = 1f;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverrideAudio(StartOfRound __instance)
		{
			__instance.shipIntroSpeechSFX = TutorialModBase.SoundFX[2];
		}
	}
	[HarmonyPatch(typeof(JesterAI))]
	internal class JesterAudioPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverrideAudio(JesterAI __instance)
		{
			__instance.popUpSFX = TutorialModBase.SoundFX[0];
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void patchUpdate(ref bool ___isFallingFromJump, ref float ___sprintMeter, ref bool ___isFallingNoJump, ref float ___playerSlidingTimer, ref float ___slideFriction, ref bool ___isJumping, ref bool ___isSprinting, ref float ___movementSpeed)
		{
			if (ModMenu.Instance.toggleTxt)
			{
				___sprintMeter = 1f;
			}
			if (!ModMenu.Instance.toggleTxtt)
			{
				return;
			}
			___playerSlidingTimer = 0f;
			___slideFriction = 0f;
			if (___isFallingFromJump | ___isJumping)
			{
				if (___isSprinting)
				{
					___movementSpeed = 10f;
				}
				else
				{
					___movementSpeed = 4f;
				}
			}
			else
			{
				___movementSpeed = 4f;
			}
		}
	}
}