Decompiled source of SoundBoard v1.0.2

SoundBoard.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SoundBoard.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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("SoundBoard")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("SoundBoard")]
[assembly: AssemblyTitle("SoundBoard")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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 SoundBoard
{
	[BepInPlugin("SoundBoard", "SoundBoard", "1.0.1")]
	public class SoundBoard : BaseUnityPlugin
	{
		private const string modGUID = "samsam.SoundBoard";

		private const string modName = "SoundBoard";

		private const string modVersion = "1.0.2";

		private readonly Harmony harmony = new Harmony("samsam.SoundBoard");

		private static SoundBoard Instance;

		public static List<AudioClip[]> allSounds = new List<AudioClip[]>();

		public static int nbSound = 3;

		public static AudioClip[] sound;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin SoundBoard is loaded!");
			allSounds = LoadAllSound(nbSound);
			if (allSounds == null || allSounds.Count == 0)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load audio assets !");
			}
			else
			{
				for (int i = 0; i < allSounds.Count; i++)
				{
					if (allSounds[i] == null)
					{
						((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load audio assets number " + i + " !"));
					}
					else
					{
						((BaseUnityPlugin)this).Logger.LogInfo((object)("Audio asset " + i + " is loaded !"));
					}
				}
			}
			harmony.PatchAll(typeof(CrawlerPatch));
			harmony.PatchAll(typeof(ShotGunPatch));
		}

		public static List<AudioClip[]> LoadAllSound(int nb)
		{
			List<AudioClip[]> list = new List<AudioClip[]>();
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("SoundBoard.dll".ToCharArray()) + "sounds";
			AssetBundle val = AssetBundle.LoadFromFile(location);
			for (int i = 1; i <= nb; i++)
			{
				try
				{
					list.Add(val.LoadAssetWithSubAssets<AudioClip>(i + ".mp3"));
				}
				catch (Exception ex)
				{
					Debug.Log((object)ex);
					list.Add(null);
				}
			}
			return list;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "SoundBoard";

		public const string PLUGIN_NAME = "SoundBoard";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace SoundBoard.Patches
{
	[HarmonyPatch(typeof(CrawlerAI))]
	internal class CrawlerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void crawlerAudioPatch(ref AudioClip[] ___longRoarSFX)
		{
			AudioClip[] array = SoundBoard.allSounds[0];
			___longRoarSFX = array;
		}
	}
	[HarmonyPatch(typeof(ShotgunItem))]
	internal class ShotGunPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void ShotGunReloadPatch(ref AudioClip ___gunReloadSFX)
		{
			AudioClip[] array = SoundBoard.allSounds[2];
			___gunReloadSFX = array[0];
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}