Decompiled source of RealerVoidFartReverb v1.0.0

VoidFartReverb.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.VoidRaidCrab;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using On.EntityStates.VoidRaidCrab;
using On.RoR2;
using RoR2;
using RoR2.Audio;
using RoR2.Projectile;
using UnityEngine;
using UnityEngine.AddressableAssets;
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("VoidFartReverb")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("VoidFartReverb")]
[assembly: AssemblyTitle("VoidFartReverb")]
[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 VoidFartReverb
{
	[BepInPlugin("prodzpod.VoidFartReverb", "VoidFartReverb", "1.0.0")]
	public class Main : BaseUnityPlugin
	{
		public class GlobalVoidFartReverbComponent : MonoBehaviour
		{
			public string sound = "Play_voidfartreverb_small";
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_OnExit <>9__14_0;

			public static hook_SpawnEffect_EffectIndex_EffectData_bool <>9__14_1;

			internal void <Awake>b__14_0(orig_OnExit orig, VacuumAttack self)
			{
				orig.Invoke(self);
				UtilPlaySound("Play_voidfartreverb_big", ((EntityState)self).gameObject);
			}

			internal void <Awake>b__14_1(orig_SpawnEffect_EffectIndex_EffectData_bool orig, EffectIndex idx, EffectData data, bool tr)
			{
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				if (!EffectManager.DisableAllEffectSpawning && (!tr || !NetworkServer.active) && NetworkClient.active)
				{
					EffectDef effectDef = EffectCatalog.GetEffectDef(idx);
					GlobalVoidFartReverbComponent globalVoidFartReverbComponent = default(GlobalVoidFartReverbComponent);
					if (effectDef.prefab.TryGetComponent<GlobalVoidFartReverbComponent>(ref globalVoidFartReverbComponent))
					{
						if (GlobalSound.Value)
						{
							AkSoundEngine.PostEvent(globalVoidFartReverbComponent.sound, effectDef.prefab);
						}
						else
						{
							PointSoundManager.EmitSoundLocal((AkEventIdArg)globalVoidFartReverbComponent.sound, data.origin);
						}
					}
				}
				orig.Invoke(idx, data, tr);
			}
		}

		public const string PluginGUID = "prodzpod.VoidFartReverb";

		public const string PluginAuthor = "prodzpod";

		public const string PluginName = "VoidFartReverb";

		public const string PluginVersion = "1.0.0";

		public static ManualLogSource Log;

		internal static PluginInfo pluginInfo;

		public static ConfigFile Config;

		public static ConfigEntry<bool> GlobalSound;

		public static ConfigEntry<bool> MuteOriginal;

		public static ConfigEntry<bool> ApplyVoidling;

		public static ConfigEntry<bool> ApplyVrit;

		public static Harmony Harmony;

		public const string SOUND_SMALL = "Play_voidfartreverb_small";

		public const string SOUND_BIG = "Play_voidfartreverb_big";

		public void Awake()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Expected O, but got Unknown
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Expected O, but got Unknown
			pluginInfo = ((BaseUnityPlugin)this).Info;
			Log = ((BaseUnityPlugin)this).Logger;
			Config = new ConfigFile(Path.Combine(Paths.ConfigPath, "prodzpod.VoidFartReverb.cfg"), true);
			GlobalSound = Config.Bind<bool>("General", "Global Sound", false, "make sound disregard proximity. default as per original version");
			MuteOriginal = Config.Bind<bool>("General", "Mute Original Sound", false, "make fart the only sound. default as per original version");
			ApplyVoidling = Config.Bind<bool>("General", "Apply to Voidling", false, "make sound apply to voidling's instakill attacks as well. default as per original version");
			ApplyVrit = Config.Bind<bool>("General", "Apply to Void Crit", false, "make sound apply to void crit as well. default as per original version");
			ChangeSound("Base/Nullifier/NullifierDeathBombExplosion", "Play_voidfartreverb_small");
			ChangeSound("DLC1/VoidJailer/VoidJailerDeathBombExplosion", "Play_voidfartreverb_big");
			ChangeSound(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/VoidJailer/VoidJailerDeathBombProjectile.prefab").WaitForCompletion().GetComponent<ProjectileImpactExplosion>()
				.impactEffect, "Play_voidfartreverb_big");
				ChangeSound(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/VoidJailer/VoidJailerDeathBombProjectileStill.prefab").WaitForCompletion().GetComponent<ProjectileImpactExplosion>()
					.impactEffect, "Play_voidfartreverb_big");
					ChangeSound("DLC1/VoidMegaCrab/VoidMegaCrabDeathBombExplosion", "Play_voidfartreverb_big");
					if (ApplyVoidling.Value)
					{
						object obj = <>c.<>9__14_0;
						if (obj == null)
						{
							hook_OnExit val = delegate(orig_OnExit orig, VacuumAttack self)
							{
								orig.Invoke(self);
								UtilPlaySound("Play_voidfartreverb_big", ((EntityState)self).gameObject);
							};
							<>c.<>9__14_0 = val;
							obj = (object)val;
						}
						VacuumAttack.OnExit += (hook_OnExit)obj;
					}
					if (ApplyVrit.Value)
					{
						ChangeSound("DLC1/CritGlassesVoid/CritGlassesVoidExecuteEffect", "Play_voidfartreverb_small");
					}
					object obj2 = <>c.<>9__14_1;
					if (obj2 == null)
					{
						hook_SpawnEffect_EffectIndex_EffectData_bool val2 = delegate(orig_SpawnEffect_EffectIndex_EffectData_bool orig, EffectIndex idx, EffectData data, bool tr)
						{
							//IL_0077: Unknown result type (might be due to invalid IL or missing references)
							//IL_0020: Unknown result type (might be due to invalid IL or missing references)
							//IL_0063: Unknown result type (might be due to invalid IL or missing references)
							//IL_0069: Unknown result type (might be due to invalid IL or missing references)
							if (!EffectManager.DisableAllEffectSpawning && (!tr || !NetworkServer.active) && NetworkClient.active)
							{
								EffectDef effectDef = EffectCatalog.GetEffectDef(idx);
								GlobalVoidFartReverbComponent globalVoidFartReverbComponent = default(GlobalVoidFartReverbComponent);
								if (effectDef.prefab.TryGetComponent<GlobalVoidFartReverbComponent>(ref globalVoidFartReverbComponent))
								{
									if (GlobalSound.Value)
									{
										AkSoundEngine.PostEvent(globalVoidFartReverbComponent.sound, effectDef.prefab);
									}
									else
									{
										PointSoundManager.EmitSoundLocal((AkEventIdArg)globalVoidFartReverbComponent.sound, data.origin);
									}
								}
							}
							orig.Invoke(idx, data, tr);
						};
						<>c.<>9__14_1 = val2;
						obj2 = (object)val2;
					}
					EffectManager.SpawnEffect_EffectIndex_EffectData_bool += (hook_SpawnEffect_EffectIndex_EffectData_bool)obj2;
				}

				public static void ChangeSound(string path, string sound)
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_0015: Unknown result type (might be due to invalid IL or missing references)
					ChangeSound(Addressables.LoadAssetAsync<GameObject>((object)("RoR2/" + path + ".prefab")).WaitForCompletion(), sound);
				}

				public static void ChangeSound(GameObject go, string sound)
				{
					go.AddComponent<GlobalVoidFartReverbComponent>().sound = sound;
					if (MuteOriginal.Value)
					{
						go.GetComponent<EffectComponent>().soundName = "";
					}
				}

				public static void UtilPlaySound(string sound, GameObject source)
				{
					//IL_0020: Unknown result type (might be due to invalid IL or missing references)
					//IL_002b: Unknown result type (might be due to invalid IL or missing references)
					string text = "";
					if (GlobalSound.Value)
					{
						AkSoundEngine.PostEvent(sound, source);
					}
					else
					{
						PointSoundManager.EmitSoundLocal((AkEventIdArg)sound, source.transform.position);
					}
				}
			}
		}