Decompiled source of RandomVoices v1.6.1

RandomVoicesMod.dll

Decompiled 6 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LCSoundTool;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("RandomVoicesMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RandomVoicesMod")]
[assembly: AssemblyTitle("RandomVoicesMod")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace LethalCompanyRandomDays
{
	[BepInPlugin("Draconias.RandomVoices", "Random Voices Mod", "1.6.1")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "Draconias.RandomVoices";

		private const string modNAME = "Random Voices Mod";

		private const string modVersion = "1.6.1";

		public static ManualLogSource staticLogSource;

		private static Plugin Instance;

		private readonly Harmony _harmony = new Harmony("Draconias.RandomVoices");

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			staticLogSource = ((BaseUnityPlugin)this).Logger;
			_harmony.PatchAll(typeof(Plugin));
			_harmony.PatchAll(typeof(VoicePatcher.HoardBugSoundPatch));
			_harmony.PatchAll(typeof(VoicePatcher.LandminePatch));
			_harmony.PatchAll(typeof(VoicePatcher.Jester));
			_harmony.PatchAll(typeof(VoicePatcher.Flowerman));
			_harmony.PatchAll(typeof(VoicePatcher.ShipIntroPatches));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Draconias.RandomVoices is loaded!");
		}
	}
	public class VoicePatcher
	{
		[HarmonyPatch(typeof(Landmine))]
		internal static class LandminePatch
		{
			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			private static void FixMine(Landmine __instance)
			{
				AudioClip val = LoadSound("LandMine.wav");
				if ((Object)(object)val != (Object)null)
				{
					__instance.mineAudio.clip = val;
					__instance.mineDetonate = val;
					AudioClip val2 = LoadSound("TriggerMine.wav");
					if ((Object)(object)val2 != (Object)null)
					{
						__instance.mineTrigger = val;
						__instance.mineDeactivate = val2;
					}
					__instance.mineDetonateFar = val;
					__instance.mineFarAudio.clip = val;
				}
				else
				{
					Plugin.staticLogSource.LogInfo((object)"|  RandomVoices| THE FILE FOR THE LANDMINE DOESN'T EXIST");
				}
			}
		}

		[HarmonyPatch(typeof(HoarderBugAI))]
		internal static class HoardBugSoundPatch
		{
			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			private static void NFixSound(HoarderBugAI __instance)
			{
				AudioClip val = LoadSound("HoardBug.wav");
				if ((Object)(object)val != (Object)null)
				{
					SoundTool.ReplaceAudioClip("creatureVoice", val);
					__instance.chitterSFX = (AudioClip[])(object)new AudioClip[1] { val };
				}
				else
				{
					Plugin.staticLogSource.LogInfo((object)"|  RandomVoices| DIE DATEI FUER DIE HOARD BUG EXISTIERT NICHT");
				}
			}
		}

		[HarmonyPatch(typeof(JesterAI))]
		internal static class Jester
		{
			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			private static void FixJesterSound(JesterAI __instance)
			{
				AudioClip val = LoadSound("JesterRadio.wav");
				AudioClip audioClip = SoundTool.GetAudioClip("Dragonias-RandomVoices", "JesterPop.wav");
				if ((Object)(object)val != (Object)null && (Object)(object)audioClip != (Object)null)
				{
					SoundTool.ReplaceAudioClip("creatureVoice", val);
					__instance.popGoesTheWeaselTheme = val;
					__instance.popUpSFX = audioClip;
				}
				else
				{
					Plugin.staticLogSource.LogInfo((object)" |  RandomVoices| DIE DATEI FUER JESTER EXESTIERT NICHT");
				}
			}
		}

		[HarmonyPatch(typeof(FlowermanAI))]
		internal static class Flowerman
		{
			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			private static void FixFlowerman(FlowermanAI __instance)
			{
				AudioClip val = LoadSound("Flowerman.wav");
				if ((Object)(object)val != (Object)null)
				{
					SoundTool.ReplaceAudioClip("creatureVoice", val);
					__instance.crackNeckSFX = val;
				}
				else
				{
					Plugin.staticLogSource.LogInfo((object)"|  RandomVoices| DIE DATEI FUER FLOWERMAN EXESTIERT NICHT");
				}
			}
		}

		[HarmonyPatch(typeof(StartOfRound))]
		internal static class ShipIntroPatches
		{
			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			public static void ShipIntroSFXPatch(StartOfRound __instance)
			{
				__instance.shipIntroSpeechSFX = LoadSound("BreakingBadIntro.wav");
			}
		}

		public static AudioClip LoadSound(string ressource)
		{
			return SoundTool.GetAudioClip("Dragonias-RandomVoices", ressource);
		}
	}
}