Decompiled source of TooManyCooks v1.0.1

TooManyCooks/TooManyCooks.dll

Decompiled 10 months ago
using System.Collections.Generic;
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 TooManyCooks.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("TooManyCooks")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TooManyCooks")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("851fe285-64e9-4265-8a0b-cc3b96ceb02c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace TooManyCooks
{
	[BepInPlugin("TooManyCooks.LethalCompany", "Too Many Cooks", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "TooManyCooks.LethalCompany";

		private const string modName = "Too Many Cooks";

		private const string modVersion = "1.0.1";

		private readonly Harmony harmony = new Harmony("TooManyCooks.LethalCompany");

		private static Plugin _instance;

		private static bool _debug = false;

		public static List<AudioClip> boomboxClips = new List<AudioClip>();

		internal static ManualLogSource mls;

		internal static AssetBundle bundle;

		private void BasicChecks()
		{
			if ((Object)(object)_instance == (Object)null)
			{
				_instance = this;
			}
		}

		private void InitializeLogger()
		{
			mls = Logger.CreateLogSource("TooManyCooks.LethalCompany");
			mls.LogInfo((object)"Starting Too Many Cooks");
		}

		private void ApplyPatches()
		{
			harmony.PatchAll(typeof(Plugin));
			if (_debug)
			{
				harmony.PatchAll(typeof(SprintMeterPatch));
				harmony.PatchAll(typeof(CreditPatch));
			}
			harmony.PatchAll(typeof(StartOfRoundPatch));
			harmony.PatchAll(typeof(BoomboxPatch));
		}

		private void LoadAssets()
		{
			string location = ((BaseUnityPlugin)_instance).Info.Location;
			location = location.TrimEnd("TooManyCooks.dll".ToCharArray());
			bundle = AssetBundle.LoadFromFile(location + "greatassets");
			mls.LogInfo((object)"Adding Audio Clips");
			boomboxClips.Add(bundle.LoadAsset<AudioClip>("radio1"));
			boomboxClips.Add(bundle.LoadAsset<AudioClip>("radio2"));
			boomboxClips.Add(bundle.LoadAsset<AudioClip>("radio3"));
		}

		private void Awake()
		{
			BasicChecks();
			InitializeLogger();
			ApplyPatches();
			LoadAssets();
		}
	}
}
namespace TooManyCooks.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class SprintMeterPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void sprintPatch(ref float ___sprintMeter)
		{
			___sprintMeter = 1f;
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal class CreditPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void creditPatch(ref int ___groupCredits)
		{
			___groupCredits = 1000000;
		}
	}
	[HarmonyPatch(typeof(BoomboxItem))]
	internal class BoomboxPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void boomboxPatch(BoomboxItem __instance)
		{
			__instance.musicAudios = Plugin.boomboxClips.ToArray();
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void startPatch(StartOfRound __instance)
		{
			AudioClip val = Plugin.bundle.LoadAsset<AudioClip>("introsong");
			if ((Object)(object)val != (Object)null)
			{
				__instance.shipIntroSpeechSFX = val;
			}
			else
			{
				Plugin.mls.LogError((object)"Failed to Load Asset");
			}
		}
	}
}