Decompiled source of boombox volume control v1.3.0

BepInEx/plugins/lcBoomboxVolumeControl.dll

Decompiled 11 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using UnityEngine;
using UnityEngine.InputSystem;
using lcBoomboxVolumeControl.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("lcBoomboxVolumeControl")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("lcBoomboxVolumeControl")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ee191fcb-62c7-4238-bbcb-9c705ab0dc28")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace lcBoomboxVolumeControl
{
	[BepInPlugin("inoyu.lcBoomboxVolumeControl", "BoomboxVolumeControl", "1.0.0")]
	public class BoomboxVolControlMod : BaseUnityPlugin
	{
		private const string modGUID = "inoyu.lcBoomboxVolumeControl";

		private const string modName = "BoomboxVolumeControl";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("inoyu.lcBoomboxVolumeControl");

		private static BoomboxVolControlMod instance;

		internal ManualLogSource mls;

		public static BoomboxVolChangeOnButtonPress InputActionInstance = new BoomboxVolChangeOnButtonPress();

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			mls = Logger.CreateLogSource("inoyu.lcBoomboxVolumeControl");
			mls.LogInfo((object)"mod awake");
			harmony.PatchAll(typeof(BoomboxVolControlMod));
			harmony.PatchAll(typeof(BoomboxVolChangePatch));
		}
	}
}
namespace lcBoomboxVolumeControl.Patches
{
	public class BoomboxVolChangeOnButtonPress : LcInputActions
	{
		[InputAction(/*Could not decode attribute arguments.*/)]
		public InputAction BoomboxVolDownKey { get; set; }

		[InputAction(/*Could not decode attribute arguments.*/)]
		public InputAction BoomboxVolUpKey { get; set; }
	}
	[HarmonyPatch(typeof(BoomboxItem))]
	internal class BoomboxVolChangePatch
	{
		private const float VOLUME_CHANGE_AMOUNT = 0.2f;

		private const float VOLUME_MAX = 1f;

		private const float VOLUME_MIN = 0f;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void volumeDown(ref AudioSource ___boomboxAudio)
		{
			if (BoomboxVolControlMod.InputActionInstance.BoomboxVolDownKey.triggered)
			{
				if (___boomboxAudio.volume > 0f)
				{
					AudioSource obj = ___boomboxAudio;
					obj.volume -= 0.2f;
				}
			}
			else if (BoomboxVolControlMod.InputActionInstance.BoomboxVolUpKey.triggered && ___boomboxAudio.volume < 1f)
			{
				AudioSource obj2 = ___boomboxAudio;
				obj2.volume += 0.2f;
			}
		}
	}
}