diff --git a/BossChecklistIntegration.cs b/BossChecklistIntegration.cs new file mode 100644 index 0000000..dfadc75 --- /dev/null +++ b/BossChecklistIntegration.cs @@ -0,0 +1,204 @@ +using CalamityModMusic.Items.Placeables; +using System.Collections.Generic; +using Terraria.ModLoader; + +namespace CalamityModMusic +{ + public class BossChecklistIntegration : ModSystem + { + public override void PostSetupContent() + { + Mod calamity = ModLoader.GetMod("CalamityMod"); + Mod bossChecklist = ModLoader.GetMod("BossChecklist"); + + if (calamity != null && bossChecklist != null) + { + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Desert Scourge", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Giant Clam", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Crabulon", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Hive Mind", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "The Perforators", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Slime God", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Cryogen", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Brimstone Elemental", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Aquatic Scourge", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Calamitas", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Leviathan", + new List() { ModContent.ItemType(), ModContent.ItemType() }); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Astrum Aureus", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Plaguebringer Goliath", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Ravager", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Astrum Deus", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Profaned Guardians", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Dragonfolly", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Providence", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Ceaseless Void", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Storm Weaver", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Signus", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Polterghast", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Devourer of Gods", + new List() { ModContent.ItemType(), ModContent.ItemType() }); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Yharon", + new List() { ModContent.ItemType(), ModContent.ItemType() }); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Exo Mechs", + new List() { ModContent.ItemType() }); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Supreme Calamitas", + new List() { ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType() }); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Adult Eidolon Wyrm", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Acid Rain", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Acid Rain (Post-AS)", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Acid Rain (Post-Polter)", + ModContent.ItemType()); + + bossChecklist.Call( + "AddToBossCollection", + calamity.Name, + "Old Duke", + ModContent.ItemType()); + } + } + } +} diff --git a/CalamityModMusic.cs b/CalamityModMusic.cs index 7356a55..00b1b4c 100644 --- a/CalamityModMusic.cs +++ b/CalamityModMusic.cs @@ -1,426 +1,11 @@ -using CalamityModMusic.Items.Placeables; -using CalamityModMusic.Tiles; -using Microsoft.Xna.Framework.Audio; -using MonoMod.Cil; -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Threading; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.ModLoader.Config; -using AbyssLowerMusicbox = CalamityModMusic.Items.Placeables.AbyssLowerMusicbox; -using AdultEidolonWyrmMusicbox = CalamityModMusic.Items.Placeables.AdultEidolonWyrmMusicbox; -using AquaticScourgeMusicbox = CalamityModMusic.Items.Placeables.AquaticScourgeMusicbox; -using AstrageldonMusicbox = CalamityModMusic.Items.Placeables.AstrageldonMusicbox; -using AstralMusicbox = CalamityModMusic.Items.Placeables.AstralMusicbox; -using AstrumDeusMusicbox = CalamityModMusic.Items.Placeables.AstrumDeusMusicbox; -using BossRush1Musicbox = CalamityModMusic.Items.Placeables.BossRushTier1MusicboxItem; -using BossRush2Musicbox = CalamityModMusic.Items.Placeables.BossRushTier2MusicboxItem; -using BossRush3Musicbox = CalamityModMusic.Items.Placeables.BossRushTier3MusicboxItem; -// using BossRush4Musicbox = CalamityModMusic.Items.Placeables.BossRushTier4MusicboxItem; -// using BossRush5Musicbox = CalamityModMusic.Items.Placeables.BossRushTier5MusicboxItem; -using BrimmyMusicbox = CalamityModMusic.Items.Placeables.BrimmyMusicbox; -using BumblebirbMusicbox = CalamityModMusic.Items.Placeables.BumblebirbMusicbox; -using CalamitasMusicbox = CalamityModMusic.Items.Placeables.CalamitasMusicbox; -using CalamityMusicbox = CalamityModMusic.Items.Placeables.CalamityMusicbox; -using CeaselessVoidMusicbox = CalamityModMusic.Items.Placeables.CeaselessVoidMusicbox; -using CrabulonMusicbox = CalamityModMusic.Items.Placeables.CrabulonMusicbox; -using CragMusicbox = CalamityModMusic.Items.Placeables.CragMusicbox; -using CryogenMusicbox = CalamityModMusic.Items.Placeables.CryogenMusicbox; -using DesertScourgeMusicbox = CalamityModMusic.Items.Placeables.DesertScourgeMusicbox; -using DoGMusicbox = CalamityModMusic.Items.Placeables.DoGMusicbox; -using DoGP2Musicbox = CalamityModMusic.Items.Placeables.DoGP2Musicbox; -using ExoMechsMusicbox = CalamityModMusic.Items.Placeables.ExoMechsMusicboxItem; -using HigherAbyssMusicbox = CalamityModMusic.Items.Placeables.HigherAbyssMusicbox; -using HiveMindMusicbox = CalamityModMusic.Items.Placeables.HiveMindMusicbox; -using LeviathanMusicbox = CalamityModMusic.Items.Placeables.LeviathanMusicbox; -using PerforatorMusicbox = CalamityModMusic.Items.Placeables.PerforatorMusicbox; -using PlaguebringerMusicbox = CalamityModMusic.Items.Placeables.PlaguebringerMusicbox; -using PolterghastMusicbox = CalamityModMusic.Items.Placeables.PolterghastMusicbox; -using ProfanedGuardianMusicbox = CalamityModMusic.Items.Placeables.ProfanedGuardianMusicbox; -using ProvidenceMusicbox = CalamityModMusic.Items.Placeables.ProvidenceMusicbox; -using RavagerMusicbox = CalamityModMusic.Items.Placeables.RavagerMusicbox; -using SCalAMusicbox = CalamityModMusic.Items.Placeables.SCalAMusicbox; -using SCalEMusicbox = CalamityModMusic.Items.Placeables.SCalEMusicbox; -using SCalGMusicbox = CalamityModMusic.Items.Placeables.SCalGMusicbox; -using SCalLMusicbox = CalamityModMusic.Items.Placeables.SCalLMusicbox; -using SignusMusicbox = CalamityModMusic.Items.Placeables.SignusMusicbox; -using SirenIdleMusicbox = CalamityModMusic.Items.Placeables.SirenIdleMusicbox; -using SirenMusicbox = CalamityModMusic.Items.Placeables.SirenMusicbox; -using SlimeGodMusicbox = CalamityModMusic.Items.Placeables.SlimeGodMusicbox; -using StormWeaverMusicbox = CalamityModMusic.Items.Placeables.StormWeaverMusicbox; -using SulphurousMusicbox = CalamityModMusic.Items.Placeables.SulphurousMusicbox; -using SunkenSeaMusicbox = CalamityModMusic.Items.Placeables.SunkenSeaMusicbox; -using VoidMusicbox = CalamityModMusic.Items.Placeables.VoidMusicbox; -using Yharon1Musicbox = CalamityModMusic.Items.Placeables.Yharon1Musicbox; -using Yharon2Musicbox = CalamityModMusic.Items.Placeables.Yharon2Musicbox; -using Yharon3Musicbox = CalamityModMusic.Items.Placeables.Yharon3Musicbox; +using Terraria.ModLoader; namespace CalamityModMusic { public class CalamityModMusic : Mod { public static CalamityModMusic Instance; - internal static CalamityMusicConfig Config => CalamityMusicConfig.Instance; - - private bool stopTitleMusic; - private ManualResetEvent titleMusicStopped; - - private int customTitleMusicSlot; - - private void TitleMusicIL(ILContext il) - { - var c = new ILCursor(il); - c.GotoNext(MoveType.After, i => i.MatchLdfld
("newMusic")); - c.EmitDelegate>(newMusic => - newMusic == MusicID.Title ? customTitleMusicSlot : newMusic); - } - - public CalamityModMusic() - { - Instance = this; - } - - public override void Load() - { - if (!Main.dedServ) - { - // Boss Music - Alphabetised. - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/AdultEidolonWyrm"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Anahita"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/AnahitaPreboss"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/AquaticScourge"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/AstrumAureus"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/AstrumDeus"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/BrimstoneElemental"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Calamitas"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Void"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Crabulon"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Cryogen"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/DesertScourge"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/DevourerOfGodsP1"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/DevourerOfGodsP2"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Dragonfolly"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/ExoMechs"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/HiveMind"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/LeviathanAndAnahita"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/BoomerDuke"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Perforators"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/PlaguebringerGoliath"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Polterghast"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Guardians"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Providence"), ModContent.ItemType(), ModContent.TileType()); //Seamless - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Ravager"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/SupremeCalamitas1"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/SupremeCalamitas2"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/SupremeCalamitas3"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/SupremeCalamitas4"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Signus"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/SlimeGod"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Weaver"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/YharonLegacy"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/YharonP1"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/YharonP2"), ModContent.ItemType(), ModContent.TileType()); - - // Biome Music. - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Abyss1"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Abyss2"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Abyss3"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Astral"), ModContent.ItemType(), ModContent.TileType()); //Seamless - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/AstralUnderground"), ModContent.ItemType(), ModContent.TileType()); //Seamless - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Crag"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Calamity"), ModContent.ItemType(), ModContent.TileType()); //Seamless - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/SulphurousSea"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/SunkenSea"), ModContent.ItemType(), ModContent.TileType()); - - // Event Music. - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/AcidRain1"), ModContent.ItemType(), ModContent.TileType()); //Seamless - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/AcidRain2"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/BossRushTier1"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/BossRushTier2"), ModContent.ItemType(), ModContent.TileType()); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/BossRushTier3"), ModContent.ItemType(), ModContent.TileType()); - //AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/BossRushTier4"), ModContent.ItemType(), ModContent.TileType()); - //AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/BossRushTier5"), ModContent.ItemType(), ModContent.TileType()); - - - stopTitleMusic = false; - titleMusicStopped = new ManualResetEvent(false); - } - } - - public override void Unload() - { - IL.Terraria.Main.UpdateAudio -= TitleMusicIL; - customTitleMusicSlot = MusicID.Title; - Close(); - titleMusicStopped?.Set(); - Instance = null; - titleMusicStopped = null; - } - - private void SetTitleMusic() - { - if (Config.ReplaceTitleMusic) - { - customTitleMusicSlot = GetSoundSlot(SoundType.Music, "Sounds/Music/Calamity"); - IL.Terraria.Main.UpdateAudio += TitleMusicIL; - } - } - - public override void PostSetupContent() - { - Mod calamity = ModLoader.GetMod("CalamityMod"); - Mod bossChecklist = ModLoader.GetMod("BossChecklist"); - Mod overhaul = ModLoader.GetMod("TerrariaOverhaul"); - - // Overhaul insists on IL editing Calamity Music Mod to disable our music regardless of player choice in the Calamity music config. - // Since it's not worth fighting over this, just don't register the IL hook if Overhaul is loaded. - // The config notifies players that they cannot hear Calamity title music if Overhaul is enabled. - if(overhaul is null) - SetTitleMusic(); - - if (calamity != null && bossChecklist != null) - { - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Desert Scourge", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Giant Clam", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Crabulon", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Hive Mind", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "The Perforators", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Slime God", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Cryogen", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Brimstone Elemental", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Aquatic Scourge", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Calamitas", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Leviathan", - new List() {ModContent.ItemType(), ModContent.ItemType()}); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Astrum Aureus", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Plaguebringer Goliath", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Ravager", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Astrum Deus", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Profaned Guardians", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Dragonfolly", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Providence", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Ceaseless Void", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Storm Weaver", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Signus", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Polterghast", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Devourer of Gods", - new List() {ModContent.ItemType(), ModContent.ItemType()}); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Yharon", - new List() {ModContent.ItemType(), ModContent.ItemType()}); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Exo Mechs", - new List() { ModContent.ItemType() }); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Supreme Calamitas", - new List() {ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType()}); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Adult Eidolon Wyrm", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Acid Rain", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Acid Rain (Post-AS)", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Acid Rain (Post-Polter)", - ModContent.ItemType()); - - bossChecklist.Call( - "AddToBossCollection", - calamity.Name, - "Old Duke", - ModContent.ItemType()); - } - } - - public override void Close() - { - var slot = GetSoundSlot(SoundType.Music, "Sounds/Music/Calamity"); - - if (Main.music.IndexInRange(slot) && Main.music[slot]?.IsPlaying == true) - { - Main.music[slot].Stop(AudioStopOptions.Immediate); - } - base.Close(); - } - - public override void UpdateMusic(ref int music, ref MusicPriority priority) - { - if (stopTitleMusic || (!Main.gameMenu && customTitleMusicSlot != MusicID.Title && Main.ActivePlayerFileData != null && Main.ActiveWorldFileData != null)) - { - if (!stopTitleMusic) - { - music = MusicID.Title; - } - - // prevent our IL hook trying to play the track anymore - // we could just remove our IL hook, but then we'd have to save it in a variable. tML removes it for us anyway - customTitleMusicSlot = MusicID.Title; - - // stop the music if it's playing (which it probably is) - var m = GetMusic("Sounds/Music/Calamity"); - if (m.IsPlaying) - m.Stop(AudioStopOptions.Immediate); - - titleMusicStopped.Set(); - stopTitleMusic = false; - } - } - - public override void PreSaveAndQuit() - { - Mod overhaul = ModLoader.GetMod("TerrariaOverhaul"); - if(overhaul is null) - SetTitleMusic(); - } - - internal static void SaveConfig(CalamityMusicConfig CalamityMusicConfig) - { - // in-game ModConfig saving from mod code is not supported yet in tmodloader, and subject to change, so we need to be extra careful. - // This code only supports client configs, and doesn't call onchanged. It also doesn't support ReloadRequired or anything else. - MethodInfo saveMethodInfo = typeof(ConfigManager).GetMethod("Save", BindingFlags.Static | BindingFlags.NonPublic); - if (saveMethodInfo != null) - saveMethodInfo.Invoke(null, new object[] { CalamityMusicConfig }); - else - Instance.Logger.Warn("In-game SaveConfig failed, code update required"); - } + public CalamityModMusic() => Instance = this; + public override void Unload() => Instance = null; } } diff --git a/CalamityMusicConfig.cs b/CalamityMusicConfig.cs deleted file mode 100644 index 9799964..0000000 --- a/CalamityMusicConfig.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.ComponentModel; -using Terraria.ModLoader.Config; - -namespace CalamityModMusic -{ - [Label("Config")] - [BackgroundColor(49, 32, 36, 216)] - public class CalamityMusicConfig : ModConfig - { - public static CalamityMusicConfig Instance; - public override ConfigScope Mode => ConfigScope.ClientSide; - - [Header("Music Changes")] - - [Label("Replace Title Music")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(true)] - [ReloadRequired] - [Tooltip("Replaces the vanilla Terraria title screen music with 'The Tale of a Cruel World'.\nThis option does nothing if Terraria Overhaul is enabled.\nThis option requires a reload to take effect.")] - public bool ReplaceTitleMusic { get; set; } - - public override bool AcceptClientChanges(ModConfig pendingConfig, int whoAmI, ref string message) => true; - } -} diff --git a/MusicBoxRegistry.cs b/MusicBoxRegistry.cs new file mode 100644 index 0000000..a47f20e --- /dev/null +++ b/MusicBoxRegistry.cs @@ -0,0 +1,127 @@ +using CalamityModMusic.Items.Placeables; +using CalamityModMusic.Tiles; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; +using AbyssLowerMusicbox = CalamityModMusic.Items.Placeables.AbyssLowerMusicbox; +using AdultEidolonWyrmMusicbox = CalamityModMusic.Items.Placeables.AdultEidolonWyrmMusicbox; +using AquaticScourgeMusicbox = CalamityModMusic.Items.Placeables.AquaticScourgeMusicbox; +using AstrageldonMusicbox = CalamityModMusic.Items.Placeables.AstrageldonMusicbox; +using AstralMusicbox = CalamityModMusic.Items.Placeables.AstralMusicbox; +using AstrumDeusMusicbox = CalamityModMusic.Items.Placeables.AstrumDeusMusicbox; +using BossRush1Musicbox = CalamityModMusic.Items.Placeables.BossRushTier1MusicboxItem; +using BossRush2Musicbox = CalamityModMusic.Items.Placeables.BossRushTier2MusicboxItem; +using BossRush3Musicbox = CalamityModMusic.Items.Placeables.BossRushTier3MusicboxItem; +// using BossRush4Musicbox = CalamityModMusic.Items.Placeables.BossRushTier4MusicboxItem; +// using BossRush5Musicbox = CalamityModMusic.Items.Placeables.BossRushTier5MusicboxItem; +using BrimmyMusicbox = CalamityModMusic.Items.Placeables.BrimmyMusicbox; +using BumblebirbMusicbox = CalamityModMusic.Items.Placeables.BumblebirbMusicbox; +using CalamitasMusicbox = CalamityModMusic.Items.Placeables.CalamitasMusicbox; +using CalamityMusicbox = CalamityModMusic.Items.Placeables.CalamityMusicbox; +using CeaselessVoidMusicbox = CalamityModMusic.Items.Placeables.CeaselessVoidMusicbox; +using CrabulonMusicbox = CalamityModMusic.Items.Placeables.CrabulonMusicbox; +using CragMusicbox = CalamityModMusic.Items.Placeables.CragMusicbox; +using CryogenMusicbox = CalamityModMusic.Items.Placeables.CryogenMusicbox; +using DesertScourgeMusicbox = CalamityModMusic.Items.Placeables.DesertScourgeMusicbox; +using DoGMusicbox = CalamityModMusic.Items.Placeables.DoGMusicbox; +using DoGP2Musicbox = CalamityModMusic.Items.Placeables.DoGP2Musicbox; +using ExoMechsMusicbox = CalamityModMusic.Items.Placeables.ExoMechsMusicboxItem; +using HigherAbyssMusicbox = CalamityModMusic.Items.Placeables.HigherAbyssMusicbox; +using HiveMindMusicbox = CalamityModMusic.Items.Placeables.HiveMindMusicbox; +using LeviathanMusicbox = CalamityModMusic.Items.Placeables.LeviathanMusicbox; +using PerforatorMusicbox = CalamityModMusic.Items.Placeables.PerforatorMusicbox; +using PlaguebringerMusicbox = CalamityModMusic.Items.Placeables.PlaguebringerMusicbox; +using PolterghastMusicbox = CalamityModMusic.Items.Placeables.PolterghastMusicbox; +using ProfanedGuardianMusicbox = CalamityModMusic.Items.Placeables.ProfanedGuardianMusicbox; +using ProvidenceMusicbox = CalamityModMusic.Items.Placeables.ProvidenceMusicbox; +using RavagerMusicbox = CalamityModMusic.Items.Placeables.RavagerMusicbox; +using SCalAMusicbox = CalamityModMusic.Items.Placeables.SCalAMusicbox; +using SCalEMusicbox = CalamityModMusic.Items.Placeables.SCalEMusicbox; +using SCalGMusicbox = CalamityModMusic.Items.Placeables.SCalGMusicbox; +using SCalLMusicbox = CalamityModMusic.Items.Placeables.SCalLMusicbox; +using SignusMusicbox = CalamityModMusic.Items.Placeables.SignusMusicbox; +using SirenIdleMusicbox = CalamityModMusic.Items.Placeables.SirenIdleMusicbox; +using SirenMusicbox = CalamityModMusic.Items.Placeables.SirenMusicbox; +using SlimeGodMusicbox = CalamityModMusic.Items.Placeables.SlimeGodMusicbox; +using StormWeaverMusicbox = CalamityModMusic.Items.Placeables.StormWeaverMusicbox; +using SulphurousMusicbox = CalamityModMusic.Items.Placeables.SulphurousMusicbox; +using SunkenSeaMusicbox = CalamityModMusic.Items.Placeables.SunkenSeaMusicbox; +using VoidMusicbox = CalamityModMusic.Items.Placeables.VoidMusicbox; +using Yharon1Musicbox = CalamityModMusic.Items.Placeables.Yharon1Musicbox; +using Yharon2Musicbox = CalamityModMusic.Items.Placeables.Yharon2Musicbox; +using Yharon3Musicbox = CalamityModMusic.Items.Placeables.Yharon3Musicbox; + +namespace CalamityModMusic +{ + public class MusicBoxRegistry : ModSystem + { + private static void AddMusicBox(string musicFile, int itemID, int tileID) + { + int musicID = SoundLoader.GetSoundSlot(CalamityModMusic.Instance, musicFile); + MusicLoader.AddMusicBox(CalamityModMusic.Instance, musicID, itemID, tileID); + } + + public override void Load() + { + if (!Main.dedServ) + { + // Boss Music - Alphabetised. + AddMusicBox("Sounds/Music/AdultEidolonWyrm", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/Anahita", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/AnahitaPreboss", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/AquaticScourge", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/AstrumAureus", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/AstrumDeus", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/BrimstoneElemental", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/Calamitas", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/Void", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/Crabulon", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/Cryogen", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/DesertScourge", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/DevourerOfGodsP1", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/DevourerOfGodsP2", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/Dragonfolly", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/ExoMechs", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/HiveMind", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/LeviathanAndAnahita", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/BoomerDuke", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/Perforators", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/PlaguebringerGoliath", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/Polterghast", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/Guardians", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/Providence", ModContent.ItemType(), ModContent.TileType()); //Seamless + AddMusicBox("Sounds/Music/Ravager", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/SupremeCalamitas1", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/SupremeCalamitas2", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/SupremeCalamitas3", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/SupremeCalamitas4", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/Signus", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/SlimeGod", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/Weaver", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/YharonLegacy", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/YharonP1", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/YharonP2", ModContent.ItemType(), ModContent.TileType()); + + // Biome Music. + AddMusicBox("Sounds/Music/Abyss1", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/Abyss2", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/Abyss3", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/Astral", ModContent.ItemType(), ModContent.TileType()); //Seamless + AddMusicBox("Sounds/Music/AstralUnderground", ModContent.ItemType(), ModContent.TileType()); //Seamless + AddMusicBox("Sounds/Music/Crag", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/Calamity", ModContent.ItemType(), ModContent.TileType()); //Seamless + AddMusicBox("Sounds/Music/SulphurousSea", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/SunkenSea", ModContent.ItemType(), ModContent.TileType()); + + // Event Music. + AddMusicBox("Sounds/Music/AcidRain1", ModContent.ItemType(), ModContent.TileType()); //Seamless + AddMusicBox("Sounds/Music/AcidRain2", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/BossRushTier1", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/BossRushTier2", ModContent.ItemType(), ModContent.TileType()); + AddMusicBox("Sounds/Music/BossRushTier3", ModContent.ItemType(), ModContent.TileType()); + //AddMusicBox("Sounds/Music/BossRushTier4", ModContent.ItemType(), ModContent.TileType()); + //AddMusicBox("Sounds/Music/BossRushTier5", ModContent.ItemType(), ModContent.TileType()); + } + } + } +}