Decompiled source of LeviLootbugJensen v1.1.1

LeviLootbugJensen.dll

Decompiled 10 months ago
using System;
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 HarmonyLib;
using LeviLootbugJensen.Patches;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LeviLootbugJensen")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Erstatter lydfilene til Lootbug og slikt at den roper som Levi Jensen, Hallelujah!")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LeviLootbugJensen")]
[assembly: AssemblyTitle("LeviLootbugJensen")]
[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 LeviLootbugJensen
{
	[BepInPlugin("nordbo.LeviLootbugJensen", "Levi Lootbug Jensen", "1.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "nordbo.LeviLootbugJensen";

		private const string modName = "Levi Lootbug Jensen";

		private const string modVersion = "1.1.0";

		private readonly Harmony harmony = new Harmony("nordbo.LeviLootbugJensen");

		internal ManualLogSource mls;

		public static Plugin Instance;

		internal static AudioClip[] voiceLines;

		internal static AudioClip[] angryVoiceLines;

		internal static AudioClip chaseVoiceLine;

		internal static AssetBundle assetBundle;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("nordbo.LeviLootbugJensen");
			mls.LogInfo((object)"Plugin nordbo.LeviLootbugJensen is loaded! HALLELUJAH!");
			LoadVoiceLines();
			harmony.PatchAll(typeof(Plugin));
			harmony.PatchAll(typeof(LeviLootbugJensenPatch));
		}

		private void LoadVoiceLines()
		{
			assetBundle = LoadAssetBundle("voice_bundle");
			if ((Object)(object)assetBundle != (Object)null)
			{
				voiceLines = (AudioClip[])(object)new AudioClip[10];
				angryVoiceLines = (AudioClip[])(object)new AudioClip[1];
				chaseVoiceLine = assetBundle.LoadAsset<AudioClip>("chase1");
				if ((Object)(object)chaseVoiceLine == (Object)null)
				{
					mls.LogError((object)"Failed to load audio clip: chase1");
				}
				else
				{
					mls.LogInfo((object)"Loaded audio clip: chase1");
				}
				for (int i = 0; i < voiceLines.Length; i++)
				{
					string text = $"voice{i + 1}";
					voiceLines[i] = assetBundle.LoadAsset<AudioClip>(text);
					if ((Object)(object)voiceLines[i] == (Object)null)
					{
						mls.LogError((object)("Failed to load audio clip: " + text));
					}
					else
					{
						mls.LogInfo((object)("Loaded audio clip: " + text));
					}
				}
				for (int j = 0; j < angryVoiceLines.Length; j++)
				{
					string text2 = $"angry{j + 1}";
					angryVoiceLines[j] = assetBundle.LoadAsset<AudioClip>(text2);
					if ((Object)(object)angryVoiceLines[j] == (Object)null)
					{
						mls.LogError((object)("Failed to load audio clip: " + text2));
					}
					else
					{
						mls.LogInfo((object)("Loaded audio clip: " + text2));
					}
				}
			}
			else
			{
				mls.LogError((object)"Failed to load voice bundle!");
			}
		}

		internal static AudioClip GetRandomVoiceLine()
		{
			return voiceLines[Random.Range(0, voiceLines.Length)];
		}

		internal static AudioClip GetRandomAngryVoiceLine()
		{
			return angryVoiceLines[Random.Range(0, angryVoiceLines.Length)];
		}

		private AssetBundle LoadAssetBundle(string bundleName)
		{
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("LeviLootbugJensen.dll".ToCharArray());
			string text = location + "/" + bundleName;
			AssetBundle val = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)("Failed to load AssetBundle: " + text));
			}
			else
			{
				mls.LogInfo((object)("Loaded AssetBundle: " + text));
			}
			return val;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LeviLootbugJensen";

		public const string PLUGIN_NAME = "LeviLootbugJensen";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace LeviLootbugJensen.Patches
{
	[HarmonyPatch(typeof(HoarderBugAI))]
	internal class LeviLootbugJensenPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void HoarderBugAudioPatch(ref AudioClip[] ___chitterSFX, ref AudioClip[] ___angryScreechSFX, ref AudioClip ___angryVoiceSFX)
		{
			___chitterSFX = Plugin.voiceLines;
			___angryScreechSFX = Plugin.angryVoiceLines;
			___angryVoiceSFX = Plugin.chaseVoiceLine;
		}
	}
}