Decompiled source of LuckyTheresAFamilyGuy v1.4.0

LuckyTheresAFamilyGuy.dll

Decompiled 10 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LuckyTheresAFamilyGuy.Patches;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LuckyTheresAFamilyGuy")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LuckyTheresAFamilyGuy")]
[assembly: AssemblyTitle("LuckyTheresAFamilyGuy")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LuckyTheresAFamilyGuy.Patches
{
	[HarmonyPatch(typeof(BaboonBirdAI))]
	internal class BaboonHawkPatch
	{
		public static AudioClip baboon;

		private static string path = "https://github.com/dant40/lethalsounds/raw/main/baboon.wav";

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void adjustStartup(ref AudioClip[] ___cawScreamSFX, ref AudioClip[] ___cawLaughSFX)
		{
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20);
			audioClip.timeout = 500;
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			baboon = DownloadHandlerAudioClip.GetContent(audioClip);
			___cawScreamSFX = (AudioClip[])(object)new AudioClip[1] { baboon };
			___cawLaughSFX = (AudioClip[])(object)new AudioClip[1] { baboon };
		}
	}
	[HarmonyPatch(typeof(RedLocustBees))]
	internal class BeesAudioPatch
	{
		public static AudioClip hateBees;

		private static string path = "https://github.com/dant40/lethalsounds/raw/main/bees.wav";

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void adjustStartup()
		{
			Debug.Log((object)path);
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20);
			audioClip.timeout = 500;
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			hateBees = DownloadHandlerAudioClip.GetContent(audioClip);
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void adjustBeeSound2(ref AudioSource ___beesAngry, ref AudioSource ___beesDefensive)
		{
			___beesAngry.clip = hateBees;
			___beesDefensive.clip = hateBees;
		}
	}
	[HarmonyPatch(typeof(FlowermanAI))]
	internal class BrackenSoundPatch
	{
		public static AudioClip peterLaugh;

		private static string path = "https://github.com/dant40/lethalsounds/raw/main/plaugh1.wav";

		private static int framesPassed = 0;

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void adjustStartup()
		{
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20);
			audioClip.timeout = 500;
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			peterLaugh = DownloadHandlerAudioClip.GetContent(audioClip);
		}

		[HarmonyPatch("DoAIInterval")]
		[HarmonyPostfix]
		public static void aiSoundPatch(ref AudioSource ___crackNeckAudio)
		{
			framesPassed++;
			if (framesPassed < 150)
			{
				framesPassed = 0;
				___crackNeckAudio.PlayOneShot(peterLaugh);
			}
		}
	}
	[HarmonyPatch(typeof(SpringManAI))]
	internal class Coilhead
	{
		public static AudioClip spring;

		private static string path = "https://github.com/dant40/lethalsounds/raw/main/spring.wav";

		private static bool hasRun = false;

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		public static void adjustStartup(ref AudioClip[] ___springNoises)
		{
			if (!hasRun)
			{
				UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20);
				audioClip.timeout = 500;
				audioClip.SendWebRequest();
				while (!audioClip.isDone)
				{
				}
				spring = DownloadHandlerAudioClip.GetContent(audioClip);
				___springNoises = (AudioClip[])(object)new AudioClip[1] { spring };
				hasRun = true;
			}
		}
	}
	[HarmonyPatch(typeof(MouthDogAI))]
	internal class EyelessDogPatch
	{
		public static AudioClip eyeless;

		private static string path = "https://github.com/dant40/lethalsounds/raw/main/eyeless.wav";

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void adjustStartup(ref AudioSource ___killPlayerSFX)
		{
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20);
			audioClip.timeout = 500;
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			eyeless = DownloadHandlerAudioClip.GetContent(audioClip);
			___killPlayerSFX.clip = eyeless;
		}
	}
	[HarmonyPatch(typeof(ForestGiantAI))]
	internal class ForestGiantPatch
	{
		public static AudioClip giant;

		private static string path = "https://github.com/dant40/lethalsounds/raw/main/giant.wav";

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void adjustStartup()
		{
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20);
			audioClip.timeout = 500;
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			giant = DownloadHandlerAudioClip.GetContent(audioClip);
		}

		[HarmonyPatch("GiantSeePlayerEffect")]
		[HarmonyPostfix]
		public static void patchSound(ref AudioSource ___farWideSFX)
		{
			___farWideSFX.PlayOneShot(giant);
		}
	}
	[HarmonyPatch(typeof(HoarderBugAI))]
	internal class HoarderBugAudioPatch
	{
		public static AudioClip clip1;

		public static AudioClip clip2;

		private static string path1 = "https://github.com/dant40/lethalsounds/raw/main/smoke1.wav";

		private static string path2 = "https://github.com/dant40/lethalsounds/raw/main/smoke2.wav";

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void adjustStartup(ref AudioClip[] ___chitterSFX, ref AudioClip ___angryVoiceSFX)
		{
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path1, (AudioType)20);
			audioClip.timeout = 500;
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			clip1 = DownloadHandlerAudioClip.GetContent(audioClip);
			___chitterSFX = (AudioClip[])(object)new AudioClip[1] { clip1 };
			UnityWebRequest audioClip2 = UnityWebRequestMultimedia.GetAudioClip(path2, (AudioType)20);
			audioClip2.timeout = 500;
			audioClip2.SendWebRequest();
			while (!audioClip2.isDone)
			{
			}
			clip2 = DownloadHandlerAudioClip.GetContent(audioClip2);
			___angryVoiceSFX = clip2;
		}
	}
	[HarmonyPatch(typeof(JesterAI))]
	internal class JesterAudioPatch
	{
		public static AudioClip clip1;

		public static AudioClip clip2;

		private static string path1 = "https://github.com/dant40/lethalsounds/raw/main/bird_start.wav";

		private static string path2 = "https://github.com/dant40/lethalsounds/raw/main/bird1.wav";

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void adjustStartup(ref AudioClip ___popGoesTheWeaselTheme, ref AudioClip ___popUpSFX)
		{
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path1, (AudioType)20);
			audioClip.timeout = 500;
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			clip1 = DownloadHandlerAudioClip.GetContent(audioClip);
			___popGoesTheWeaselTheme = clip1;
			UnityWebRequest audioClip2 = UnityWebRequestMultimedia.GetAudioClip(path2, (AudioType)20);
			audioClip2.timeout = 500;
			audioClip2.SendWebRequest();
			while (!audioClip2.isDone)
			{
			}
			clip2 = DownloadHandlerAudioClip.GetContent(audioClip2);
			___popUpSFX = clip2;
		}
	}
	[HarmonyPatch(typeof(NutcrackerEnemyAI))]
	internal class NutcrackerPatch
	{
		public static AudioClip nut1;

		public static AudioClip nut2;

		private static string path1 = "https://github.com/dant40/lethalsounds/raw/main/nut1.wav";

		private static string path2 = "https://github.com/dant40/lethalsounds/raw/main/nut2.wav";

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void adjustStartup(ref AudioSource ___aimSFX, ref AudioSource ___kickSFX)
		{
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path1, (AudioType)20);
			audioClip.timeout = 500;
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			nut1 = DownloadHandlerAudioClip.GetContent(audioClip);
			___aimSFX.clip = nut1;
			audioClip = UnityWebRequestMultimedia.GetAudioClip(path2, (AudioType)20);
			audioClip.timeout = 500;
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			nut2 = DownloadHandlerAudioClip.GetContent(audioClip);
			___kickSFX.clip = nut2;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class ShipAudioPatch
	{
		public static AudioClip clip1;

		private static string path = "https://github.com/dant40/lethalsounds/raw/main/house.wav";

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void adjustStartup()
		{
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20);
			audioClip.timeout = 500;
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			clip1 = DownloadHandlerAudioClip.GetContent(audioClip);
		}

		private static IEnumerator waitHelper(float time)
		{
			yield return (object)new WaitForSeconds(time);
		}

		[HarmonyPatch("OpenShipDoors")]
		[HarmonyPostfix]
		public static void playSound(ref AudioSource ___shipArriveSFX)
		{
			waitHelper(5f);
			___shipArriveSFX.PlayOneShot(clip1);
		}
	}
	[HarmonyPatch(typeof(BlobAI))]
	internal class SlimePatch
	{
	}
	[HarmonyPatch(typeof(CentipedeAI))]
	internal class SnareFleaPatch
	{
		public static AudioClip flea;

		private static string path = "https://github.com/dant40/lethalsounds/raw/main/flea.wav";

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void adjustStartup(ref AudioClip ___fallShriek)
		{
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20);
			audioClip.timeout = 500;
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			flea = DownloadHandlerAudioClip.GetContent(audioClip);
			___fallShriek = flea;
		}
	}
	[HarmonyPatch(typeof(SandSpiderAI))]
	internal class SpiderPatch
	{
		public static AudioClip spider1;

		public static AudioClip spider2;

		public static AudioClip spider3;

		private static string path = "https://github.com/dant40/lethalsounds/raw/main/spider1.wav";

		private static string path2 = "https://github.com/dant40/lethalsounds/raw/main/spider2.wav";

		private static string path3 = "https://github.com/dant40/lethalsounds/raw/main/spider3.wav";

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void adjustStartup(ref AudioClip[] ___footstepSFX, ref AudioClip ___attackSFX, ref AudioClip ___hangPlayerSFX)
		{
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20);
			audioClip.timeout = 500;
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			spider1 = DownloadHandlerAudioClip.GetContent(audioClip);
			___hangPlayerSFX = spider1;
			audioClip = UnityWebRequestMultimedia.GetAudioClip(path2, (AudioType)20);
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			spider2 = DownloadHandlerAudioClip.GetContent(audioClip);
			___attackSFX = spider2;
			audioClip = UnityWebRequestMultimedia.GetAudioClip(path3, (AudioType)20);
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			spider3 = DownloadHandlerAudioClip.GetContent(audioClip);
			___footstepSFX = (AudioClip[])(object)new AudioClip[1] { spider3 };
		}
	}
	[HarmonyPatch(typeof(PufferAI))]
	internal class SporeLizardPatch
	{
		public static AudioClip spore;

		private static string path = "https://github.com/dant40/lethalsounds/raw/main/spore.wav";

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void adjustStartup(ref AudioSource ___angry, ref AudioSource ___nervousMumbling, ref AudioSource ___puff)
		{
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20);
			audioClip.timeout = 500;
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			spore = DownloadHandlerAudioClip.GetContent(audioClip);
			___angry.clip = spore;
			___nervousMumbling.clip = spore;
			___puff.clip = spore;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class TestPatch
	{
		public static AudioClip clip1;

		private static string path = "https://github.com/dant40/lethalsounds/raw/main/candy.wav";

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void adjustStartup()
		{
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20);
			audioClip.timeout = 1000;
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			clip1 = DownloadHandlerAudioClip.GetContent(audioClip);
		}

		[HarmonyPatch("GrabObject")]
		[HarmonyPrefix]
		public static void GrabObject(ref AudioSource ___itemAudio)
		{
			if (Random.Range(0, 10) > 5)
			{
				___itemAudio.PlayOneShot(clip1);
			}
		}
	}
	[HarmonyPatch(typeof(TimeOfDay))]
	internal class TimeAudioPatch
	{
		public static AudioClip clip1;

		private static string path = "https://github.com/dant40/lethalsounds/raw/main/outoftime.wav";

		private static bool hasPlayed = false;

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void adjustStartup()
		{
			hasPlayed = false;
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20);
			audioClip.timeout = 500;
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			clip1 = DownloadHandlerAudioClip.GetContent(audioClip);
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void playSound(ref AudioSource ___TimeOfDayMusic, ref bool ___shipLeavingOnMidnight, ref bool ___shipLeavingAlertCalled)
		{
			if ((___shipLeavingAlertCalled | ___shipLeavingOnMidnight) && !hasPlayed)
			{
				hasPlayed = true;
				___TimeOfDayMusic.PlayOneShot(clip1);
			}
		}
	}
	[HarmonyPatch(typeof(SandWormAI))]
	internal class WormPatch
	{
		public static AudioClip worm;

		private static string path = "https://github.com/dant40/lethalsounds/raw/main/worm.wav";

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void adjustStartup(ref AudioClip ___emergeFromGroundSFX)
		{
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20);
			audioClip.timeout = 500;
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			worm = DownloadHandlerAudioClip.GetContent(audioClip);
			___emergeFromGroundSFX = worm;
		}
	}
}
namespace LethalCompanyTemplate
{
	[BepInPlugin("Lucky.FG", "Lucky There's a Family Guy", "1.3")]
	public class MainPlugin : BaseUnityPlugin
	{
		private const string plugGuid = "Lucky.FG";

