using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using On.RoR2; using RiskOfOptions; using RiskOfOptions.Options; using RoR2; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("RoR2MusicNotification")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Mod for Risk of Rain 2")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+e2b882c6986107c3a47882dac2da94066813c791")] [assembly: AssemblyProduct("RoR2MusicNotification")] [assembly: AssemblyTitle("RoR2MusicNotification")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace System.Diagnostics.CodeAnalysis { [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] [ExcludeFromCodeCoverage] [DebuggerNonUserCode] internal sealed class MemberNotNullAttribute : Attribute { public string[] Members { get; } public MemberNotNullAttribute(string member) { Members = new string[1] { member }; } public MemberNotNullAttribute(params string[] members) { Members = members; } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] [ExcludeFromCodeCoverage] [DebuggerNonUserCode] internal sealed class MemberNotNullWhenAttribute : Attribute { public bool ReturnValue { get; } public string[] Members { get; } public MemberNotNullWhenAttribute(bool returnValue, string member) { ReturnValue = returnValue; Members = new string[1] { member }; } public MemberNotNullWhenAttribute(bool returnValue, params string[] members) { ReturnValue = returnValue; Members = members; } } } namespace RoR2MusicNotification { internal class Data { public static Dictionary trackNames = new Dictionary { { "muBossfightDLC1_10", "Having Fallen, It Was Blood" }, { "muBossfightDLC1_12", "A Boat Made from a Sheet of Newspaper" }, { "muEscape", "Escape (Unnamed Track)" }, { "muFULLSong02", "Into the Doldrums" }, { "muFULLSong06", "Nocturnal Emission" }, { "muFULLSong07", "Evapotranspiration" }, { "muFULLSong18", "Disdrometer" }, { "muFULLSong19", "Terra Pluviam" }, { "muGameplayBase_09", "They Might As Well Be Dead" }, { "muGameplayDLC1_01", "Once in a Lullaby" }, { "muGameplayDLC1_03", "Out of Whose Womb Came the Ice?" }, { "muGameplayDLC1_06", "Who Can Fathom the Soundless Depths?" }, { "muGameplayDLC1_08", "A Placid Island of Ignorance" }, { "muIntroCutscene", "Through a Cloud, Darkly" }, { "muLogbook", "The Dehydration of Risk of Rain 2" }, { "muMainEndingFull", "Lacrimosum" }, { "muMainEndingOutroA", "Lacrimosum" }, { "muMainEndingOutroB", "Lacrimosum" }, { "muMenu", "Risk of Rain 2" }, { "muMenuDLC1", "Prelude in D flat major" }, { "muNone", "" }, { "muRaidfightDLC1_07", "The Face of the Deep" }, { "muSong04", "Parjanya" }, { "muSong05", "Thermodynamic Equilibrium" }, { "muSong08", "A Glacier Eventually Farts (And Don't You Listen to the Song of Life)" }, { "muSong13", "The Raindrop that Fell to the Sky" }, { "muSong14", "The Rain Formerly Known as Purple" }, { "muSong16", "Hydrophobia" }, { "muSong21", "Petrichor V" }, { "muSong22", "Köppen As Fuck" }, { "muSong23", "Antarctic Oscillation" }, { "muSong24", "...con lentitud poderosa" }, { "muSong25", "You're Gonna Need A Bigger Ukulele" }, { "muSong_Habitat", "Om Mani Padme Hum, part II" }, { "muSong_HelminthBoss", "Tlalocan" }, { "muSong_HelminthRoost", "屋根の漏り (Yane No Mori)" }, { "muSong_Lakes&HabitatBoss", "A Tempestuous Noise of Thunder and Lightning Heard" }, { "muSong_LakesGameplay", "It Can't Rain All the Time" }, { "muSong_LemurianTemple", "Om Mani Padme Hum, part III" }, { "muSong_LemurianTempleBoss", "Forgot the Cry of Gulls" }, { "muSong_Meridian", "Om Mani Padme Hum, part I" }, { "muSong_MeridianFSB", "Om Mani Padme Hum, part I" }, { "muSong_Village", "I Should Build the Man a Statue" }, { "muSong_VillageBoss", "Forgot the Cry of Gulls" }, { "muGameplayDLC3_01_SH_Map", "Mistery" }, { "muGameplayDLC3_02_P_Map", "Swamplified Mizzle" }, { "muGameplayDLC3_03_IA_Map", "Mine Your Drone Business!" }, { "muGameplayDLC3_04_RC_Map", "Reign of hrisC" }, { "muGameplayDLC3_05_CE_Map", "Even Strong Swimmers Can Drone" }, { "muGameplayDLC3_06_CC_Map", "We’ll Rain Together" }, { "muGameplayDLC3_07_RC_Boss", "A Torrent That Can't Be Downloaded" }, { "muGameplayDLC3_08_RMX_SolHeart_Boss", "Heav’n Flies Before the Machine Soul (BT)" }, { "muGameplayDLC3_08_SH_Boss", "Deluge ional" } }; public static Dictionary trackAuthors = new Dictionary { { "muBossfightDLC1_10", "Chris Christodoulou" }, { "muBossfightDLC1_12", "Chris Christodoulou" }, { "muEscape", "Chris Christodoulou" }, { "muFULLSong02", "Chris Christodoulou" }, { "muFULLSong06", "Chris Christodoulou" }, { "muFULLSong07", "Chris Christodoulou" }, { "muFULLSong18", "Chris Christodoulou" }, { "muFULLSong19", "Chris Christodoulou" }, { "muGameplayBase_09", "Chris Christodoulou" }, { "muGameplayDLC1_01", "Chris Christodoulou" }, { "muGameplayDLC1_03", "Chris Christodoulou" }, { "muGameplayDLC1_06", "Chris Christodoulou" }, { "muGameplayDLC1_08", "Chris Christodoulou" }, { "muGameplayDLC3_01_SH_Map", "Stavros Markonis" }, { "muGameplayDLC3_02_P_Map", "Stavros Markonis" }, { "muGameplayDLC3_03_IA_Map", "Stavros Markonis" }, { "muGameplayDLC3_04_RC_Map", "Stavros Markonis" }, { "muGameplayDLC3_05_CE_Map", "Stavros Markonis" }, { "muGameplayDLC3_06_CC_Map", "Stavros Markonis" }, { "muGameplayDLC3_07_RC_Boss", "Stavros Markonis" }, { "muGameplayDLC3_08_RMX_SolHeart_Boss", "Stavros Markonis" }, { "muGameplayDLC3_08_SH_Boss", "Stavros Markonis" }, { "muIntroCutscene", "Chris Christodoulou" }, { "muLogbook", "Chris Christodoulou" }, { "muMainEndingFull", "Chris Christodoulou" }, { "muMainEndingOutroA", "Chris Christodoulou" }, { "muMainEndingOutroB", "Chris Christodoulou" }, { "muMenu", "Chris Christodoulou" }, { "muMenuDLC1", "Chris Christodoulou" }, { "muNone", "Chris Christodoulou" }, { "muRaidfightDLC1_07", "Chris Christodoulou" }, { "muSong_Habitat", "Chris Christodoulou" }, { "muSong_HelminthBoss", "Chris Christodoulou" }, { "muSong_HelminthRoost", "Chris Christodoulou" }, { "muSong_Lakes&HabitatBoss", "Chris Christodoulou" }, { "muSong_LakesGameplay", "Chris Christodoulou" }, { "muSong_LemurianTemple", "Chris Christodoulou" }, { "muSong_LemurianTempleBoss", "Chris Christodoulou" }, { "muSong_Meridian", "Chris Christodoulou" }, { "muSong_MeridianFSB", "Chris Christodoulou" }, { "muSong_Village", "Stavros Markonis" }, { "muSong_VillageBoss", "Chris Christodoulou" }, { "muSong04", "Chris Christodoulou" }, { "muSong05", "Chris Christodoulou" }, { "muSong08", "Chris Christodoulou" }, { "muSong13", "Chris Christodoulou" }, { "muSong14", "Chris Christodoulou" }, { "muSong16", "Chris Christodoulou" }, { "muSong21", "Chris Christodoulou" }, { "muSong22", "Chris Christodoulou" }, { "muSong23", "Chris Christodoulou" }, { "muSong24", "Chris Christodoulou" }, { "muSong25", "Chris Christodoulou" } }; } internal class ModConfig { public static ConfigEntry cfgXHeight; public static ConfigEntry cfgYHeight; public static ConfigEntry cfgScale; public static ConfigEntry cfgTextAlignment; public static void Initialize(ConfigFile config) { cfgXHeight = config.Bind("Display", "Position X", 810, ""); cfgYHeight = config.Bind("Display", "Position Y", -200, ""); cfgScale = config.Bind("Display", "Scale Multiplier", 1f, ""); cfgTextAlignment = config.Bind("Display", "Text Alignment", (HorizontalAlignmentOptions)4, ""); cfgXHeight.SettingChanged += CfgXHeight_SettingChanged; cfgYHeight.SettingChanged += CfgYHeight_SettingChanged; cfgScale.SettingChanged += CfgScale_SettingChanged; cfgTextAlignment.SettingChanged += CfgTextAlignment_SettingChanged; if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions")) { ModSupport_RiskOfOptions.Initialize(); } } private static void CfgTextAlignment_SettingChanged(object sender, EventArgs e) { Plugin.SetNotifAlignment(); } private static void CfgScale_SettingChanged(object sender, EventArgs e) { Plugin.SetNotifScale(); } private static void CfgYHeight_SettingChanged(object sender, EventArgs e) { Plugin.SetNotifPosition(); } private static void CfgXHeight_SettingChanged(object sender, EventArgs e) { Plugin.SetNotifPosition(); } } internal class ModSupport_RiskOfOptions { [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void Initialize() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown ModSettingsManager.SetModDescription("Adds a persistent music notification.", "com.DestroyedClone.MusicDisplay", "Music Display"); ModSettingsManager.AddOption((BaseOption)new IntFieldOption(ModConfig.cfgXHeight, false)); ModSettingsManager.AddOption((BaseOption)new IntFieldOption(ModConfig.cfgYHeight, false)); ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ModConfig.cfgScale, false)); ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)ModConfig.cfgTextAlignment, false)); } } [BepInPlugin("com.DestroyedClone.MusicDisplay", "Music Display", "1.0.3")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private class FadeOutText : MonoBehaviour { public float stopwatch = 0f; public float fadeDuration = 0f; public HGTextMeshProUGUI textMesh; public void Update() { stopwatch += Time.deltaTime; if (!(stopwatch > fadeDuration)) { } } } public static MusicController musicController; public static GameObject notif; public static HGTextMeshProUGUI notifTextMesh; public static GameObject ReferenceGameObject; public static bool canLoad = false; public static string currentlyPlaying = string.Empty; public void Awake() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) ModConfig.Initialize(((BaseUnityPlugin)this).Config); MusicTrackDef.Play += new hook_Play(MusicTrackDef_Play); AsyncOperationHandle val = Addressables.LoadAssetAsync((object)"RoR2/Base/UI/CreditsPanel/HGCreditNameLabel.prefab"); val.Completed += delegate(AsyncOperationHandle obj) { ReferenceGameObject = obj.Result; }; RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnLoad)); } private void OnLoad() { canLoad = true; CreateDisplay(); } private void MusicTrackDef_Play(orig_Play orig, MusicTrackDef self) { orig.Invoke(self); currentlyPlaying = self.cachedName; CreateDisplay(); } private static void CreateDisplay() { if (!canLoad) { return; } if (!Object.op_Implicit((Object)(object)notif)) { Canvas userCanvas = AchievementNotificationPanel.GetUserCanvas(LocalUserManager.GetFirstLocalUser()); if (!Object.op_Implicit((Object)(object)userCanvas)) { return; } notif = Object.Instantiate(ReferenceGameObject); notif.transform.parent = ((Component)userCanvas).transform; ((Object)notif).name = "MusicNameDisplay"; } notifTextMesh = notif.GetComponent(); ((TMP_Text)notifTextMesh).text = GetTrackInfo(currentlyPlaying); SetNotifAlignment(); SetNotifPosition(); SetNotifScale(); } public static void SetNotifAlignment() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)notifTextMesh) && canLoad) { ((TMP_Text)notifTextMesh).horizontalAlignment = ModConfig.cfgTextAlignment.Value; } } public static void SetNotifPosition() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)notif) && canLoad) { notif.transform.localPosition = new Vector3((float)ModConfig.cfgXHeight.Value, (float)ModConfig.cfgYHeight.Value); } } public static void SetNotifScale() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)notif) && canLoad) { notif.transform.localScale = Vector3.one * ModConfig.cfgScale.Value; } } public static string GetTrackInfo(string trackDefName) { if (Data.trackNames.TryGetValue(trackDefName, out var value)) { if (1 == 0) { } string result = ((!(trackDefName == "muNone")) ? (value + "\n" + Data.trackAuthors.GetValueOrDefault(trackDefName)) : string.Empty); if (1 == 0) { } return result; } return trackDefName; } } }