using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("Buglemusic")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Buglemusic")]
[assembly: AssemblyTitle("Buglemusic")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 Buglemusic
{
public static class Bugle
{
private const string FolderName = "bugle";
private static readonly string[] Extensions = new string[6] { ".ogg", ".wav", ".mp3", ".aif", ".aiff", ".m4a" };
public static readonly List<AudioClip> Clips = new List<AudioClip>();
public static readonly List<string> ClipNames = new List<string>();
private static readonly List<float> ClipVolumes = new List<float>();
public static bool Logged;
public static int CurrentClipIndex = 0;
private static MethodInfo _getDataMethod;
private static PropertyInfo _samplesProperty;
private static PropertyInfo _channelsProperty;
private static bool _reflectionInitialized;
private static void InitReflection()
{
if (!_reflectionInitialized)
{
Type typeFromHandle = typeof(AudioClip);
_getDataMethod = typeFromHandle.GetMethod("GetData", new Type[2]
{
typeof(float[]),
typeof(int)
});
_samplesProperty = typeFromHandle.GetProperty("samples");
_channelsProperty = typeFromHandle.GetProperty("channels");
if (_getDataMethod != null)
{
_ = _samplesProperty != null;
}
_reflectionInitialized = true;
}
}
public static void Load(string modFolder)
{
try
{
InitReflection();
Clips.Clear();
ClipNames.Clear();
ClipVolumes.Clear();
CurrentClipIndex = 0;
HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
List<string> list = new List<string>();
if (Directory.Exists(modFolder))
{
string[] extensions = Extensions;
foreach (string text in extensions)
{
list.AddRange(Directory.GetFiles(modFolder, "*." + text.TrimStart(new char[1] { '.' }), SearchOption.TopDirectoryOnly));
}
}
string path = Path.Combine(modFolder, "bugle");
if (Directory.Exists(path))
{
string[] extensions = Extensions;
foreach (string text2 in extensions)
{
list.AddRange(Directory.GetFiles(path, "*." + text2.TrimStart(new char[1] { '.' }), SearchOption.TopDirectoryOnly));
}
}
foreach (string item in list)
{
string fileName = Path.GetFileName(item);
if (hashSet.Add(fileName))
{
LoadClip(item);
}
}
if (Clips.Count > 0)
{
Logged = true;
}
else if (!Logged)
{
Logged = true;
}
}
catch (Exception ex)
{
if (!Logged)
{
Plugin.Log.LogError((object)("Failed to load clips: " + ex.Message));
Logged = true;
}
}
}
private static void LoadClip(string path)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
try
{
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path);
WWW val = new WWW("file://" + path.Replace("\\", "/"));
while (!val.isDone)
{
}
if (val.error != null)
{
val.Dispose();
return;
}
AudioClip audioClip = val.GetAudioClip(false);
if ((Object)(object)audioClip != (Object)null)
{
((Object)audioClip).name = fileNameWithoutExtension;
float item = (Config.Instance.EnableAutoBalance ? CalculateVolume(audioClip) : 1f);
Clips.Add(audioClip);
ClipNames.Add(fileNameWithoutExtension);
ClipVolumes.Add(item);
}
val.Dispose();
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("Error loading clip " + path + ": " + ex.Message));
}
}
private static float CalculateVolume(AudioClip clip)
{
if (_getDataMethod != null && _samplesProperty != null)
{
try
{
int num = (int)_samplesProperty.GetValue(clip, null);
if (num > 0)
{
float[] array = new float[Mathf.Min(num, Config.Instance.SampleLimit)];
_getDataMethod.Invoke(clip, new object[2] { array, 0 });
float num2 = 0f;
float num3 = 0f;
for (int i = 0; i < array.Length; i++)
{
float num4 = Mathf.Abs(array[i]);
if (num4 > num3)
{
num3 = num4;
}
num2 += array[i] * array[i];
}
float num5 = Mathf.Sqrt(num2 / (float)array.Length);
float rmsWeight = Config.Instance.RmsWeight;
float num6 = 1f - rmsWeight;
float targetLoudness = Config.Instance.TargetLoudness;
float num7 = num5 * rmsWeight + num3 * num6;
return Mathf.Clamp((num7 > 0.001f) ? (targetLoudness / num7) : 1f, 0.1f, Config.Instance.MaxVolumeBoost);
}
}
catch
{
}
}
return 1f;
}
public static void NextClip()
{
if (Clips.Count > 0)
{
CurrentClipIndex = (CurrentClipIndex + 1) % Clips.Count;
}
}
public static void PrevClip()
{
if (Clips.Count > 0)
{
CurrentClipIndex = (CurrentClipIndex - 1 + Clips.Count) % Clips.Count;
}
}
public static string GetClipName()
{
if (ClipNames.Count == 0)
{
return "Unknown";
}
int num = CurrentClipIndex % ClipNames.Count;
if (num < 0)
{
num += ClipNames.Count;
}
return ClipNames[num];
}
public static float GetCurrentVolume()
{
if (ClipVolumes.Count == 0)
{
return 1f;
}
int num = CurrentClipIndex % ClipVolumes.Count;
if (num < 0)
{
num += ClipVolumes.Count;
}
return ClipVolumes[num];
}
public static void Apply(BugleSFX sfx)
{
if ((Object)(object)sfx == (Object)null || Clips.Count == 0)
{
return;
}
try
{
int num = CurrentClipIndex % Clips.Count;
if (num < 0)
{
num += Clips.Count;
}
if (sfx.bugle != null && sfx.bugle.Length != 0)
{
for (int i = 0; i < sfx.bugle.Length; i++)
{
sfx.bugle[i] = Clips[num];
}
}
else
{
sfx.bugle = (AudioClip[])(object)new AudioClip[1] { Clips[num] };
}
if ((Object)(object)sfx.bugleEnd != (Object)null)
{
sfx.bugleEnd.clip = Clips[num];
sfx.bugleEnd.loop = Config.Instance.EnableLoop;
}
if ((Object)(object)sfx.buglePlayer != (Object)null)
{
sfx.buglePlayer.clip = Clips[num];
sfx.buglePlayer.loop = Config.Instance.EnableLoop;
}
ApplyVolume(sfx);
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("Failed to apply clips: " + ex.Message));
}
}
public static void SwitchClip(BugleSFX sfx)
{
if ((Object)(object)sfx == (Object)null || Clips.Count == 0)
{
return;
}
try
{
int num = CurrentClipIndex % Clips.Count;
if (num < 0)
{
num += Clips.Count;
}
if (sfx.bugle != null && sfx.bugle.Length != 0)
{
for (int i = 0; i < sfx.bugle.Length; i++)
{
sfx.bugle[i] = Clips[num];
}
}
if ((Object)(object)sfx.buglePlayer != (Object)null)
{
sfx.buglePlayer.clip = Clips[num];
sfx.buglePlayer.loop = Config.Instance.EnableLoop;
if (sfx.hold && !sfx.isProp)
{
sfx.buglePlayer.Play();
}
}
if ((Object)(object)sfx.bugleEnd != (Object)null)
{
sfx.bugleEnd.clip = Clips[num];
sfx.bugleEnd.loop = Config.Instance.EnableLoop;
}
ApplyVolume(sfx);
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("Failed to switch clip: " + ex.Message));
}
}
public static void ApplyVolume(BugleSFX sfx)
{
if ((Object)(object)sfx == (Object)null)
{
return;
}
try
{
float num = ((Config.Instance != null) ? Config.Instance.Volume : 1f);
float currentVolume = GetCurrentVolume();
float volume = num * currentVolume;
sfx.volume = volume;
if ((Object)(object)sfx.buglePlayer != (Object)null)
{
sfx.buglePlayer.dopplerLevel = 0f;
if ((Object)(object)sfx.buglePlayer.clip != (Object)null)
{
sfx.buglePlayer.loop = Config.Instance.EnableLoop;
}
}
if ((Object)(object)sfx.bugleEnd != (Object)null)
{
sfx.bugleEnd.dopplerLevel = 0f;
}
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("Failed to apply volume: " + ex.Message));
}
}
}
public static class ClipIndicator
{
private class ClipIndicatorMonoBehaviour : MonoBehaviour
{
private GUIStyle _style;
private GUIStyle _bgStyle;
private Rect _rect;
private Font _font;
private Texture2D _bgTexture;
private GUIContent _cachedContent;
private string _cachedMessage;
private void Awake()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Expected O, but got Unknown
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Expected O, but got Unknown
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Expected O, but got Unknown
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Expected O, but got Unknown
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
_font = Resources.GetBuiltinResource<Font>("Arial.ttf");
_style = new GUIStyle();
_style.font = _font;
_style.fontSize = 32;
_style.normal.textColor = new Color(1f, 1f, 1f, 1f);
_style.alignment = (TextAnchor)4;
_style.fontStyle = (FontStyle)1;
_style.wordWrap = false;
_style.richText = true;
_style.padding = new RectOffset(0, 0, 0, 0);
_bgStyle = new GUIStyle();
_bgStyle.padding = new RectOffset(0, 0, 0, 0);
_bgTexture = new Texture2D(1, 1)
{
hideFlags = (HideFlags)61
};
_bgStyle.normal.background = _bgTexture;
}
private void OnGUI()
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Expected O, but got Unknown
if (_notification == null || Time.time - _notificationTime > _notificationDuration)
{
return;
}
float num = Time.time - _notificationTime;
float num2 = Mathf.Clamp01((_notificationDuration - num) / 0.5f);
if (num < 0.2f)
{
num2 = num / 0.2f;
}
_style.normal.textColor = new Color(1f, 1f, 1f, num2);
_bgStyle.normal.textColor = new Color(0f, 0f, 0f, num2 * 0.6f);
if (_cachedMessage != _notification)
{
_cachedMessage = _notification;
if (_cachedContent == null)
{
_cachedContent = new GUIContent();
}
_cachedContent.text = _notification;
}
Vector2 val = _style.CalcSize(_cachedContent);
float num3 = val.x + 20f;
float num4 = val.y + 10f;
float num5 = ((float)Screen.width - num3) / 2f;
float num6 = (float)Screen.height - num4 - 60f;
_rect = new Rect(num5, num6, num3, num4);
GUI.Box(_rect, GUIContent.none, _bgStyle);
GUI.Label(_rect, _notification, _style);
}
}
private static GameObject _gameObject;
private static string _notification;
private static float _notificationTime;
private static float _notificationDuration = 2.5f;
private static bool _initialized;
public static void Initialize()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
if (!_initialized)
{
_gameObject = new GameObject("Buglemusic_ClipIndicator");
_gameObject.AddComponent<ClipIndicatorMonoBehaviour>();
_initialized = true;
}
}
public static void ShowNotification(string message)
{
if (!((Object)(object)_gameObject == (Object)null))
{
_notification = message;
_notificationTime = Time.time;
}
}
}
public class Config
{
private static Config _instance;
private ConfigFile config;
public static Config Instance
{
get
{
if (_instance == null)
{
_instance = new Config();
}
return _instance;
}
}
public float Volume { get; set; }
public float VolumeStep { get; private set; }
public bool EnableLoop { get; private set; }
public bool EnableWheelSwitch { get; private set; }
public bool EnableClipIndicator { get; private set; }
public KeyCode SwitchUpKey { get; private set; }
public KeyCode SwitchDownKey { get; private set; }
public KeyCode VolumeUpKey { get; private set; }
public KeyCode VolumeDownKey { get; private set; }
public bool ApplyToOthers { get; private set; }
public bool EnableAutoBalance { get; private set; }
public float RmsWeight { get; private set; }
public float TargetLoudness { get; private set; }
public float MaxVolumeBoost { get; private set; }
public int SampleLimit { get; private set; }
private Config()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Expected O, but got Unknown
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Expected O, but got Unknown
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Expected O, but got Unknown
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Expected O, but got Unknown
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Expected O, but got Unknown
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Expected O, but got Unknown
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Expected O, but got Unknown
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Expected O, but got Unknown
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Expected O, but got Unknown
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_0281: Expected O, but got Unknown
//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: Expected O, but got Unknown
//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
//IL_02eb: Expected O, but got Unknown
//IL_0316: Unknown result type (might be due to invalid IL or missing references)
//IL_0320: Expected O, but got Unknown
string text = Path.Combine(Paths.ConfigPath, "Buglemusic.cfg");
config = new ConfigFile(text, false);
Volume = config.Bind<float>("Bugle", "Volume", 1f, new ConfigDescription("Base volume 0.0 - 5.0", (AcceptableValueBase)null, Array.Empty<object>())).Value;
VolumeStep = config.Bind<float>("Bugle", "VolumeStep", 0.1f, new ConfigDescription("Volume adjustment step 0.01 - 0.5", (AcceptableValueBase)null, Array.Empty<object>())).Value;
EnableLoop = config.Bind<bool>("Bugle", "EnableLoop", true, new ConfigDescription("Loop audio clips when they end", (AcceptableValueBase)null, Array.Empty<object>())).Value;
EnableWheelSwitch = config.Bind<bool>("Bugle", "EnableWheelSwitch", false, new ConfigDescription("Use mouse wheel to switch clips while holding bugle", (AcceptableValueBase)null, Array.Empty<object>())).Value;
EnableClipIndicator = config.Bind<bool>("Bugle", "EnableClipIndicator", true, new ConfigDescription("Show notification when switching clips or volume", (AcceptableValueBase)null, Array.Empty<object>())).Value;
SwitchUpKey = config.Bind<KeyCode>("Bugle", "SwitchUpKey", (KeyCode)275, new ConfigDescription("Key to switch to next clip", (AcceptableValueBase)null, Array.Empty<object>())).Value;
SwitchDownKey = config.Bind<KeyCode>("Bugle", "SwitchDownKey", (KeyCode)276, new ConfigDescription("Key to switch to previous clip", (AcceptableValueBase)null, Array.Empty<object>())).Value;
VolumeUpKey = config.Bind<KeyCode>("Bugle", "VolumeUpKey", (KeyCode)273, new ConfigDescription("Key to increase volume", (AcceptableValueBase)null, Array.Empty<object>())).Value;
VolumeDownKey = config.Bind<KeyCode>("Bugle", "VolumeDownKey", (KeyCode)274, new ConfigDescription("Key to decrease volume", (AcceptableValueBase)null, Array.Empty<object>())).Value;
ApplyToOthers = config.Bind<bool>("Bugle", "ApplyToOthers", true, new ConfigDescription("Apply to other players' bugles too", (AcceptableValueBase)null, Array.Empty<object>())).Value;
EnableAutoBalance = config.Bind<bool>("AutoBalance", "EnableAutoBalance", true, new ConfigDescription("Enable automatic volume normalization between clips", (AcceptableValueBase)null, Array.Empty<object>())).Value;
RmsWeight = config.Bind<float>("AutoBalance", "RmsWeight", 0.6f, new ConfigDescription("RMS weight in mixed loudness (0.0-1.0, higher = average loudness, lower = peak sensitivity)", (AcceptableValueBase)null, Array.Empty<object>())).Value;
TargetLoudness = config.Bind<float>("AutoBalance", "TargetLoudness", 0.25f, new ConfigDescription("Target loudness level (0.01-1.0, higher = louder)", (AcceptableValueBase)null, Array.Empty<object>())).Value;
MaxVolumeBoost = config.Bind<float>("AutoBalance", "MaxVolumeBoost", 2.5f, new ConfigDescription("Maximum volume boost multiplier (1.0-5.0)", (AcceptableValueBase)null, Array.Empty<object>())).Value;
SampleLimit = config.Bind<int>("AutoBalance", "SampleLimit", 100000, new ConfigDescription("Max samples to analyze per clip (1000-500000, lower = faster but less accurate)", (AcceptableValueBase)null, Array.Empty<object>())).Value;
}
}
[HarmonyPatch(typeof(BugleSFX), "Start")]
public static class PatchBugleStart
{
public static void Postfix(BugleSFX __instance)
{
try
{
Bugle.Apply(__instance);
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("PatchBugleStart error: " + ex.Message));
}
}
}
[HarmonyPatch(typeof(BugleSFX), "Update")]
public static class PatchBugleVolume
{
private static float _currentVolume = -1f;
private static FieldInfo _itemField;
private static PropertyInfo _holderCharProp;
private static PropertyInfo _isMineProp;
private static bool _reflectionInit;
private static void InitReflection()
{
if (_reflectionInit)
{
return;
}
_itemField = typeof(BugleSFX).GetField("item", BindingFlags.Instance | BindingFlags.NonPublic);
if (_itemField != null)
{
_holderCharProp = _itemField.FieldType.GetProperty("holderCharacter", BindingFlags.Instance | BindingFlags.Public);
if (_holderCharProp != null)
{
_isMineProp = _holderCharProp.PropertyType.GetProperty("IsMine", BindingFlags.Instance | BindingFlags.Public);
}
}
_reflectionInit = true;
}
private static bool IsHoldingBugle(BugleSFX sfx)
{
InitReflection();
if (_itemField == null || _holderCharProp == null)
{
return false;
}
object value = _itemField.GetValue(sfx);
if (value == null)
{
return false;
}
object value2 = _holderCharProp.GetValue(value, null);
if (value2 == null)
{
return false;
}
if (_isMineProp != null)
{
return (bool)_isMineProp.GetValue(value2, null);
}
return true;
}
public static void Prefix(BugleSFX __instance)
{
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
try
{
if (__instance.isProp)
{
return;
}
if (!__instance.hold && (Object)(object)__instance.buglePlayer != (Object)null && __instance.buglePlayer.isPlaying && __instance.buglePlayer.volume < 0.01f)
{
__instance.buglePlayer.Stop();
}
float num = Config.Instance.Volume * Bugle.GetCurrentVolume();
if (Mathf.Abs(num - _currentVolume) > 0.001f)
{
__instance.volume = num;
_currentVolume = num;
}
if (!((MonoBehaviourPun)__instance).photonView.IsMine || !IsHoldingBugle(__instance))
{
return;
}
if (Config.Instance.EnableWheelSwitch)
{
float axis = Input.GetAxis("Mouse ScrollWheel");
if (axis > 0f)
{
Bugle.NextClip();
Bugle.SwitchClip(__instance);
_currentVolume = -1f;
if (Config.Instance.EnableClipIndicator)
{
ClipIndicator.ShowNotification("♪ " + Bugle.GetClipName());
}
}
else if (axis < 0f)
{
Bugle.PrevClip();
Bugle.SwitchClip(__instance);
_currentVolume = -1f;
if (Config.Instance.EnableClipIndicator)
{
ClipIndicator.ShowNotification("♬ " + Bugle.GetClipName());
}
}
}
if (Input.GetKeyDown(Config.Instance.SwitchUpKey))
{
Bugle.NextClip();
Bugle.SwitchClip(__instance);
_currentVolume = -1f;
if (Config.Instance.EnableClipIndicator)
{
ClipIndicator.ShowNotification("♪ " + Bugle.GetClipName());
}
}
else if (Input.GetKeyDown(Config.Instance.SwitchDownKey))
{
Bugle.PrevClip();
Bugle.SwitchClip(__instance);
_currentVolume = -1f;
if (Config.Instance.EnableClipIndicator)
{
ClipIndicator.ShowNotification("♬ " + Bugle.GetClipName());
}
}
if (Input.GetKeyDown(Config.Instance.VolumeUpKey))
{
AdjustVolume(__instance, Config.Instance.VolumeStep);
}
else if (Input.GetKeyDown(Config.Instance.VolumeDownKey))
{
AdjustVolume(__instance, 0f - Config.Instance.VolumeStep);
}
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("PatchBugleVolume error: " + ex.Message));
}
}
private static void AdjustVolume(BugleSFX sfx, float delta)
{
float num = Config.Instance.Volume + delta;
num = Mathf.Clamp(num, 0f, 5f);
Config.Instance.Volume = num;
_currentVolume = -1f;
if (Config.Instance.EnableClipIndicator)
{
int num2 = (int)Mathf.Round(num * 100f);
ClipIndicator.ShowNotification($"\ud83d\udd0a {num2}%");
}
}
}
[BepInPlugin("Buglemusic", "Buglemusic", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
internal static Harmony harmony;
internal static Plugin Instance { get; private set; }
private void Awake()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
harmony = new Harmony("Buglemusic");
Bugle.Load(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
ClipIndicator.Initialize();
harmony.PatchAll();
}
}
}