Decompiled source of Reduces sound v1.2.3

fallsound.dll

Decompiled 2 years 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 System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;
using fallsound.Objects;
using fallsound.Patches;

[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("fallsound")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("fallsound")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("fallsound")]
[assembly: AssemblyTitle("fallsound")]
[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;
		}
	}
}
public static class CoroutineHelper
{
	private class CoroutineRunner : MonoBehaviour
	{
	}

	private static GameObject coroutineObject;

	public static void StartCoroutine(IEnumerator coroutine)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		if ((Object)(object)coroutineObject == (Object)null)
		{
			coroutineObject = new GameObject("CoroutineHelper");
			Object.DontDestroyOnLoad((Object)(object)coroutineObject);
		}
		((MonoBehaviour)coroutineObject.AddComponent<CoroutineRunner>()).StartCoroutine(coroutine);
	}
}
namespace fallsound
{
	[BepInPlugin("fallsound", "fallsound", "1.0.0")]
	public class fallsound : BaseUnityPlugin
	{
		private const string modGUID = "fallsound";

		private const string modName = "fallsound";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("fallsound");

		public static fallsound instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			instance = this;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
				Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			}
			if ((Object)(object)instance == (Object)null)
			{
			}
			harmony.PatchAll(typeof(fallsound));
			harmony.PatchAll(typeof(FallvoidPatch));
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "fallsound";

		public const string PLUGIN_NAME = "fallsound";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace fallsound.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class FallvoidPatch : HarmonyPatch
	{
		public static List<PlayerSoundStatus> playerSoundStatusList = new List<PlayerSoundStatus>();

		public static AudioClip newSFX;

		private static ManualLogSource mls;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void startEventListener()
		{
			if ((Object)(object)fallsound.instance != (Object)null)
			{
				string location = ((BaseUnityPlugin)fallsound.instance).Info.Location;
				string text = "fallsound.dll";
				string text2 = location.TrimEnd(text.ToCharArray());
				string text3 = text2 + "fallsound.wav";
				((MonoBehaviour)fallsound.instance).StartCoroutine(LoadAudio("file:///" + text3, delegate(AudioClip sound)
				{
					newSFX = sound;
				}));
			}
			else
			{
				string location2 = Assembly.GetExecutingAssembly().Location;
				string directoryName = Path.GetDirectoryName(location2);
				string text4 = Path.Combine(directoryName, "fallsound.wav");
				CoroutineHelper.StartCoroutine(LoadAudio("file:///" + text4, delegate(AudioClip sound)
				{
					newSFX = sound;
				}));
			}
		}

		public static IEnumerator LoadAudio(string url, Action<AudioClip> callback)
		{
			UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(url, (AudioType)20);
			try
			{
				yield return www.SendWebRequest();
				if ((int)www.result != 2)
				{
					AudioClip clip = DownloadHandlerAudioClip.GetContent(www);
					if (!((Object)(object)clip == (Object)null))
					{
						callback(clip);
					}
				}
			}
			finally
			{
				((IDisposable)www)?.Dispose();
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void SoundVoidPatch(ref PlayerControllerB __instance)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = __instance;
			PlayerSoundStatus item = new PlayerSoundStatus(val);
			CauseOfDeath causeOfDeath = val.causeOfDeath;
			if ((Object)(object)__instance == (Object)null)
			{
				return;
			}
			if (val.isPlayerDead && (int)causeOfDeath == 2)
			{
				if (!playerSoundStatusList.Contains(item))
				{
					playerSoundStatusList.Add(item);
					return;
				}
				item = playerSoundStatusList[playerSoundStatusList.IndexOf(item)];
				if (!item._status)
				{
					AudioSource val2 = ((Component)val).gameObject.AddComponent<AudioSource>();
					val2.clip = newSFX;
					((Component)val2).transform.position = ((Component)val).transform.position;
					val2.rolloffMode = (AudioRolloffMode)1;
					val2.maxDistance = 30f;
					val2.minDistance = 1f;
					val2.Play();
					item._status = true;
				}
			}
			else if (!val.isPlayerDead && playerSoundStatusList.IndexOf(item) != -1)
			{
				playerSoundStatusList.Remove(item);
			}
		}
	}
}
namespace fallsound.Objects
{
	internal class PlayerSoundStatus
	{
		public bool _status;

		public PlayerControllerB _player;

		public bool Status
		{
			get
			{
				return _status;
			}
			set
			{
				_status = value;
			}
		}

		private PlayerControllerB Player
		{
			get
			{
				return _player;
			}
			set
			{
				_player = value;
			}
		}

		public PlayerSoundStatus(PlayerControllerB player)
		{
			Player = player;
			Status = false;
		}

		public override bool Equals(object obj)
		{
			if (obj == null || GetType() != obj.GetType())
			{
				return false;
			}
			PlayerSoundStatus playerSoundStatus = (PlayerSoundStatus)obj;
			return ((object)Player).Equals((object?)playerSoundStatus.Player);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

neckcracksound.dll

Decompiled 2 years 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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("neckcracksound")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("neckcracksound")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("neckcracksound")]
[assembly: AssemblyTitle("neckcracksound")]
[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 neckcracksound
{
	[BepInPlugin("neckcracksound", "neckcracksound", "1.0.0")]
	public class neckcracksound : BaseUnityPlugin
	{
		private const string modGUID = "neckcracksound";

		private const string modName = "neckcracksound";

		private const string modVersion = "1.0.0";

		private static neckcracksound Instance;

		private readonly Harmony harmony = new Harmony("neckcracksound");

		internal ManualLogSource mls;

		public void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			if ((Object)Instance == (Object)null)
			{
				Instance = this;
			}
			harmony.PatchAll();
		}
	}
	[HarmonyPatch(typeof(FlowermanAI))]
	internal class neckcracksoundPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void AudioPatch(FlowermanAI __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Invalid comparison between Unknown and I4
			if ((Object)__instance != (Object)null)
			{
				string path = "neckcracksound.wav";
				string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), path);
				UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip("file:///" + text, (AudioType)20);
				audioClip.SendWebRequest();
				while (!audioClip.isDone)
				{
				}
				if ((int)audioClip.result == 1)
				{
					__instance.crackNeckSFX = DownloadHandlerAudioClip.GetContent(audioClip);
					__instance.crackNeckAudio.rolloffMode = (AudioRolloffMode)1;
					__instance.crackNeckAudio.maxDistance = 30f;
					__instance.crackNeckAudio.minDistance = 1f;
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "neckcracksound";

		public const string PLUGIN_NAME = "neckcracksound";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}