Decompiled source of VolumeBooster v1.0.10

Ramune.VolumeBooster.dll

Decompiled 7 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RamuneLib;
using RamuneLib.Utils;
using Unity.Mathematics;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Ramune.VolumeBooster")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Ramune.VolumeBooster")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2d71702a-7d4e-493d-b39d-f7d531c5ecca")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[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 Ramune.VolumeBooster
{
	[BepInPlugin("com.ramune.VolumeBooster", "Volume Booster", "1.0.1")]
	[BepInProcess("Content Warning.exe")]
	public class VolumeBooster : BaseUnityPlugin
	{
		public static VolumeBooster Instance;

		public static readonly Harmony harmony = new Harmony("com.ramune.VolumeBooster");

		public const string GUID = "com.ramune.VolumeBooster";

		public const string Name = "Volume Booster";

		public const string Version = "1.0.1";

		public static ManualLogSource logger => ((BaseUnityPlugin)Instance).Logger;

		public static ConfigEntry<float> MaxEntry { get; set; }

		public void Awake()
		{
			MaxEntry = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "MaxVolumeSettingValue", 30f, "This number will be the top limit for how much you can adjust your volume settings");
			Initializer.Initialize(harmony, ((BaseUnityPlugin)this).Logger, "Volume Booster", "1.0.1");
		}
	}
}
namespace Ramune.VolumeBooster.Patches
{
	[HarmonyPatch(typeof(MasterVolumeSetting))]
	public static class MasterVolumeSettingPatch
	{
		[HarmonyPatch("GetMinMaxValue")]
		[HarmonyPostfix]
		public static void GetMinMaxValue(MasterVolumeSetting __instance, ref float2 __result)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			__result = new float2(0f, VolumeBooster.MaxEntry.Value);
		}
	}
	[HarmonyPatch(typeof(SFXVolumeSetting))]
	public static class SFXVolumeSettingPatch
	{
		[HarmonyPatch("GetMinMaxValue")]
		[HarmonyPostfix]
		public static void GetMinMaxValue(SFXVolumeSetting __instance, ref float2 __result)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			__result = new float2(0f, VolumeBooster.MaxEntry.Value);
		}
	}
	[HarmonyPatch(typeof(VoiceVolumeSetting))]
	public static class VoiceVolumeSettingPatch
	{
		[HarmonyPatch("GetMinMaxValue")]
		[HarmonyPostfix]
		public static void GetMinMaxValue(VoiceVolumeSetting __instance, ref float2 __result)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			__result = new float2(0f, VolumeBooster.MaxEntry.Value);
		}
	}
}
namespace RamuneLib
{
	public static class Initializer
	{
		public static void Initialize(Harmony harmony, ManualLogSource logger, string name, string version, bool patchAll = true)
		{
			Variables.harmony = harmony;
			Variables.logger = logger;
			string text = "======================= " + name + " (" + version + ") =======================";
			string message = new string('=', text.Length);
			LoggerUtils.LogInfo(text);
			if (patchAll)
			{
				LoggerUtils.LogInfo(">> Loading harmony patches for '" + name + " " + version + "'");
				harmony.PatchAll();
				LoggerUtils.LogInfo(">> Finished loading harmony patches for '" + name + " " + version + "'..");
			}
			LoggerUtils.LogInfo(message);
		}
	}
	public static class Variables
	{
		public static class Paths
		{
			public static string PluginFolder => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

			public static string AssetsFolder => Path.Combine(PluginFolder, "Assets");
		}

		public static Harmony harmony { get; set; }

		public static ManualLogSource logger { get; set; }
	}
}
namespace RamuneLib.Utils
{
	public static class LoggerUtils
	{
		public static bool Debug;

		public static void LogInfo(string message)
		{
			ManualLogSource logger = Variables.logger;
			if (logger != null)
			{
				logger.LogInfo((object)message);
			}
		}

		public static void LogDebug(string message)
		{
			ManualLogSource logger = Variables.logger;
			if (logger != null)
			{
				logger.LogDebug((object)message);
			}
		}

		public static void LogWarning(string message)
		{
			ManualLogSource logger = Variables.logger;
			if (logger != null)
			{
				logger.LogWarning((object)message);
			}
		}

		public static void LogError(string message)
		{
			ManualLogSource logger = Variables.logger;
			if (logger != null)
			{
				logger.LogError((object)message);
			}
		}

		public static void LogFatal(string message)
		{
			ManualLogSource logger = Variables.logger;
			if (logger != null)
			{
				logger.LogFatal((object)message);
			}
		}
	}
}