Decompiled source of AudioPatch v1.0.0

AudioPatch.dll

Decompiled 2 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("blacks7ar")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AudioPatch")]
[assembly: AssemblyTitle("AudioPatch")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 AudioPatch
{
	[BepInPlugin("blacks7ar.AudioPatch", "AudioPatch", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(ZSFX), "CustomUpdate")]
		public class ZSFXPatch
		{
			private static void Postfix(ZSFX __instance)
			{
				if (_modEnable.Value && (Object)(object)__instance.m_audioSource != (Object)null && __instance.m_audioSource.isPlaying)
				{
					float sFXVolume = AudioMan.GetSFXVolume();
					AudioSource audioSource = __instance.m_audioSource;
					audioSource.volume *= sFXVolume;
					AudioSource audioSource2 = __instance.m_audioSource;
					AudioSource audioSource3 = __instance.m_audioSource;
					float volume = (audioSource3.volume *= _masterVolume.Value);
					audioSource2.volume = volume;
				}
			}
		}

		private const string modGUID = "blacks7ar.AudioPatch";

		public const string modName = "AudioPatch";

		public const string modAuthor = "blacks7ar";

		public const string modVersion = "1.0.0";

		private static readonly Harmony _harmony = new Harmony("blacks7ar.AudioPatch");

		private static ConfigEntry<bool> _modEnable;

		private static ConfigEntry<float> _masterVolume;

		private ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			ConfigDescription val = new ConfigDescription(description.Description, description.AcceptableValues, description.Tags);
			return ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val);
		}

		public void Awake()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
			_modEnable = config("General", "Enable Mod", value: true, new ConfigDescription("If true, enables mod and applies patch.", (AcceptableValueBase)null, Array.Empty<object>()));
			_masterVolume = config("General", "SFX Volume", 100f, new ConfigDescription("Separate additional volume for sfx", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
			((BaseUnityPlugin)this).Config.Save();
		}

		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
		}
	}
}