Decompiled source of Underslam v0.2.0

Underslam.dll

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

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyVersion("0.2.0.0")]
[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 Prototype
{
	[BepInPlugin("prototype.audio.thunderslam", "Underslam", "0.2.0")]
	public class Underslam : BaseUnityPlugin
	{
		public const string version = "0.2.0";

		public const string identifier = "prototype.audio.thunderslam";

		private static MonoBehaviour instance;

		private static GameObject emitter;

		protected void Awake()
		{
			instance = (MonoBehaviour)(object)this;
			Harmony.CreateAndPatchAll(((object)this).GetType(), (string)null);
		}

		[HarmonyPatch(typeof(AkSoundEngine), "PostEvent", new Type[]
		{
			typeof(string),
			typeof(GameObject)
		})]
		[HarmonyPrefix]
		private static void PostEvent(string in_pszEventName, GameObject in_gameObjectID)
		{
			if ((in_pszEventName == "Play_loader_R_variant_activate" || in_pszEventName == "Play_loader_R_variant_whooshDown") ? true : false)
			{
				instance.StopAllCoroutines();
				SetVolume(emitter = in_gameObjectID, 0.05f);
			}
		}

		[HarmonyPatch(typeof(AkSoundEngine), "PostEvent", new Type[]
		{
			typeof(uint),
			typeof(GameObject)
		})]
		[HarmonyPrefix]
		private static void PostEvent(uint in_eventID, GameObject in_gameObjectID)
		{
			if (in_eventID == 2640687082u)
			{
				SetVolume(in_gameObjectID, 0.015f);
				instance.StartCoroutine(delay());
			}
			static IEnumerator delay()
			{
				yield return (object)new WaitForSeconds(0.75f);
				SetVolume(emitter, 1f);
			}
		}

		private static void SetVolume(GameObject source, float volume)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)source))
			{
				return;
			}
			foreach (AkAudioListener listener in ((BaseListenerList)AkAudioListener.DefaultListeners).ListenerList)
			{
				AkSoundEngine.SetGameObjectOutputBusVolume(source, ((Component)listener).gameObject, volume);
			}
		}
	}
}