		private const string plugName = "Lucky There's a Family Guy";

		private const string plugVersion = "1.3";

		private readonly Harmony harmony = new Harmony("Lucky.FG");

		private static readonly MainPlugin instance;

		public ManualLogSource mls;

		public static MainPlugin Instance => instance;

		static MainPlugin()
		{
			instance = new MainPlugin();
		}

		private MainPlugin()
		{
		}//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown


		private void Awake()
		{
			mls = Logger.CreateLogSource("Lucky.FG");
			mls.LogInfo((object)"Trying to load family guy sound mod pack...");
			try
			{
				harmony.PatchAll(typeof(MainPlugin));
				harmony.PatchAll(typeof(BrackenSoundPatch));
				harmony.PatchAll(typeof(BeesAudioPatch));
				harmony.PatchAll(typeof(TimeAudioPatch));
				harmony.PatchAll(typeof(JesterAudioPatch));
				harmony.PatchAll(typeof(HoarderBugAudioPatch));
				harmony.PatchAll(typeof(ForestGiantPatch));
				harmony.PatchAll(typeof(EyelessDogPatch));
				harmony.PatchAll(typeof(SporeLizardPatch));
				harmony.PatchAll(typeof(BaboonHawkPatch));
				harmony.PatchAll(typeof(SpiderPatch));
				harmony.PatchAll(typeof(NutcrackerPatch));
				harmony.PatchAll(typeof(WormPatch));
				harmony.PatchAll(typeof(SnareFleaPatch));
				harmony.PatchAll(typeof(Coilhead));
				harmony.PatchAll(typeof(TestPatch));
				mls.LogInfo((object)"Successfully loaded ");
			}
			catch (Exception ex)
			{
				mls.LogInfo((object)("Failed to load! " + ex.ToString()));
			}
		}
	}
}