Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of MushVolume v1.0.0
BepInEx/plugins/BetterVolume.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using GameNetcodeStuff; using HarmonyLib; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using VolumeControllers; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("BetterVolume")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BetterVolume")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("65268603-6af7-4666-a277-d6c869c43e71")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace VolumeController.Patchers { [HarmonyPatch] internal class ChangeVolumePatchers { internal abstract class AudioPlayerTypeBases { public string name; public List<AudioSource> audioSources; public string originalHoverTip; public float defaultVolume; public float currentVolume; public bool lookingAtDeviceType; public Type objectType; public AudioPlayerTypeBases(string name, string originalHoverTip = "", float defaultVolume = 0f) { this.name = name; audioSources = new List<AudioSource>(); this.originalHoverTip = originalHoverTip; this.defaultVolume = defaultVolume; currentVolume = Plugin.defaultVolume; lookingAtDeviceType = false; } public void UpdateVolumes() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown for (int i = 0; i < audioSources.Count; i++) { if ((Object)audioSources[i] != (Object)null) { audioSources[i].volume = currentVolume / Plugin.maxDisplayedVolume; } } } public abstract void UpdateTooltips2(); } internal class AudioPlayerPlaceableTypes : AudioPlayerTypeBases { public List<InteractTrigger> triggers; public AudioPlayerPlaceableTypes(string name, string originalHoverTip = "", float defaultVolume = 0f) : base(name, originalHoverTip, defaultVolume) { triggers = new List<InteractTrigger>(); } public override void UpdateTooltips2() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown for (int i = 0; i < triggers.Count; i++) { if ((Object)triggers[i] != (Object)null) { triggers[i].hoverTip = $"{originalHoverTip}\n{Mathf.RoundToInt(currentVolume * 10f) * 10}% volume\n{Plugin.volumeHoverTip}"; } } } } private static AudioPlayerPlaceableTypes recordPlayers = new AudioPlayerPlaceableTypes("Record players", "Record player: [E]"); [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPrefix] public static void GetObjectLookingAt(PlayerControllerB __instance) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown recordPlayers.lookingAtDeviceType = false; if (((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled && !__instance.inTerminalMenu && !__instance.isTypingChat && !__instance.isPlayerDead) { InteractTrigger hoveringOverTrigger = __instance.hoveringOverTrigger; object obj; if ((Object)(object)hoveringOverTrigger == (Object)null) { obj = null; } else { Transform parent = ((Component)hoveringOverTrigger).transform.parent; obj = (((Object)(object)parent != (Object)null) ? ((Component)parent).gameObject : null); } GameObject val = (GameObject)obj; if ((Object)val != (Object)null && ((Object)val).name.Contains("RecordPlayer")) { recordPlayers.lookingAtDeviceType = true; } } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] public static void GetVolumeInput(PlayerControllerB __instance) { if (!((NetworkBehaviour)__instance).IsOwner || !__instance.isPlayerControlled || __instance.inTerminalMenu || __instance.isTypingChat || __instance.isPlayerDead || !recordPlayers.lookingAtDeviceType) { return; } float num = 0f; if (((ButtonControl)Keyboard.current.minusKey).wasPressedThisFrame) { num = 0f - Plugin.volumeIncrement; } if (((ButtonControl)Keyboard.current.equalsKey).wasPressedThisFrame) { num = Plugin.volumeIncrement; } if (num != 0f) { Plugin.Log("AdjustVolume: " + num); AudioPlayerTypeBases audioPlayerTypeBases = null; if (recordPlayers.lookingAtDeviceType) { audioPlayerTypeBases = recordPlayers; } if (audioPlayerTypeBases != null) { audioPlayerTypeBases.currentVolume = Mathf.Clamp(audioPlayerTypeBases.currentVolume + num, 0f, Plugin.maxDisplayedVolume); audioPlayerTypeBases.UpdateVolumes(); audioPlayerTypeBases.UpdateTooltips2(); Plugin.Log($"[{audioPlayerTypeBases.name}] Updating volume to: {audioPlayerTypeBases.currentVolume}%"); } } } [HarmonyPatch(typeof(AutoParentToShip), "Awake")] [HarmonyPostfix] public static void SetRecordPlayerHoverTip(AutoParentToShip __instance) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown if (((Object)__instance).name.Contains("RecordPlayerContainer")) { AudioSource val = ((Component)__instance).GetComponentInChildren<AnimatedObjectTrigger>()?.thisAudioSource; if ((Object)val != (Object)null) { recordPlayers.audioSources.Add(val); } InteractTrigger componentInChildren = ((Component)__instance).GetComponentInChildren<InteractTrigger>(); if (recordPlayers.defaultVolume == 0f) { recordPlayers.defaultVolume = val.volume; Plugin.Log("RecordPlayer Volume: " + recordPlayers.defaultVolume); } if ((Object)componentInChildren == (Object)null) { Plugin.Log("Record player trigger missing!"); return; } recordPlayers.triggers.Add(componentInChildren); recordPlayers.UpdateTooltips2(); recordPlayers.UpdateVolumes(); } } } } namespace VolumeControllers { [BepInPlugin("Mush.Volume", "MushVolume", "1.0.3")] public class Plugin : BaseUnityPlugin { public static Plugin instance; private Harmony _harmony; public static Key volumeUpKey = (Key)14; public static Key volumeDownKey = (Key)13; public static string volumeHoverTip = "Volume up: [+]\nVolume down: [-]"; public static float volumeIncrement = 0.1f; public static float maxDisplayedVolume = 1.5f; public static float defaultVolume = 1f; private void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown _harmony = new Harmony("MushVolume"); _harmony.PatchAll(); instance = this; } public static void Log(string message) { } } public static class PluginInfo { public const string PLUGIN_GUID = "MushVolume"; public const string PLUGIN_NAME = "MushVolume"; public const string PLUGIN_VERSION = "1.0.3"; } }