Decompiled source of Rumble Additional Sounds v3.1.2

Mods/RumbleAdditionalSounds.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using AdditionalSounds;
using AdditionalSounds.Patches;
using HarmonyLib;
using Il2CppRUMBLE.Audio;
using Il2CppRUMBLE.Environment;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Players.Subsystems;
using Il2CppRUMBLE.Pools;
using Il2CppRUMBLE.Poses;
using Il2CppRUMBLE.Utilities;
using MelonLoader;
using MelonLoader.Preferences;
using RumbleModdingAPI.RMAPI;
using UIFramework;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Main), "Rumble Additional Sounds", "3.1.2", "UlvakSkillz", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 195, 0, 255)]
[assembly: MelonAuthorColor(255, 195, 0, 255)]
[assembly: VerifyLoaderVersion(0, 7, 2, true)]
[assembly: MelonAdditionalDependencies(new string[] { "UIFramework" })]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("RumbleAdditionalSounds")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+fd8665dc2d18a6eb8bf097956a3e4b126caba017")]
[assembly: AssemblyProduct("RumbleAdditionalSounds")]
[assembly: AssemblyTitle("RumbleAdditionalSounds")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AdditionalSounds
{
	public enum SoundsOrder
	{
		MoveFileNames,
		SceneLoadFileNames,
		LocalDamageFileNames,
		RemoteDamageFileNames,
		BoundaryFileName,
		HealFileNames,
		LowHealthFileName
	}
	public enum MovesOrder
	{
		Sprint,
		Flick,
		Explode,
		Hold,
		Parry,
		Dash,
		Cube,
		Uppercut,
		Wall,
		Jump,
		Stomp,
		Ball,
		Kick,
		Disc,
		Straight,
		Pillar
	}
	public enum SceneLoadOrder
	{
		EnterGymFromLoaderSound,
		EnterGymFromParkSound,
		EnterGymFromMatchmakingSound,
		EnterParkSound,
		EnterMatchmakingFromGymSound,
		EnterMatchmakingFromMatchmakingSound
	}
	public static class BuildInfo
	{
		public const string Name = "Rumble Additional Sounds";

		public const string Version = "3.1.2";
	}
	public class Main : MelonMod
	{
		[CompilerGenerated]
		private sealed class <PlaySceneLoadSound>d__13 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Main <>4__this;

			private Vector3 <playerPos>5__1;

			private string <>s__2;

			private string <>s__3;

			private string <>s__4;

			private string <>s__5;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <PlaySceneLoadSound>d__13(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>s__2 = null;
				<>s__3 = null;
				<>s__4 = null;
				<>s__5 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Expected O, but got Unknown
				//IL_0128: Unknown result type (might be due to invalid IL or missing references)
				//IL_012d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_0217: Unknown result type (might be due to invalid IL or missing references)
				//IL_0112: Unknown result type (might be due to invalid IL or missing references)
				//IL_0117: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ed: Expected O, but got Unknown
				//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_0240: Unknown result type (might be due to invalid IL or missing references)
				//IL_0269: Unknown result type (might be due to invalid IL or missing references)
				//IL_030b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0334: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					try
					{
						<playerPos>5__1 = ((Component)Singleton<PlayerManager>.instance.localPlayer.Controller.PlayerCamera).gameObject.transform.position;
					}
					catch
					{
						string currentScene = Main.currentScene;
						<>s__2 = currentScene;
						switch (<>s__2)
						{
						case "Gym":
							<playerPos>5__1 = new Vector3(2.9169f, 1.7373f, -2.1799f);
							break;
						case "Park":
							<playerPos>5__1 = new Vector3(-22.259f, -1.0704f, -11.6696f);
							break;
						case "Map0":
						case "Map1":
							<playerPos>5__1 = new Vector3(0f, 1.449f, 0f);
							break;
						}
						<>s__2 = null;
						<playerPos>5__1 = Vector3.zero;
					}
					string currentScene2 = Main.currentScene;
					<>s__3 = currentScene2;
					switch (<>s__3)
					{
					case "Gym":
						break;
					case "Park":
						if (fileExists[1][3])
						{
							AudioManager.PlaySound(audioCalls[1][3], <playerPos>5__1, false);
						}
						goto end_IL_0008;
					case "Map0":
					case "Map1":
					{
						string lastScene = Main.lastScene;
						<>s__5 = lastScene;
						switch (<>s__5)
						{
						case "Gym":
							if (fileExists[1][4])
							{
								AudioManager.PlaySound(audioCalls[1][4], <playerPos>5__1, false);
							}
							break;
						case "Map0":
						case "Map1":
							if (fileExists[1][5])
							{
								AudioManager.PlaySound(audioCalls[1][5], <playerPos>5__1, false);
							}
							break;
						}
						<>s__5 = null;
						goto end_IL_0008;
					}
					default:
						goto end_IL_0008;
					}
					string lastScene2 = Main.lastScene;
					<>s__4 = lastScene2;
					switch (<>s__4)
					{
					case "Loader":
						<>2__current = (object)new WaitForSeconds(3f);
						<>1__state = 2;
						return true;
					case "Park":
						if (fileExists[1][1])
						{
							AudioManager.PlaySound(audioCalls[1][1], <playerPos>5__1, false);
						}
						break;
					case "Map0":
					case "Map1":
						if (fileExists[1][2])
						{
							AudioManager.PlaySound(audioCalls[1][2], <playerPos>5__1, false);
						}
						break;
					}
					goto IL_027a;
				}
				case 2:
					{
						<>1__state = -1;
						if (fileExists[1][0])
						{
							AudioManager.PlaySound(audioCalls[1][0], <playerPos>5__1, false);
						}
						goto IL_027a;
					}
					IL_027a:
					<>s__4 = null;
					break;
					end_IL_0008:
					break;
				}
				<>s__3 = null;
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		internal static string[][] fileNames = new string[7][]
		{
			new string[16]
			{
				"UserData\\AdditionalSounds\\Sprint.wav", "UserData\\AdditionalSounds\\Flick.wav", "UserData\\AdditionalSounds\\Explode.wav", "UserData\\AdditionalSounds\\Hold.wav", "UserData\\AdditionalSounds\\Parry.wav", "UserData\\AdditionalSounds\\Dash.wav", "UserData\\AdditionalSounds\\Cube.wav", "UserData\\AdditionalSounds\\Uppercut.wav", "UserData\\AdditionalSounds\\Wall.wav", "UserData\\AdditionalSounds\\Jump.wav",
				"UserData\\AdditionalSounds\\Stomp.wav", "UserData\\AdditionalSounds\\Ball.wav", "UserData\\AdditionalSounds\\Kick.wav", "UserData\\AdditionalSounds\\Disc.wav", "UserData\\AdditionalSounds\\Straight.wav", "UserData\\AdditionalSounds\\Pillar.wav"
			},
			new string[6] { "UserData\\AdditionalSounds\\EnterGymFromLoaderSound.wav", "UserData\\AdditionalSounds\\EnterGymFromParkSound.wav", "UserData\\AdditionalSounds\\EnterGymFromMatchmakingSound.wav", "UserData\\AdditionalSounds\\EnterParkSound.wav", "UserData\\AdditionalSounds\\EnterMatchmakingFromGymSound.wav", "UserData\\AdditionalSounds\\EnterMatchmakingFromMatchmakingSound.wav" },
			new string[9] { "UserData\\AdditionalSounds\\LocalDamageSound0.wav", "UserData\\AdditionalSounds\\LocalDamageSound1.wav", "UserData\\AdditionalSounds\\LocalDamageSound2.wav", "UserData\\AdditionalSounds\\LocalDamageSound3.wav", "UserData\\AdditionalSounds\\LocalDamageSound4.wav", "UserData\\AdditionalSounds\\LocalDamageSound5.wav", "UserData\\AdditionalSounds\\LocalDamageSound6.wav", "UserData\\AdditionalSounds\\LocalDamageSound7.wav", "UserData\\AdditionalSounds\\LocalDamageSound8.wav" },
			new string[9] { "UserData\\AdditionalSounds\\RemoteDamageSound0.wav", "UserData\\AdditionalSounds\\RemoteDamageSound1.wav", "UserData\\AdditionalSounds\\RemoteDamageSound2.wav", "UserData\\AdditionalSounds\\RemoteDamageSound3.wav", "UserData\\AdditionalSounds\\RemoteDamageSound4.wav", "UserData\\AdditionalSounds\\RemoteDamageSound5.wav", "UserData\\AdditionalSounds\\RemoteDamageSound6.wav", "UserData\\AdditionalSounds\\RemoteDamageSound7.wav", "UserData\\AdditionalSounds\\RemoteDamageSound8.wav" },
			new string[2] { "UserData\\AdditionalSounds\\PlayerTooLow.wav", "UserData\\AdditionalSounds\\PlayerTooHigh.wav" },
			new string[2] { "UserData\\AdditionalSounds\\LocalHealSound.wav", "UserData\\AdditionalSounds\\RemoteHealSound.wav" },
			new string[1] { "UserData\\AdditionalSounds\\LowHealthSound.wav" }
		};

		internal static bool[][] fileExists = new bool[7][];

		internal static AudioCall[][] audioCalls = new AudioCall[7][];

		internal static string lastScene = "";

		internal static string currentScene = "Loader";

		internal const int TOGGLESCOUNT = 7;

		internal static void Log(string msg)
		{
			Melon<Main>.Logger.Msg(msg);
		}

		public override void OnInitializeMelon()
		{
			Preferences.InitPrefs();
			((ModelModItem)UI.Register((MelonBase)(object)this, (MelonPreferences_Category[])(object)new MelonPreferences_Category[8]
			{
				Preferences.TogglesCategory,
				Preferences.PosesCategory,
				Preferences.SceneChangeCategory,
				Preferences.YouTakingDamageCategory,
				Preferences.OthersTakingDamageCategory,
				Preferences.PlayerBoundaryKillsCategory,
				Preferences.HealingCategory,
				Preferences.LowHealthCategory
			})).OnModSaved += Save;
			LoadSounds();
		}

		public void Save()
		{
			if (Preferences.IsVolumePrefChanged())
			{
				SetVolumes();
			}
			Preferences.StoreLastSavedPrefs();
		}

		private void LoadSounds()
		{
			string text = "";
			for (int i = 0; i < 7; i++)
			{
				fileExists[i] = new bool[fileNames[i].Length];
				audioCalls[i] = (AudioCall[])(object)new AudioCall[fileNames[i].Length];
				for (int j = 0; j < fileNames[i].Length; j++)
				{
					audioCalls[i][j] = AudioManager.CreateAudioCall(fileNames[i][j], Preferences.PrefVolumes[i][j].Value / 100f);
					if ((Object)(object)audioCalls[i][j] == (Object)null)
					{
						fileExists[i][j] = false;
						string text2 = fileNames[i][j].Split('\\')[^1];
						text = text + Environment.NewLine + text2;
						continue;
					}
					if (i == 1 || i == 3 || (i == 5 && j == 1) || i == 6)
					{
						SetAudioRollOffToLinear(i, j);
					}
					fileExists[i][j] = true;
				}
			}
			if (text != "")
			{
				Log("Optional Files Not Found:" + text);
			}
			Log("Initialized");
		}

		private void SetVolumes()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			for (int i = 0; i < 7; i++)
			{
				if (audioCalls[i] == null)
				{
					continue;
				}
				for (int j = 0; j < audioCalls[i].Length; j++)
				{
					if (!((Object)(object)audioCalls[i][j] == (Object)null))
					{
						GeneralAudioSettings val = new GeneralAudioSettings();
						val.SetVolume(Preferences.PrefVolumes[i][j].Value / 100f);
						val.Pitch = 1f;
						audioCalls[i][j].generalSettings = val;
					}
				}
			}
		}

		private void SetAudioRollOffToLinear(int soundGrouping, int spot)
		{
			SpatialAudioSettings spatialSettings = audioCalls[soundGrouping][spot].spatialSettings;
			spatialSettings.AudioRollOff = (AudioRolloffMode)1;
			audioCalls[soundGrouping][spot].spatialSettings = spatialSettings;
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			lastScene = currentScene;
			currentScene = sceneName;
			SetHealth.StopLowHealthSoundEffect();
			if (Preferences.PrefSceneChangeToggle.Value)
			{
				MelonCoroutines.Start(PlaySceneLoadSound());
			}
		}

		[IteratorStateMachine(typeof(<PlaySceneLoadSound>d__13))]
		private IEnumerator PlaySceneLoadSound()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <PlaySceneLoadSound>d__13(0)
			{
				<>4__this = this
			};
		}
	}
	public class Preferences
	{
		private const string CONFIG_FILE = "config.cfg";

		private const string USER_DATA = "UserData/AdditionalSounds/";

		internal static Dictionary<MelonPreferences_Entry, object> LastSavedValues = new Dictionary<MelonPreferences_Entry, object>();

		internal static MelonPreferences_Category TogglesCategory;

		internal static List<MelonPreferences_Category> VolumeCategories;

		internal static MelonPreferences_Category PosesCategory;

		internal static MelonPreferences_Category SceneChangeCategory;

		internal static MelonPreferences_Category YouTakingDamageCategory;

		internal static MelonPreferences_Category OthersTakingDamageCategory;

		internal static MelonPreferences_Category PlayerBoundaryKillsCategory;

		internal static MelonPreferences_Category HealingCategory;

		internal static MelonPreferences_Category LowHealthCategory;

		internal static MelonPreferences_Entry<bool> PrefPosesToggle;

		internal static MelonPreferences_Entry<bool> PrefSceneChangeToggle;

		internal static MelonPreferences_Entry<bool> PrefYouTakingDamageToggle;

		internal static MelonPreferences_Entry<bool> PrefOthersTakingDamageToggle;

		internal static MelonPreferences_Entry<bool> PrefPlayerBoundaryKillsToggle;

		internal static MelonPreferences_Entry<bool> PrefHealingToggle;

		internal static MelonPreferences_Entry<bool> PrefLowHealthToggle;

		internal static MelonPreferences_Entry<int> PrefLowHealthAmount;

		internal static MelonPreferences_Entry<float>[][] PrefVolumes;

		internal static void InitPrefs()
		{
			if (!Directory.Exists("UserData/AdditionalSounds/"))
			{
				Directory.CreateDirectory("UserData/AdditionalSounds/");
			}
			TogglesCategory = MelonPreferences.CreateCategory("Toggles", "Toggles");
			TogglesCategory.SetFilePath(Path.Combine("UserData/AdditionalSounds/", "config.cfg"));
			PrefPosesToggle = TogglesCategory.CreateEntry<bool>("Poses", true, "Poses Toggle", "Toggles Pose Sounds from Playing", false, false, (ValueValidator)null, (string)null);
			PrefSceneChangeToggle = TogglesCategory.CreateEntry<bool>("SceneChange", true, "Scene Change Toggle", "Toggles Scene Change Sounds from Playing", false, false, (ValueValidator)null, (string)null);
			PrefYouTakingDamageToggle = TogglesCategory.CreateEntry<bool>("YouTakingDamage", true, "You Taking Damage Toggle", "Toggles You Taking Damage Sounds from Playing", false, false, (ValueValidator)null, (string)null);
			PrefOthersTakingDamageToggle = TogglesCategory.CreateEntry<bool>("OthersTakingDamage", true, "Others Taking Damage Toggle", "Toggles Others Taking Damage Sounds from Playing", false, false, (ValueValidator)null, (string)null);
			PrefPlayerBoundaryKillsToggle = TogglesCategory.CreateEntry<bool>("PlayerBoundaryKills", true, "Player Boundary Kills Toggle", "Toggles Kill Boundary Sounds from Playing", false, false, (ValueValidator)null, (string)null);
			PrefHealingToggle = TogglesCategory.CreateEntry<bool>("Healing", true, "Healing Toggle", "Toggles Healing Sounds from Playing", false, false, (ValueValidator)null, (string)null);
			PrefLowHealthToggle = TogglesCategory.CreateEntry<bool>("LowHealth", true, "Low Health Toggle", "Toggles Low Health Sound from Playing. In Matchmaking Only.", false, false, (ValueValidator)null, (string)null);
			PrefLowHealthAmount = TogglesCategory.CreateEntry<int>("LowHealthAmount", 7, "Low Health Amount", "Sets the Amount of Health to Start Triggering the Low Health Sound", false, false, (ValueValidator)(object)new ValueRange<int>(0, 20), (string)null);
			PosesCategory = MelonPreferences.CreateCategory("PosesVolumes", "Poses");
			PosesCategory.SetFilePath(Path.Combine("UserData/AdditionalSounds/", "config.cfg"));
			SceneChangeCategory = MelonPreferences.CreateCategory("SceneChangeVolumes", "SceneChange");
			SceneChangeCategory.SetFilePath(Path.Combine("UserData/AdditionalSounds/", "config.cfg"));
			YouTakingDamageCategory = MelonPreferences.CreateCategory("YouTakingDamageVolumes", "You Taking Damage");
			YouTakingDamageCategory.SetFilePath(Path.Combine("UserData/AdditionalSounds/", "config.cfg"));
			OthersTakingDamageCategory = MelonPreferences.CreateCategory("OthersTakingDamageVolumes", "Others Taking Damage");
			OthersTakingDamageCategory.SetFilePath(Path.Combine("UserData/AdditionalSounds/", "config.cfg"));
			PlayerBoundaryKillsCategory = MelonPreferences.CreateCategory("PlayerBoundaryKillsVolumes", "Player Boundary Kills");
			PlayerBoundaryKillsCategory.SetFilePath(Path.Combine("UserData/AdditionalSounds/", "config.cfg"));
			HealingCategory = MelonPreferences.CreateCategory("HealingVolumes", "Healing");
			HealingCategory.SetFilePath(Path.Combine("UserData/AdditionalSounds/", "config.cfg"));
			LowHealthCategory = MelonPreferences.CreateCategory("LowHealthVolumes", "Low Health");
			LowHealthCategory.SetFilePath(Path.Combine("UserData/AdditionalSounds/", "config.cfg"));
			VolumeCategories = new List<MelonPreferences_Category> { PosesCategory, SceneChangeCategory, YouTakingDamageCategory, OthersTakingDamageCategory, PlayerBoundaryKillsCategory, HealingCategory, LowHealthCategory };
			PrefVolumes = new MelonPreferences_Entry<float>[7][];
			for (int i = 0; i < 7; i++)
			{
				PrefVolumes[i] = new MelonPreferences_Entry<float>[Main.fileNames[i].Length];
				for (int j = 0; j < Main.fileNames[i].Length; j++)
				{
					string text = Main.fileNames[i][j].Replace(".wav", "").Split('\\')[^1];
					PrefVolumes[i][j] = VolumeCategories[i].CreateEntry<float>(text + " Volume", 50f, text + " Volume", "Edits " + text + "'s Volume in Game. 0 - 100.", false, false, (ValueValidator)(object)new ValueRange<float>(0f, 100f), (string)null);
				}
			}
			StoreLastSavedPrefs();
		}

		internal static void StoreLastSavedPrefs()
		{
			List<MelonPreferences_Entry> list = new List<MelonPreferences_Entry>();
			list.AddRange(TogglesCategory.Entries);
			foreach (MelonPreferences_Category volumeCategory in VolumeCategories)
			{
				list.AddRange(volumeCategory.Entries);
			}
			foreach (MelonPreferences_Entry item in list)
			{
				LastSavedValues[item] = item.BoxedValue;
			}
		}

		public static bool IsPrefChanged(MelonPreferences_Entry entry)
		{
			if (LastSavedValues.TryGetValue(entry, out var value))
			{
				return !entry.BoxedValue.Equals(value);
			}
			return false;
		}

		public static bool IsVolumePrefChanged()
		{
			for (int i = 0; i < PrefVolumes.Length; i++)
			{
				for (int j = 0; j < PrefVolumes[i].Length; j++)
				{
					if (IsPrefChanged((MelonPreferences_Entry)(object)PrefVolumes[i][j]))
					{
						return true;
					}
				}
			}
			return false;
		}
	}
}
namespace AdditionalSounds.Patches
{
	[HarmonyPatch(typeof(PlayerResetSystem), "ResetPlayerController", new Type[] { })]
	public static class ResetPlayerController
	{
		private static void Postfix(ref PlayerResetSystem __instance)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			if (Preferences.PrefPlayerBoundaryKillsToggle.Value && (int)((PlayerControllerSubsystem)__instance).parentController.controllerType != 2)
			{
				Vector3 position = ((Component)Singleton<PlayerManager>.instance.localPlayer.Controller.PlayerVR).gameObject.transform.FindChild("Foot Collider").position;
				Transform transform = ((Component)SceneBoundary.CurrentActivePlayerSceneBoundary).transform;
				float num = transform.position.y + transform.localScale.y / 2f;
				float num2 = transform.position.y - transform.localScale.y / 2f;
				if (position.y < num2)
				{
					AudioManager.PlaySound(Main.audioCalls[4][0], position, false);
				}
				else if (position.y > num)
				{
					AudioManager.PlaySound(Main.audioCalls[4][1], position, false);
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerPoseSystem), "OnPoseSetCompleted", new Type[] { typeof(PoseSet) })]
	public static class PosePatch
	{
		private static void Postfix(ref PlayerPoseSystem __instance, PoseSet set)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_040e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			if (Preferences.PrefPosesToggle.Value)
			{
				Vector3 position = ((Component)((PlayerControllerSubsystem)__instance).parentController.PlayerCamera).gameObject.transform.position;
				switch (((Object)set).name)
				{
				case "SprintingPoseSet":
					AudioManager.PlaySound(Main.audioCalls[0][0], position, false);
					break;
				case "PoseSetFlick":
					AudioManager.PlaySound(Main.audioCalls[0][1], position, false);
					break;
				case "PoseSetExplode":
					AudioManager.PlaySound(Main.audioCalls[0][2], position, false);
					break;
				case "PoseSetHoldLeft":
					AudioManager.PlaySound(Main.audioCalls[0][3], position, false);
					break;
				case "PoseSetHoldRight":
					AudioManager.PlaySound(Main.audioCalls[0][3], position, false);
					break;
				case "PoseSetParry":
					AudioManager.PlaySound(Main.audioCalls[0][4], position, false);
					break;
				case "PoseSetDash":
					AudioManager.PlaySound(Main.audioCalls[0][5], position, false);
					break;
				case "PoseSetSpawnCube":
					AudioManager.PlaySound(Main.audioCalls[0][6], position, false);
					break;
				case "PoseSetUppercut":
					AudioManager.PlaySound(Main.audioCalls[0][7], position, false);
					break;
				case "PoseSetWall_Grounded":
					AudioManager.PlaySound(Main.audioCalls[0][8], position, false);
					break;
				case "PoseSetRockjump":
					AudioManager.PlaySound(Main.audioCalls[0][9], position, false);
					break;
				case "PoseSetStomp":
					AudioManager.PlaySound(Main.audioCalls[0][10], position, false);
					break;
				case "PoseSetBall":
					AudioManager.PlaySound(Main.audioCalls[0][11], position, false);
					break;
				case "PoseSetKick":
					AudioManager.PlaySound(Main.audioCalls[0][12], position, false);
					break;
				case "PoseSetDisc":
					AudioManager.PlaySound(Main.audioCalls[0][13], position, false);
					break;
				case "PoseSetStraight":
					AudioManager.PlaySound(Main.audioCalls[0][14], position, false);
					break;
				case "PoseSetSpawnPillar":
					AudioManager.PlaySound(Main.audioCalls[0][15], position, false);
					break;
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerHealth), "SetHealth", new Type[]
	{
		typeof(short),
		typeof(short),
		typeof(bool)
	})]
	public static class SetHealth
	{
		[CompilerGenerated]
		private sealed class <StartLowHealthSoundEffect>d__2 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <StartLowHealthSoundEffect>d__2(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0094: Expected O, but got Unknown
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					Melon<Main>.Logger.Msg("Starting Low Health Sound");
					lowHealthSoundEffect = AudioManager.PlaySound(Main.audioCalls[6][0], ((Component)Singleton<PlayerManager>.instance.localPlayer.Controller.PlayerCamera).gameObject.transform.position, false);
					<>2__current = (object)new WaitForSeconds(lowHealthSoundEffect.audioSource.clip.length);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					break;
				case 2:
					<>1__state = -1;
					break;
				}
				if ((Object)(object)lowHealthSoundEffect != (Object)null && Preferences.PrefLowHealthToggle.Value)
				{
					lowHealthSoundEffect = AudioManager.PlaySound(Main.audioCalls[6][0], ((Component)Singleton<PlayerManager>.instance.localPlayer.Controller.PlayerCamera).gameObject.transform.position, false);
					<>2__current = (object)new WaitForSeconds(lowHealthSoundEffect.audioSource.clip.length);
					<>1__state = 2;
					return true;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static PooledAudioSource lowHealthSoundEffect;

		private static void Postfix(ref PlayerHealth __instance, short newHealth, short previousHealth, bool useEffects)
		{
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Invalid comparison between Unknown and I4
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			if (!useEffects)
			{
				return;
			}
			if (newHealth > previousHealth)
			{
				if ((int)((PlayerControllerSubsystem)__instance).ParentController.controllerType == 1)
				{
					if (newHealth > Preferences.PrefLowHealthAmount.Value)
					{
						StopLowHealthSoundEffect();
					}
					if (Preferences.PrefHealingToggle.Value && Main.fileExists[5][0])
					{
						AudioManager.PlaySound(Main.audioCalls[5][0], ((Component)((PlayerControllerSubsystem)__instance).parentController.PlayerCamera).gameObject.transform.position, false);
					}
				}
				else if (Preferences.PrefHealingToggle.Value && Main.fileExists[5][1])
				{
					AudioManager.PlaySound(Main.audioCalls[5][1], ((Component)((PlayerControllerSubsystem)__instance).parentController.PlayerCamera).gameObject.transform.position, false);
				}
				return;
			}
			if ((int)((PlayerControllerSubsystem)__instance).ParentController.controllerType == 1)
			{
				if (Preferences.PrefYouTakingDamageToggle.Value && Main.fileExists[2][Math.Min(previousHealth - newHealth, 8)])
				{
					AudioManager.PlaySound(Main.audioCalls[2][Math.Min(previousHealth - newHealth, 8)], ((Component)((PlayerControllerSubsystem)__instance).parentController.PlayerCamera).gameObject.transform.position, false);
				}
				if (Preferences.PrefLowHealthToggle.Value && Main.fileExists[6][0] && (Main.currentScene == "Map0" || Main.currentScene == "Map1") && (Object)(object)lowHealthSoundEffect == (Object)null && newHealth > 0 && newHealth <= Preferences.PrefLowHealthAmount.Value)
				{
					MelonCoroutines.Start(StartLowHealthSoundEffect());
				}
			}
			else if (Preferences.PrefOthersTakingDamageToggle.Value && Main.fileExists[3][Math.Min(previousHealth - newHealth, 8)] && previousHealth != 0)
			{
				AudioManager.PlaySound(Main.audioCalls[3][Math.Min(previousHealth - newHealth, 8)], ((Component)((PlayerControllerSubsystem)__instance).parentController.PlayerCamera).gameObject.transform.position, false);
			}
			if (newHealth == 0)
			{
				StopLowHealthSoundEffect();
			}
		}

		[IteratorStateMachine(typeof(<StartLowHealthSoundEffect>d__2))]
		private static IEnumerator StartLowHealthSoundEffect()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <StartLowHealthSoundEffect>d__2(0);
		}

		internal static void StopLowHealthSoundEffect()
		{
			if ((Object)(object)lowHealthSoundEffect != (Object)null)
			{
				Melon<Main>.Logger.Msg("Stopping Low Health Sound");
				((PooledMonoBehaviour)lowHealthSoundEffect).ReturnToPool();
				lowHealthSoundEffect = null;
			}
		}
	}
}