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 DanceMusic v1.0.0
plugins/DanceMusic/dancemod1.dll
Decompiled a day agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("dancemod1")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("dancemod1")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("a9b992e2-0fe7-47f7-9404-422503a02c94")] [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 DanceMod_valheim; [BepInPlugin("com.viktor.dancemusic", "Dance Music", "0.7.0")] public class DanceMusicPlugin : BaseUnityPlugin { internal static DanceMusicPlugin Instance; private const string HaldorClipName = "Black Forest - Haldor"; private const float FadeSpeed = 0.4f; private const float HaldorTargetVolume = 1f; private AudioSource _haldorSource; private AudioSource _biomeMusicSource; private AudioClip _haldorClip; private bool _danceMusicActive; private bool _fadingOut; private bool _biomeMusicPaused; private void Awake() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown Instance = this; Harmony val = new Harmony("com.viktor.dancemusic"); val.PatchAll(); CreateHaldorMusicSource(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Dance Music 0.7.0 успешно загрузился."); } private void CreateHaldorMusicSource() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown if (!((Object)(object)_haldorSource != (Object)null)) { GameObject val = new GameObject("DanceMusic_Haldor"); Object.DontDestroyOnLoad((Object)(object)val); _haldorSource = val.AddComponent<AudioSource>(); _haldorSource.playOnAwake = false; _haldorSource.loop = true; _haldorSource.spatialBlend = 0f; _haldorSource.volume = 0f; } } private void Update() { if (!_danceMusicActive || (Object)(object)_haldorSource == (Object)null) { return; } if (_fadingOut) { _haldorSource.volume = Mathf.MoveTowards(_haldorSource.volume, 0f, 0.4f * Time.deltaTime); if (_haldorSource.volume <= 0.001f) { FinishDanceMusic(); } return; } _haldorSource.volume = Mathf.MoveTowards(_haldorSource.volume, 1f, 0.4f * Time.deltaTime); if ((Object)(object)_biomeMusicSource != (Object)null && _biomeMusicSource.isPlaying) { _biomeMusicSource.Pause(); _biomeMusicPaused = true; } } internal void StartDanceMusic() { if (_danceMusicActive && !_fadingOut) { return; } if ((Object)(object)_haldorSource == (Object)null) { CreateHaldorMusicSource(); } if ((Object)(object)_haldorClip == (Object)null) { _haldorClip = FindHaldorClip(); } if ((Object)(object)_haldorClip == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Не найден аудиоклип: Black Forest - Haldor"); return; } FindBiomeMusicSource(); PauseBiomeMusic(); if ((Object)(object)MusicMan.instance != (Object)null) { _haldorSource.outputAudioMixerGroup = MusicMan.instance.m_musicMixer; } _danceMusicActive = true; _fadingOut = false; if ((Object)(object)_haldorSource.clip != (Object)(object)_haldorClip) { _haldorSource.clip = _haldorClip; } if (!_haldorSource.isPlaying) { _haldorSource.volume = 0f; _haldorSource.Play(); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Танец начался. Музыка биома поставлена на паузу, включаем музыку Хальдора."); } internal void StopDanceMusic() { if (_danceMusicActive && !_fadingOut) { _fadingOut = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Танец закончился. Музыка Хальдора плавно затихает."); } } private void FinishDanceMusic() { _haldorSource.volume = 0f; _haldorSource.Stop(); ResumeBiomeMusic(); _danceMusicActive = false; _fadingOut = false; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Музыка Хальдора остановлена. Музыка биома продолжена."); } private void FindBiomeMusicSource() { _biomeMusicSource = null; if ((Object)(object)MusicMan.instance == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"MusicMan ещё не создан."); return; } _biomeMusicSource = Traverse.Create((object)MusicMan.instance).Field("m_musicSource").GetValue<AudioSource>(); if ((Object)(object)_biomeMusicSource == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Источник музыки биома не найден."); return; } string text = (((Object)(object)_biomeMusicSource.clip != (Object)null) ? ((Object)_biomeMusicSource.clip).name : "<клип отсутствует>"); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Найдена музыка биома: " + text)); } private void PauseBiomeMusic() { if (!((Object)(object)_biomeMusicSource == (Object)null)) { _biomeMusicSource.Pause(); _biomeMusicPaused = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Музыка биома поставлена на паузу."); } } private void ResumeBiomeMusic() { if (!((Object)(object)_biomeMusicSource == (Object)null) && _biomeMusicPaused) { _biomeMusicSource.UnPause(); _biomeMusicPaused = false; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Музыка биома снята с паузы."); } } private AudioClip FindHaldorClip() { AudioClip[] array = Resources.FindObjectsOfTypeAll<AudioClip>(); AudioClip[] array2 = array; foreach (AudioClip val in array2) { if (!((Object)(object)val == (Object)null) && string.Equals(((Object)val).name, "Black Forest - Haldor", StringComparison.Ordinal)) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Найден аудиоклип Хальдора: " + ((Object)val).name)); return val; } } return null; } private void OnDestroy() { ResumeBiomeMusic(); if ((Object)(object)_haldorSource != (Object)null) { _haldorSource.Stop(); Object.Destroy((Object)(object)((Component)_haldorSource).gameObject); } Instance = null; } } [HarmonyPatch(typeof(Player), "StartEmote", new Type[] { typeof(string), typeof(bool) })] internal static class PlayerStartEmotePatch { private static void Postfix(Player __instance, string emote, bool __result) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && __result && string.Equals(emote, "dance", StringComparison.OrdinalIgnoreCase)) { DanceMusicPlugin.Instance?.StartDanceMusic(); } } } [HarmonyPatch(typeof(Player), "StopEmote")] internal static class PlayerStopEmotePatch { private static void Postfix(Player __instance) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { DanceMusicPlugin.Instance?.StopDanceMusic(); } } }