Decompiled source of LethalTweekSpeaker v1.1.0

TweekLethalSpeaker/LethalTweekSpeaker.dll

Decompiled 10 months ago
using System;
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 HarmonyLib;
using LethalTweekSpeaker.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("LethalTweekSpeaker")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LethalTweekSpeaker")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9b62877a-ea4a-4a09-a53e-55a47d10975a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LethalTweekSpeaker
{
	[BepInPlugin("SipcoGamingGuild.LethalTweekSpeaker", "Lethal Tweek Speaker", "1.1.0")]
	public class LTS_Base : BaseUnityPlugin
	{
		private const string modGUID = "SipcoGamingGuild.LethalTweekSpeaker";

		private const string modName = "Lethal Tweek Speaker";

		private const string modVersion = "1.1.0";

		private readonly Harmony harmony = new Harmony("SipcoGamingGuild.LethalTweekSpeaker");

		private static LTS_Base Instance;

		internal static ManualLogSource mls;

		internal static List<AudioClip> PlaceHolderSFX;

		internal static AssetBundle PlaceHolderAudioBundle;

		internal static List<AudioClip> IntroSFX;

		internal static AssetBundle IntroAudioBundle;

		internal static List<AudioClip> ZeroDaysSFX;

		internal static AssetBundle ZeroDaysAudioBundle;

		internal static List<AudioClip> FiredSFX;

		internal static AssetBundle FiredAudioBundle;

		internal static List<AudioClip> AllDeadSFX;

		internal static AssetBundle AllDeadAudioBundle;

		internal static List<AudioClip> ThankDeskSFX;

		internal static AssetBundle ThankDeskAudioBundle;

		internal static List<AudioClip> ThankDeskRareSFX;

		internal static AssetBundle ThankDeskRareAudioBundle;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("SipcoGamingGuild.LethalTweekSpeaker");
			mls.LogInfo((object)"Lethal Tweek Speaker has awoken");
			harmony.PatchAll(typeof(StartOfRoundPatch));
			harmony.PatchAll(typeof(DepositItemsDeskPatch));
			mls = ((BaseUnityPlugin)this).Logger;
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("LethalTweekSpeaker.dll".ToCharArray());
			PlaceHolderSFX = new List<AudioClip>();
			PlaceHolderAudioBundle = AssetBundle.LoadFromFile(location + "placeholder");
			if ((Object)(object)PlaceHolderAudioBundle != (Object)null)
			{
				mls.LogInfo((object)"Loaded Placeholder SFX Successfully!");
				PlaceHolderSFX = PlaceHolderAudioBundle.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogError((object)"Failed to Load Placeholder SFX");
			}
			IntroSFX = new List<AudioClip>();
			IntroAudioBundle = AssetBundle.LoadFromFile(location + "tweekintro");
			if ((Object)(object)IntroAudioBundle != (Object)null)
			{
				mls.LogInfo((object)"Loaded Intro SFX Successfully!");
				IntroSFX = IntroAudioBundle.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogError((object)"Failed to Load Intro SFX");
			}
			ZeroDaysSFX = new List<AudioClip>();
			ZeroDaysAudioBundle = AssetBundle.LoadFromFile(location + "zerodays");
			if ((Object)(object)ZeroDaysAudioBundle != (Object)null)
			{
				mls.LogInfo((object)"Loaded Zero Days SFX Successfully!");
				ZeroDaysSFX = ZeroDaysAudioBundle.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogError((object)"Failed to Load Zero Days SFX");
			}
			FiredSFX = new List<AudioClip>();
			FiredAudioBundle = AssetBundle.LoadFromFile(location + "fired");
			if ((Object)(object)FiredAudioBundle != (Object)null)
			{
				mls.LogInfo((object)"Loaded Fired SFX Successfully!");
				FiredSFX = FiredAudioBundle.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogError((object)"Failed to Load Fired SFX");
			}
			AllDeadSFX = new List<AudioClip>();
			AllDeadAudioBundle = AssetBundle.LoadFromFile(location + "alldead");
			if ((Object)(object)AllDeadAudioBundle != (Object)null)
			{
				mls.LogInfo((object)"Loaded AllDead SFX Successfully!");
				AllDeadSFX = AllDeadAudioBundle.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogError((object)"Failed to Load AllDead SFX");
			}
			ThankDeskSFX = new List<AudioClip>();
			ThankDeskAudioBundle = AssetBundle.LoadFromFile(location + "thankdesk");
			if ((Object)(object)ThankDeskAudioBundle != (Object)null)
			{
				mls.LogInfo((object)"Loaded Thank Desk SFX Successfully!");
				ThankDeskSFX = ThankDeskAudioBundle.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogError((object)"Failed to Load Thank Desk SFX");
			}
			ThankDeskRareSFX = new List<AudioClip>();
			ThankDeskRareAudioBundle = AssetBundle.LoadFromFile(location + "thankdeskrare");
			if ((Object)(object)ThankDeskRareAudioBundle != (Object)null)
			{
				mls.LogInfo((object)"Loaded Thank For Items Rare SFX Successfully!");
				ThankDeskRareSFX = ThankDeskRareAudioBundle.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogError((object)"Failed to Load Thank For Items Rare SFX");
			}
		}
	}
}
namespace LethalTweekSpeaker.Patches
{
	[HarmonyPatch(typeof(DepositItemsDesk))]
	internal class DepositItemsDeskPatch
	{
		private static Random rnd = new Random();

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverideAudio(DepositItemsDesk __instance)
		{
			int num = rnd.Next(LTS_Base.ThankDeskSFX.Count);
			LTS_Base.mls.LogInfo((object)("The Count for Tweek Intro is " + LTS_Base.ThankDeskSFX.Count));
			LTS_Base.mls.LogInfo((object)("The Chosen Random For it is " + num));
			__instance.microphoneAudios = LTS_Base.ThankDeskSFX.ToArray();
			int num2 = rnd.Next(LTS_Base.ThankDeskRareSFX.Count);
			LTS_Base.mls.LogInfo((object)("The Count for Tweek Intro is " + LTS_Base.ThankDeskRareSFX.Count));
			LTS_Base.mls.LogInfo((object)("The Chosen Random For it is " + num2));
			__instance.rareMicrophoneAudios = LTS_Base.ThankDeskRareSFX.ToArray();
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		private static Random rnd = new Random();

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverideAudio(StartOfRound __instance)
		{
			int index = rnd.Next(LTS_Base.IntroSFX.Count);
			LTS_Base.mls.LogInfo((object)("The Count for Tweek Intro is " + LTS_Base.IntroSFX.Count));
			LTS_Base.mls.LogInfo((object)("The Chosen Random For it is " + index));
			__instance.shipIntroSpeechSFX = LTS_Base.IntroSFX[index];
			int index2 = rnd.Next(LTS_Base.ZeroDaysSFX.Count);
			LTS_Base.mls.LogInfo((object)("The Count for Tweek Zero Days Left Alert is " + LTS_Base.ZeroDaysSFX.Count));
			LTS_Base.mls.LogInfo((object)("The Chosen Random For it is " + index2));
			__instance.zeroDaysLeftAlertSFX = LTS_Base.ZeroDaysSFX[index2];
			int index3 = rnd.Next(LTS_Base.FiredSFX.Count);
			LTS_Base.mls.LogInfo((object)("The Count for Tweek Zero Days Left Alert is " + LTS_Base.FiredSFX.Count));
			LTS_Base.mls.LogInfo((object)("The Chosen Random For it is " + index3));
			__instance.firedVoiceSFX = LTS_Base.FiredSFX[index3];
			int index4 = rnd.Next(LTS_Base.AllDeadSFX.Count);
			LTS_Base.mls.LogInfo((object)("The Count for Tweek All Dead is " + LTS_Base.AllDeadSFX.Count));
			LTS_Base.mls.LogInfo((object)("The Chosen Random For it is " + index4));
			__instance.allPlayersDeadAudio = LTS_Base.AllDeadSFX[index4];
		}
	}
}