diff --git a/Assets/Music/Ambience/GlowingMushroomGrove.ogg b/Assets/Music/Ambience/GlowingMushroomGrove.ogg deleted file mode 100644 index e7bb6b7..0000000 Binary files a/Assets/Music/Ambience/GlowingMushroomGrove.ogg and /dev/null differ diff --git a/Assets/Music/Ambience/GlowingMushroomFields.ogg b/Assets/Music/Ambience/GlowingMushrooms.ogg similarity index 100% rename from Assets/Music/Ambience/GlowingMushroomFields.ogg rename to Assets/Music/Ambience/GlowingMushrooms.ogg diff --git a/Assets/Music/Biomes/Crimson.ogg b/Assets/Music/Biomes/Crimson.ogg index fd46ed2..7b62153 100644 Binary files a/Assets/Music/Biomes/Crimson.ogg and b/Assets/Music/Biomes/Crimson.ogg differ diff --git a/Assets/Music/Biomes/CrimsonUnderground.ogg b/Assets/Music/Biomes/CrimsonUnderground.ogg index 087d6a7..ba92eed 100644 Binary files a/Assets/Music/Biomes/CrimsonUnderground.ogg and b/Assets/Music/Biomes/CrimsonUnderground.ogg differ diff --git a/Assets/Music/Biomes/GlowingMushroomFields.ogg b/Assets/Music/Biomes/GlowingMushrooms.ogg similarity index 100% rename from Assets/Music/Biomes/GlowingMushroomFields.ogg rename to Assets/Music/Biomes/GlowingMushrooms.ogg diff --git a/Assets/Music/Bosses/BrainofCthulhu.ogg b/Assets/Music/Bosses/BrainofCthulhu.ogg index 1542173..ebbb794 100644 Binary files a/Assets/Music/Bosses/BrainofCthulhu.ogg and b/Assets/Music/Bosses/BrainofCthulhu.ogg differ diff --git a/Common/ModCompatibility/MusicDisplayCompatibility.cs b/Common/ModCompatibility/MusicDisplayCompatibility.cs index e8ef808..fa4e18c 100644 --- a/Common/ModCompatibility/MusicDisplayCompatibility.cs +++ b/Common/ModCompatibility/MusicDisplayCompatibility.cs @@ -41,7 +41,7 @@ namespace UnCalamityModMusic.Common.ModCompatibility AddMusic("ForestDayMorning", "HeartPlusUp", "Biomes"); AddMusic("ForestNight", "HeartPlusUp", "Biomes"); AddMusic("Geodes", "HeartPlusUp", "Biomes"); - AddMusic("GlowingMushroomFields", "HeartPlusUp", "Biomes"); + AddMusic("GlowingMushrooms", "HeartPlusUp", "Biomes"); //AddMusic("Graveyard", "", "Biomes"); //AddMusic("Hallow", "", "Biomes"); //AddMusic("HallowUnderground", "", "Biomes"); diff --git a/Common/Music/AmbienceScenes.cs b/Common/Music/AmbienceScenes.cs index 2822ada..2da99db 100644 --- a/Common/Music/AmbienceScenes.cs +++ b/Common/Music/AmbienceScenes.cs @@ -282,15 +282,13 @@ namespace UnCalamityModMusic.Common.Music public override bool AmbienceCondition(Player player) => MusicFlags.SunkenSea; } - public class GlowingMushroomFields_Ambience : AmbienceSceneBase + public class GlowingMushrooms_Ambience : AmbienceSceneBase { - public override string AmbienceFilePath => - MusicFlags.Underground ? "GlowingMushroomFields" : - "GlowingMushroomGrove"; + public override string AmbienceFilePath => "GlowingMushrooms"; - public override SceneEffectPriority Priority => ModContent.GetInstance().Priority; + public override SceneEffectPriority Priority => ModContent.GetInstance().Priority; - public override bool AmbienceCondition(Player player) => ModContent.GetInstance().IsSceneEffectActive(player); + public override bool AmbienceCondition(Player player) => ModContent.GetInstance().IsSceneEffectActive(player); } public class Corruption_Ambience : AmbienceSceneBase diff --git a/Common/Music/BiomeMusicScenes.cs b/Common/Music/BiomeMusicScenes.cs index 019f114..1113cea 100644 --- a/Common/Music/BiomeMusicScenes.cs +++ b/Common/Music/BiomeMusicScenes.cs @@ -45,19 +45,19 @@ namespace UnCalamityModMusic.Common.Music MusicFlags.WorkshopTier3 ? "WorkshopTier3" : MusicFlags.WorkshopTier2 ? "WorkshopTier2" : MusicFlags.WorkshopTier1 ? "WorkshopTier1" : - string.Empty; + "Nothing"; public override SceneEffectPriority Priority => SceneEffectPriority.Environment; - public override bool MusicCondition(Player player) => MusicFlags.Workshop; + public override bool MusicCondition(Player player) => MusicFlags.WorkshopBase; } public class Town : MusicSceneBase { public override string MusicFilePath => + MusicFlags.Party ? "TownParty" : MusicFlags.Night ? !MusicFlags.Surface ? "TownNight_Noiseless" : "TownNight" : - MusicFlags.Party ? "TownParty" : "TownDay"; public override SceneEffectPriority Priority => SceneEffectPriority.Environment; @@ -83,9 +83,9 @@ namespace UnCalamityModMusic.Common.Music public override bool MusicCondition(Player player) => MusicFlags.Underworld; } - public class GlowingMushroomFields : MusicSceneBase + public class GlowingMushrooms : MusicSceneBase { - public override string MusicFilePath => "GlowingMushroomFields"; + public override string MusicFilePath => "GlowingMushrooms"; public override SceneEffectPriority Priority => SceneEffectPriority.BiomeHigh; @@ -154,7 +154,7 @@ namespace UnCalamityModMusic.Common.Music MusicFlags.Night ? "JungleNight" : "JungleDay";*/ public override string MusicFilePath => // Temporary for vanilla music. - MusicFlags.Underground ? string.Empty : + MusicFlags.Underground ? "Nothing" : "JungleDay"; public override int VanillaMusicPath => // Temporary for vanilla music. @@ -190,7 +190,7 @@ namespace UnCalamityModMusic.Common.Music "Hallow";*/ public override string MusicFilePath => // Temporary for vanilla music. MusicFlags.Night ? "ForestNight" : - string.Empty; + "Nothing"; public override int VanillaMusicPath => // Temporary for vanilla music. MusicFlags.OtherworldlyMusic ? MusicFlags.Underground ? MusicID.OtherworldlyUGHallow : diff --git a/Common/Music/EventMusicScenes.cs b/Common/Music/EventMusicScenes.cs index 4874734..da03c6f 100644 --- a/Common/Music/EventMusicScenes.cs +++ b/Common/Music/EventMusicScenes.cs @@ -100,8 +100,8 @@ namespace UnCalamityModMusic.Common.Music public class OldOnesArmy : MusicSceneBase { /*public override string MusicFilePath => - NPC.downedGolemBoss ? "OldOnesArmyTier3" : - NPC.downedMechBossAny ? "OldOnesArmyTier2" : + MusicFlags.DefeatedGolem ? "OldOnesArmyTier3" : + MusicFlags.DefeatedAnyMech ? "OldOnesArmyTier2" : "OldOnesArmyTier1"; public override SceneEffectPriority Priority => SceneEffectPriority.Event; @@ -162,19 +162,19 @@ namespace UnCalamityModMusic.Common.Music public class Rain : MusicSceneBase { public override string MusicFilePath => - /*MusicFlags.Tundra ? "Blizzard" :*/ MusicFlags.Tundra ? "Tundra" : + /*MusicFlags.Blizzard ? "Blizzard" :*/ MusicFlags.Blizzard ? "Tundra" : MusicFlags.Ocean ? "OceanRain" : //MusicFlags.Thunderstorm ? "Thunderstorm" : MusicFlags.Night ? "RainNight" : - MusicFlags.RainyTown ? "TownRain" : + MusicFlags.Town ? "TownRain" : "RainDay"; public override SceneEffectPriority Priority => - MusicFlags.Tundra || MusicFlags.RainyTown ? SceneEffectPriority.Environment : + MusicFlags.Blizzard || MusicFlags.Town ? SceneEffectPriority.Environment : SceneEffectPriority.BiomeMedium; public override float GetWeight(Player player) => // Relative weight change. - MusicFlags.Tundra || MusicFlags.RainyTown ? base.GetWeight(player) : + MusicFlags.Blizzard || MusicFlags.Town ? base.GetWeight(player) : base.GetWeight(player) + 0.01f; public override bool MusicCondition(Player player) => MusicFlags.Rain; diff --git a/Common/MusicFlags.cs b/Common/MusicFlags.cs index 642f857..c5bc2d5 100644 --- a/Common/MusicFlags.cs +++ b/Common/MusicFlags.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using Terraria; using Terraria.GameContent.Events; using Terraria.ID; @@ -32,22 +33,21 @@ namespace UnCalamityModMusic.Common internal static bool Surface; internal static bool Underground; - internal static bool OffsetOverworldLayer; - internal static bool OffsetRockLayer; - internal static bool RemixSeedSpawnIsland; + internal static bool OffsetSurface; + internal static bool FestiveMoonLayer; + + internal static bool RemixedOffsetSurface; + internal static bool RemixedSpawnIsland; #endregion #region Biome Flags - internal static bool NotInGreaterBiomeMediumZone; - internal static bool NotInGreaterBiomeHighZone; - internal static bool NotInGreaterEnvironmentZone; - internal static bool Purity; internal static bool Forest; internal static bool Desert; internal static bool UndergroundDesert; internal static bool Ocean; internal static bool Hallow; + internal static bool Tundra; internal static bool Jungle; internal static bool Geodes; @@ -57,9 +57,11 @@ namespace UnCalamityModMusic.Common internal static bool BeeHive; internal static bool Meteorite; internal static bool Graveyard; + internal static bool Crimson; internal static bool Corruption; internal static bool GlowingMushrooms; + internal static bool Underworld; internal static bool Space; internal static bool Dungeon; @@ -69,31 +71,32 @@ namespace UnCalamityModMusic.Common #region Town Flags internal static bool NearThreeVillagers; - internal static bool NotInExemptBiomeForTowns; - internal static bool NotInExemptEventForTowns; + internal static bool NotInTownAverseBiome; + internal static bool NotInTownAverseEvent; internal static bool Town; - internal static bool RainyTown; internal static bool Party; #endregion #region Workshop Flags - internal static bool Workshop; + internal static bool WorkshopBase; + internal static bool WorkshopAnyTier; internal static double WorkshopRange; + + internal static List WorkBench; + internal static int Furnace; + internal static int Anvil; + internal static int Hellforge; + internal static int HardmodeAnvil; + internal static int HardmodeForge; + internal static int AncientManipulator; + internal static bool WorkshopTier1; internal static bool WorkshopTier2; internal static bool WorkshopTier3; internal static bool WorkshopTier4; internal static bool WorkshopTier5; internal static bool WorkshopTier6; - internal static bool AnyWorkshopTier; - - internal static bool MagicStorageWorkshop; - internal static bool MagicStorageTier2Progression; - internal static bool MagicStorageTier3Progression; - internal static bool MagicStorageTier4Progression; - internal static bool MagicStorageTier5Progression; - internal static bool MagicStorageTier6Progression; #endregion #region Event Flags @@ -101,22 +104,25 @@ namespace UnCalamityModMusic.Common internal static bool LanternFestival; internal static bool Rain; internal static bool Thunderstorm; + internal static bool Blizzard; internal static bool SlimeRain; internal static bool Sandstorm; internal static bool BloodMoon; internal static bool SolarEclipse; + internal static bool PumpkinMoon; + internal static bool FrostMoon; + internal static bool GoblinArmy; internal static bool OldOnesArmy; internal static bool FrostLegion; internal static bool PirateInvasion; - internal static bool PumpkinMoon; - internal static bool FrostMoon; internal static bool MartianMadness; + + internal static bool TorchGod; internal static bool VortexPillar; internal static bool NebulaPillar; internal static bool StardustPillar; internal static bool SolarPillar; - internal static bool TorchGod; #endregion #region Misc Flags @@ -126,12 +132,28 @@ namespace UnCalamityModMusic.Common #endregion #region Boss Flags + internal static bool DefeatedQueenBee; + internal static bool DefeatedDeerclops; + internal static bool DefeatedSkeletron; + internal static bool DefeatedQueenSlime; + internal static bool DefeatedAnyMech; + internal static bool DefeatedPlantera; + internal static bool DefeatedGolem; + internal static bool DefeatedDukeFishron; + internal static bool DefeatedEmpressofLight; + internal static bool DefeatedLunaticCultist; + internal static float BossMusicTileRange; + internal static bool SimultaneousMechs; internal static bool MechaMayhem; #endregion #region Calamity Flags + internal static bool RevengeanceMode; + internal static bool DeathMode; + internal static bool BossRush; + internal static bool SunkenSea; internal static bool SulphurousSea; internal static bool AstralInfection; @@ -141,9 +163,10 @@ namespace UnCalamityModMusic.Common internal static bool ThermalVents; internal static bool TheVoid; internal static bool BrimstoneCrags; - internal static bool RevengeanceMode; - internal static bool DeathMode; - internal static bool BossRush; + + internal static int CosmicAnvil = TileID.Count; + internal static int DraedonsForge = TileID.Count; + internal static bool DefeatedHiveMind; internal static bool DefeatedPerforators; internal static bool DefeatedSlimeGod; @@ -168,33 +191,45 @@ namespace UnCalamityModMusic.Common internal static bool DefeatedYharon; internal static bool DefeatedExoMechs; internal static bool DefeatedCalamitas; + internal static bool NotInCalamityMusicEvent = true; #endregion #region Other Modded Flags + internal static bool InfernumMode; + internal static bool LostColosseum; internal static bool ProfanedTemple; - internal static bool InfernumMode; internal static bool RemnantsPyramid; internal static bool RemnantsGraniteCave; internal static bool RemnantsMarbleCave; internal static bool RemnantsHive; + + internal static int StorageHeart = TileID.Count; + internal static int CraftingUnit = TileID.Count; + + internal static bool MagicStorageWorkshop; + internal static bool MagicStorageTier2Progression; + internal static bool MagicStorageTier3Progression; + internal static bool MagicStorageTier4Progression; + internal static bool MagicStorageTier5Progression; + internal static bool MagicStorageTier6Progression; #endregion public override void PreUpdate() { - #region Mod Instancing + #region Instancing var calamityMod = ModLoader.TryGetMod("CalamityMod", out Mod calamitymod); var magicStorage = ModLoader.TryGetMod("MagicStorage", out Mod magicstorage); var noTownMusic = ModLoader.TryGetMod("NoTownMusic", out Mod notownmusic); var infernumMod = ModLoader.TryGetMod("InfernumMode", out Mod infernummod); var remnantsMod = ModLoader.TryGetMod("Remnants", out Mod remnantsmod); + + Player player = Main.player[Main.myPlayer]; #endregion #region Basic Flags - Player player = Main.player[Main.myPlayer]; - OtherworldlyMusic = Main.zenithWorld ? Main.swapMusic : Main.swapMusic != Main.drunkWorld; RemixSeed = Main.remixWorld; Hardmode = Main.hardMode; @@ -216,36 +251,37 @@ namespace UnCalamityModMusic.Common Surface = RemixSeed ? RockLayer : OverworldLayer; Underground = RemixSeed && !Purity ? DirtLayer : DirtLayer || RockLayer; - OffsetOverworldLayer = player.position.Y < Main.worldSurface * 16.0 + (double)Main.screenHeight / 2; - OffsetRockLayer = player.position.Y > Main.rockLayer * 16.0 && player.position.Y <= (Main.UnderworldLayer * 16); - RemixSeedSpawnIsland = player.position.Y > (Main.UnderworldLayer * 16) && (double)(player.Center.X / 16f) > Main.maxTilesX * 0.37 + 50.0 && (double)(player.Center.X / 16f) < Main.maxTilesX * 0.63; + OffsetSurface = RemixSeed ? RemixedOffsetSurface : player.position.Y < Main.worldSurface * 16.0 + (double)Main.screenHeight / 2; + FestiveMoonLayer = RemixSeed || (double)(Main.screenPosition.Y / 16f) < Main.worldSurface + 10.0; + + RemixedSpawnIsland = player.position.Y > (Main.UnderworldLayer * 16) && (double)(player.Center.X / 16f) > Main.maxTilesX * 0.37 + 50.0 && (double)(player.Center.X / 16f) < Main.maxTilesX * 0.63; + RemixedOffsetSurface = player.position.Y > Main.rockLayer * 16.0 && player.position.Y <= (Main.UnderworldLayer * 16) || RemixedSpawnIsland; #endregion #region Biome Flags - NotInGreaterBiomeMediumZone = !(Meteorite || Graveyard); - NotInGreaterBiomeHighZone = !(SunkenSea || SulphurousSea || AstralInfection); - NotInGreaterEnvironmentZone = !(BrimstoneCrags || ProfanedTemple || Town || AnyWorkshopTier); - Purity = player.ZonePurity; Forest = Surface || Underground; - Desert = player.ZoneDesert && !(Ocean || Hallow) && (UndergroundDesert ? Underground : Surface); + Desert = player.ZoneDesert && ((Hallow && Night) || Sandstorm ? !Ocean : !(Ocean || Hallow)) && (UndergroundDesert ? Underground : Surface); UndergroundDesert = player.ZoneUndergroundDesert && !Surface; Ocean = player.ZoneBeach && !Hallow; Hallow = player.ZoneHallow; - Tundra = player.ZoneSnow && NotInGreaterBiomeMediumZone; - Jungle = player.ZoneJungle && NotInGreaterBiomeMediumZone; - Geodes = (GraniteCave || MarbleCave) && Underground && NotInGreaterBiomeMediumZone; + + Tundra = player.ZoneSnow && !(Meteorite || Graveyard); + Jungle = player.ZoneJungle && !(Meteorite || Graveyard); + Geodes = (GraniteCave || MarbleCave) && Underground && !Graveyard; GraniteCave = (player.ZoneGranite && TileCounts.GraniteTileCount >= 50) || (MusicUtilities.InFrontOfWall(WallID.GraniteBlock) && TileCounts.GraniteTileCount >= 500); MarbleCave = (player.ZoneMarble && TileCounts.MarbleTileCount >= 50) || (MusicUtilities.InFrontOfWall(WallID.MarbleBlock) && TileCounts.MarbleTileCount >= 500); SpiderCave = MusicUtilities.InFrontOfWall(WallID.SpiderUnsafe) && Underground; BeeHive = MusicUtilities.InFrontOfWall(WallID.HiveUnsafe); Meteorite = player.ZoneMeteor && !Graveyard; Graveyard = player.ZoneGraveyard; - Crimson = player.ZoneCrimson && !GlowingMushrooms && NotInGreaterBiomeHighZone; - Corruption = player.ZoneCorrupt && !GlowingMushrooms && NotInGreaterBiomeHighZone; - GlowingMushrooms = player.ZoneGlowshroom && NotInGreaterBiomeHighZone; - Underworld = player.ZoneUnderworldHeight && (RemixSeed ? !(SolarEclipse || BloodMoon) && NotInGreaterEnvironmentZone : NotInGreaterEnvironmentZone); - Space = (RemixSeed ? (SkyLayer || OverworldLayer) : SkyLayer) && NotInGreaterEnvironmentZone; + + Crimson = player.ZoneCrimson && !(GlowingMushrooms || SunkenSea || SulphurousSea || AstralInfection); + Corruption = player.ZoneCorrupt && !(GlowingMushrooms || SunkenSea || SulphurousSea || AstralInfection); + GlowingMushrooms = player.ZoneGlowshroom && !(SunkenSea || SulphurousSea || AstralInfection); + + Underworld = player.ZoneUnderworldHeight && (RemixSeed ? !(BloodMoon || SolarEclipse || BrimstoneCrags || ProfanedTemple || Town || WorkshopAnyTier) : !(BrimstoneCrags || ProfanedTemple || Town || WorkshopAnyTier)); + Space = (RemixSeed ? SkyLayer || OverworldLayer : SkyLayer) && !(BrimstoneCrags || ProfanedTemple || Town || WorkshopAnyTier); Dungeon = player.ZoneDungeon; JungleTemple = player.ZoneLihzhardTemple; Aether = player.ZoneShimmer; @@ -253,69 +289,81 @@ namespace UnCalamityModMusic.Common #region Town Flags NearThreeVillagers = player.townNPCs > 2f; - NotInExemptBiomeForTowns = !(Graveyard || Dungeon || JungleTemple || Aether || Abyss); - NotInExemptEventForTowns = !(/*WindyDay || */Rain || SlimeRain || Sandstorm || BloodMoon || SolarEclipse); // Windy Day is temporarily omitted from this list until it gets music. + + NotInTownAverseBiome = !(Graveyard || Dungeon || JungleTemple || Aether || Abyss); + NotInTownAverseEvent = !(/*(!Party && WindyDay) || */SlimeRain || Sandstorm || BloodMoon || SolarEclipse); // Windy Day is temporarily omitted from this list until it gets music. if (noTownMusic || player.ZoneShadowCandle || player.inventory[player.selectedItem].type == ItemID.ShadowCandle) { Town = false; - RainyTown = false; Party = false; } else { - Town = NearThreeVillagers && !AnyWorkshopTier && (Surface ? NotInExemptBiomeForTowns && NotInExemptEventForTowns : NotInExemptBiomeForTowns); - RainyTown = NearThreeVillagers && Rain && Surface && !SulphurousSea; - Party = Town && BirthdayParty.PartyIsUp; + Town = NearThreeVillagers && (Surface ? NotInTownAverseBiome && NotInTownAverseEvent : NotInTownAverseBiome) && (Rain ? !SulphurousSea : !WorkshopAnyTier); + Party = NearThreeVillagers && BirthdayParty.PartyIsUp; } #endregion #region Workshop Flags - Workshop = (Surface ? !LanternFestival && NotInExemptBiomeForTowns && NotInExemptEventForTowns : NotInExemptBiomeForTowns) && - ModContent.GetInstance().WorkshopThemes; - WorkshopRange = Math.Pow(ModContent.GetInstance().WorkshopRange * 16f, 2); - WorkshopTier1 = (WorkshopDetection.TileDistance(TileID.WorkBenches, TileID.Furnaces, TileID.Anvils) <= WorkshopRange && - TileCounts.WorkbenchTileCount > 0 && TileCounts.FurnaceTileCount > 0 && TileCounts.AnvilTileCount > 0) || - MagicStorageWorkshop; - WorkshopTier2 = WorkshopDetection.TileDistance(TileID.WorkBenches, TileID.Hellforge, TileID.Anvils, TileID.AdamantiteForge, TileID.MythrilAnvil) <= WorkshopRange && - TileCounts.WorkbenchTileCount > 0 && (TileCounts.HellforgeTileCount > 0 || TileCounts.HardmodeForgeTileCount > 0) && TileCounts.AnvilTileCount > 0 || - (TileCounts.WorkbenchTileCount > 0 && TileCounts.HellforgeTileCount > 0 && (TileCounts.AnvilTileCount > 0 || TileCounts.HardmodeAnvilTileCount > 0)) || - MagicStorageWorkshop && MagicStorageTier2Progression; - WorkshopTier3 = (WorkshopDetection.TileDistance(TileID.WorkBenches, TileID.AdamantiteForge, TileID.MythrilAnvil) <= WorkshopRange && - TileCounts.WorkbenchTileCount > 0 && TileCounts.HardmodeForgeTileCount > 0 && TileCounts.HardmodeAnvilTileCount > 0) || - MagicStorageWorkshop && MagicStorageTier3Progression; - WorkshopTier4 = (NPC.downedPlantBoss && WorkshopTier3) || - (MagicStorageWorkshop && MagicStorageTier4Progression); - WorkshopTier5 = (Endgame && WorkshopTier3) || - calamityMod && WorkshopDetection.TileDistance(TileID.WorkBenches, TileID.AdamantiteForge, calamitymod.Find("CosmicAnvil").Type) <= WorkshopRange && - TileCounts.WorkbenchTileCount > 0 && TileCounts.HardmodeForgeTileCount > 0 && TileCounts.CosmicAnvilTileCount > 0 || - MagicStorageWorkshop && MagicStorageTier5Progression; - WorkshopTier6 = (calamityMod && WorkshopDetection.TileDistance(calamitymod.Find("DraedonsForge").Type) <= WorkshopRange && - TileCounts.DraedonsForgeTileCount > 0) || - MagicStorageWorkshop && MagicStorageTier6Progression; - AnyWorkshopTier = Workshop && (WorkshopTier1 || WorkshopTier2 || WorkshopTier3 || WorkshopTier4 || WorkshopTier5 || WorkshopTier6); + WorkshopBase = (Surface ? !(/*WindyDay || */LanternFestival || Rain) && NotInTownAverseBiome && NotInTownAverseEvent : NotInTownAverseBiome) && !Party && ModContent.GetInstance().WorkshopThemes; // Windy Day is temporarily omitted from this list until it gets music. + WorkshopAnyTier = WorkshopBase && (WorkshopTier1 || WorkshopTier2 || WorkshopTier3 || WorkshopTier4 || WorkshopTier5 || WorkshopTier6); + WorkshopRange = Math.Pow(ModContent.GetInstance().WorkshopRange * 16f, 2f); - MagicStorageWorkshop = magicStorage && (WorkshopDetection.TileDistance(magicstorage.Find("StorageHeart").Type) <= WorkshopRange || - WorkshopDetection.TileDistance(magicstorage.Find("CraftingAccess").Type) <= WorkshopRange) && - TileCounts.StorageHeartTileCount > 0 && TileCounts.CraftingUnitTileCount > 0; - MagicStorageTier2Progression = DefeatedHiveMind || DefeatedPerforators || NPC.downedQueenBee || NPC.downedBoss3 || NPC.downedDeerclops || DefeatedSlimeGod; - MagicStorageTier3Progression = Hardmode || NPC.downedQueenSlime || DefeatedCryogen || NPC.downedMechBossAny || DefeatedAquaticScourge || DefeatedBrimstoneElemental || DefeatedCalamitasClone; - MagicStorageTier4Progression = NPC.downedPlantBoss || DefeatedLeviathan || DefeatedAstrumAureus || NPC.downedGolemBoss || DefeatedPlaguebringerGoliath || NPC.downedFishron || - DefeatedRavager || NPC.downedEmpressOfLight || NPC.downedAncientCultist || DefeatedAstrumDeus; - MagicStorageTier5Progression = Endgame || DefeatedProfanedGuardians || DefeatedDragonfolly || DefeatedProvidence || DefeatedCeaselessVoid || DefeatedStormWeaver || - DefeatedSignus || DefeatedPolterghast || DefeatedOldDuke || DefeatedDevourerofGods || DefeatedYharon; - MagicStorageTier6Progression = DefeatedExoMechs || DefeatedCalamitas; + WorkBench = [TileID.WorkBenches, ..TileCounts.ModdedWorkBenches]; + Furnace = TileID.Furnaces; + Anvil = TileID.Anvils; + Hellforge = TileID.Hellforge; + HardmodeAnvil = TileID.MythrilAnvil; + HardmodeForge = TileID.AdamantiteForge; + AncientManipulator = TileID.LunarCraftingStation; + + WorkshopTier1 = + (WorkshopDetection.TileDistance(WorkBench, Furnace, Anvil) <= WorkshopRange && + TileCounts.WorkBenchTileCount > 0 && TileCounts.FurnaceTileCount > 0 && TileCounts.AnvilTileCount > 0) || + MagicStorageWorkshop; + WorkshopTier2 = + (WorkshopDetection.TileDistance(WorkBench, Hellforge, Anvil) <= WorkshopRange && + TileCounts.WorkBenchTileCount > 0 && TileCounts.HellforgeTileCount > 0 && TileCounts.AnvilTileCount > 0) || + (WorkshopDetection.TileDistance(WorkBench, Hellforge, HardmodeAnvil) <= WorkshopRange && + TileCounts.WorkBenchTileCount > 0 && TileCounts.HellforgeTileCount > 0 && TileCounts.HardmodeAnvilTileCount > 0) || + (WorkshopDetection.TileDistance(WorkBench, HardmodeForge, Anvil) <= WorkshopRange && + TileCounts.WorkBenchTileCount > 0 && TileCounts.HardmodeForgeTileCount > 0 && TileCounts.AnvilTileCount > 0) || + (WorkshopDetection.TileDistance(WorkBench, Furnace, HardmodeAnvil) <= WorkshopRange && + TileCounts.WorkBenchTileCount > 0 && TileCounts.FurnaceTileCount > 0 && TileCounts.HardmodeAnvilTileCount > 0) || + (MagicStorageWorkshop && MagicStorageTier2Progression); + WorkshopTier3 = + (WorkshopDetection.TileDistance(WorkBench, HardmodeForge, HardmodeAnvil) <= WorkshopRange && + TileCounts.WorkBenchTileCount > 0 && TileCounts.HardmodeForgeTileCount > 0 && TileCounts.HardmodeAnvilTileCount > 0) || + (MagicStorageWorkshop && MagicStorageTier3Progression); + WorkshopTier4 = + (DefeatedPlantera && WorkshopTier3) || + (MagicStorageWorkshop && MagicStorageTier4Progression); + WorkshopTier5 = + (WorkshopDetection.TileDistance(WorkBench, HardmodeForge, HardmodeAnvil, AncientManipulator) <= WorkshopRange && + TileCounts.WorkBenchTileCount > 0 && TileCounts.HardmodeForgeTileCount > 0 && TileCounts.HardmodeAnvilTileCount > 0 && TileCounts.AncientManipulatorTileCount > 0) || + (WorkshopDetection.TileDistance(WorkBench, HardmodeForge, CosmicAnvil) <= WorkshopRange && + TileCounts.WorkBenchTileCount > 0 && TileCounts.HardmodeForgeTileCount > 0 && TileCounts.CosmicAnvilTileCount > 0) || + (MagicStorageWorkshop && MagicStorageTier5Progression); + WorkshopTier6 = + (WorkshopDetection.TileDistance(DraedonsForge) <= WorkshopRange && + TileCounts.DraedonsForgeTileCount > 0) || + (MagicStorageWorkshop && MagicStorageTier6Progression); #endregion #region Event Flags - WindyDay = Main._shouldUseWindyDayMusic && (RemixSeed ? Purity && Surface : Surface); - LanternFestival = LanternNight.LanternsUp && !Rain && (Ocean || SulphurousSea ? NotInGreaterBiomeMediumZone : Surface && NotInGreaterBiomeMediumZone); - Rain = (Tundra ? NaturalRain && VisibleRain : VisibleRain) && Surface && NotInGreaterBiomeMediumZone; - Thunderstorm = Main._shouldUseStormMusic && Surface; - SlimeRain = Main.slimeRain && OffsetOverworldLayer && !(Space || BloodMoon || SolarEclipse); - Sandstorm = Terraria.GameContent.Events.Sandstorm.Happening && Desert && Surface; - BloodMoon = Main.bloodMoon && (RemixSeed ? (OffsetRockLayer || RemixSeedSpawnIsland) && !(Crimson || Corruption) : OffsetOverworldLayer) && !Space; - SolarEclipse = Main.eclipse && (RemixSeed ? OffsetRockLayer || RemixSeedSpawnIsland : OffsetOverworldLayer) && !Space; + WindyDay = Main._shouldUseWindyDayMusic && Surface && Purity; + LanternFestival = LanternNight.LanternsUp && (Ocean || SulphurousSea ? !(Rain || Meteorite || Graveyard) : Surface && !(Rain || Meteorite || Graveyard)); + Rain = VisibleRain && Surface && /*(Blizzard ? !(Meteorite || Graveyard || SolarEclipse) : */!(Meteorite || Graveyard || BloodMoon || SolarEclipse)/*)*/; //This check is not needed until Blizzard music is added. + Thunderstorm = Main._shouldUseStormMusic; + Blizzard = NaturalRain && Tundra; + SlimeRain = Main.slimeRain && OffsetSurface && !(Space || BloodMoon || SolarEclipse); + Sandstorm = Terraria.GameContent.Events.Sandstorm.Happening && player.ZoneDesert && Surface; + BloodMoon = Main.bloodMoon && (RemixSeed ? OffsetSurface && !(Crimson || Corruption) : OffsetSurface) && !Space; + SolarEclipse = Main.eclipse && OffsetSurface && !Space; + PumpkinMoon = Main.pumpkinMoon && FestiveMoonLayer; + FrostMoon = Main.snowMoon && FestiveMoonLayer; + GoblinArmy = (Main.invasionType == InvasionID.GoblinArmy && Main.invasionProgressNearInvasion) || MusicUtilities.NPCNearby(NPCID.GoblinPeon, NPCID.GoblinThief, NPCID.GoblinWarrior, NPCID.GoblinSorcerer, NPCID.GoblinArcher, NPCID.GoblinSummoner); OldOnesArmy = (DD2Event.Ongoing && Main.invasionProgressNearInvasion) || @@ -329,16 +377,15 @@ namespace UnCalamityModMusic.Common PirateInvasion = (Main.invasionType == InvasionID.PirateInvasion && Main.invasionProgressNearInvasion) || MusicUtilities.NPCNearby(NPCID.Parrot, NPCID.PirateCaptain, NPCID.PirateCorsair, NPCID.PirateCrossbower, NPCID.PirateDeadeye, NPCID.PirateDeckhand, NPCID.PirateShip); - PumpkinMoon = Main.pumpkinMoon && (OffsetOverworldLayer || RemixSeed); - FrostMoon = Main.snowMoon && (OffsetOverworldLayer || RemixSeed); MartianMadness = (Main.invasionType == InvasionID.MartianMadness && Main.invasionProgressNearInvasion) || MusicUtilities.NPCNearby(NPCID.MartianSaucerCore, NPCID.ScutlixRider, NPCID.Scutlix, NPCID.MartianWalker, NPCID.MartianDrone, NPCID.MartianTurret, NPCID.GigaZapper, NPCID.MartianEngineer, NPCID.MartianOfficer, NPCID.RayGunner, NPCID.GrayGrunt, NPCID.BrainScrambler); + + TorchGod = player.happyFunTorchTime || MusicUtilities.NPCNearby(NPCID.TorchGod); VortexPillar = player.ZoneTowerVortex || MusicUtilities.NPCNearby(NPCID.LunarTowerVortex); NebulaPillar = player.ZoneTowerNebula || MusicUtilities.NPCNearby(NPCID.LunarTowerNebula); StardustPillar = player.ZoneTowerStardust || MusicUtilities.NPCNearby(NPCID.LunarTowerStardust); SolarPillar = player.ZoneTowerSolar || MusicUtilities.NPCNearby(NPCID.LunarTowerSolar); - TorchGod = player.happyFunTorchTime || MusicUtilities.NPCNearby(NPCID.TorchGod); #endregion #region Misc Flags @@ -348,24 +395,35 @@ namespace UnCalamityModMusic.Common #endregion #region Boss Flags + DefeatedQueenBee = NPC.downedQueenBee; + DefeatedDeerclops = NPC.downedDeerclops; + DefeatedSkeletron = NPC.downedBoss3; + DefeatedQueenSlime = NPC.downedQueenSlime; + DefeatedAnyMech = NPC.downedMechBossAny; + DefeatedPlantera = NPC.downedPlantBoss; + DefeatedGolem = NPC.downedGolemBoss; + DefeatedDukeFishron = NPC.downedFishron; + DefeatedEmpressofLight = NPC.downedEmpressOfLight; + DefeatedLunaticCultist = NPC.downedAncientCultist; + BossMusicTileRange = 525f * 16f; // 525 tile radius. + SimultaneousMechs = (MechaMayhem && MusicUtilities.NPCNearby(NPCID.TheDestroyer, NPCID.TheDestroyerBody, NPCID.TheDestroyerTail)) || (MechaMayhem && MusicUtilities.NPCNearby(NPCID.Spazmatism, NPCID.Retinazer)) || (MechaMayhem && MusicUtilities.NPCNearby(NPCID.SkeletronPrime)); - if (MusicUtilities.NPCNearby(NPCID.TheDestroyer, NPCID.TheDestroyerBody, NPCID.TheDestroyerTail) && MusicUtilities.NPCNearby(NPCID.Spazmatism, NPCID.Retinazer) && MusicUtilities.NPCNearby(NPCID.SkeletronPrime)) - { MechaMayhem = true; - } else if (!MusicUtilities.NPCNearby(NPCID.TheDestroyer, NPCID.TheDestroyerBody, NPCID.TheDestroyerTail) && !MusicUtilities.NPCNearby(NPCID.Spazmatism, NPCID.Retinazer) && !MusicUtilities.NPCNearby(NPCID.SkeletronPrime)) - { MechaMayhem = false; - } #endregion #region Calamity Flags if (calamityMod) { + RevengeanceMode = (bool)calamitymod.Call("GetDifficultyActive", "revengeance"); + DeathMode = (bool)calamitymod.Call("GetDifficultyActive", "death"); + BossRush = (bool)calamitymod.Call("GetDifficultyActive", "bossrush"); + SunkenSea = (bool)calamitymod.Call("GetInZone", player, "sunkensea"); SulphurousSea = (bool)calamitymod.Call("GetInZone", player, "sulphursea") && !Abyss; AstralInfection = (bool)calamitymod.Call("GetInZone", player, "astral"); @@ -375,9 +433,10 @@ namespace UnCalamityModMusic.Common ThermalVents = (bool)calamitymod.Call("GetInZone", player, "layer3"); TheVoid = (bool)calamitymod.Call("GetInZone", player, "layer4"); BrimstoneCrags = (bool)calamitymod.Call("GetInZone", player, "crags"); - RevengeanceMode = (bool)calamitymod.Call("GetDifficultyActive", "revengeance"); - DeathMode = (bool)calamitymod.Call("GetDifficultyActive", "death"); - BossRush = (bool)calamitymod.Call("GetDifficultyActive", "bossrush"); + + CosmicAnvil = calamitymod.Find("CosmicAnvil").Type; + DraedonsForge = calamitymod.Find("DraedonsForge").Type; + DefeatedHiveMind = (bool)calamitymod.Call("GetBossDowned", "hivemind"); DefeatedPerforators = (bool)calamitymod.Call("GetBossDowned", "perforator"); DefeatedSlimeGod = (bool)calamitymod.Call("GetBossDowned", "slimegod"); @@ -402,6 +461,7 @@ namespace UnCalamityModMusic.Common DefeatedYharon = (bool)calamitymod.Call("GetBossDowned", "yharon"); DefeatedExoMechs = (bool)calamitymod.Call("GetBossDowned", "exomechs"); DefeatedCalamitas = (bool)calamitymod.Call("GetBossDowned", "calamitas"); + NotInCalamityMusicEvent = MusicUtilities.CalamityMusicEvent() == null; } #endregion @@ -409,9 +469,10 @@ namespace UnCalamityModMusic.Common #region Other Modded Flags if (infernumMod) { + InfernumMode = (bool)infernummod.Call("GetInfernumActive"); + ProfanedTemple = player.InModBiome(infernummod.Find("ProfanedTempleBiome")); LostColosseum = player.InModBiome(infernummod.Find("LostColosseumBiome")); - InfernumMode = (bool)infernummod.Call("GetInfernumActive"); } if (remnantsMod) @@ -421,6 +482,23 @@ namespace UnCalamityModMusic.Common RemnantsMarbleCave = player.InModBiome(remnantsmod.Find("MarbleCave")); RemnantsHive = player.InModBiome(remnantsmod.Find("Beehive")); } + + if (magicStorage) + { + StorageHeart = magicstorage.Find("StorageHeart").Type; + CraftingUnit = magicstorage.Find("CraftingAccess").Type; + + MagicStorageWorkshop = WorkshopDetection.TileDistance(StorageHeart, CraftingUnit) <= WorkshopRange && + TileCounts.StorageHeartTileCount > 0 && TileCounts.CraftingUnitTileCount > 0; + MagicStorageTier2Progression = DefeatedHiveMind || DefeatedPerforators || DefeatedQueenBee || DefeatedDeerclops || DefeatedSkeletron || DefeatedSlimeGod; + MagicStorageTier3Progression = Hardmode || DefeatedQueenSlime || DefeatedCryogen || DefeatedAnyMech || DefeatedAquaticScourge || DefeatedBrimstoneElemental || + DefeatedCalamitasClone; + MagicStorageTier4Progression = DefeatedPlantera || DefeatedLeviathan || DefeatedAstrumAureus || DefeatedGolem || DefeatedPlaguebringerGoliath || DefeatedDukeFishron || + DefeatedRavager || DefeatedEmpressofLight || DefeatedLunaticCultist || DefeatedAstrumDeus; + MagicStorageTier5Progression = Endgame || DefeatedProfanedGuardians || DefeatedDragonfolly || DefeatedProvidence || DefeatedCeaselessVoid || DefeatedStormWeaver || + DefeatedSignus || DefeatedPolterghast || DefeatedOldDuke || DefeatedDevourerofGods || DefeatedYharon; + MagicStorageTier6Progression = DefeatedExoMechs || DefeatedCalamitas; + } #endregion } } diff --git a/Common/MusicPathing.cs b/Common/MusicPathing.cs index c626e85..4a6d61b 100644 --- a/Common/MusicPathing.cs +++ b/Common/MusicPathing.cs @@ -28,7 +28,7 @@ namespace UnCalamityModMusic.Common {"ForestDayMorning", MusicLoader.GetMusicSlot(mod, "Assets/Music/Biomes/ForestDayMorning")}, {"ForestNight", MusicLoader.GetMusicSlot(mod, "Assets/Music/Biomes/ForestNight")}, {"Geodes", MusicLoader.GetMusicSlot(mod, "Assets/Music/Biomes/Geodes")}, - {"GlowingMushroomFields", MusicLoader.GetMusicSlot(mod, "Assets/Music/Biomes/GlowingMushroomFields")}, + {"GlowingMushrooms", MusicLoader.GetMusicSlot(mod, "Assets/Music/Biomes/GlowingMushrooms")}, {"Graveyard", MusicLoader.GetMusicSlot(mod, "Assets/Music/Biomes/Graveyard")}, {"Hallow", MusicLoader.GetMusicSlot(mod, "Assets/Music/Biomes/Hallow")}, {"HallowUnderground", MusicLoader.GetMusicSlot(mod, "Assets/Music/Biomes/HallowUnderground")}, @@ -139,8 +139,7 @@ namespace UnCalamityModMusic.Common {"Dungeon", MusicLoader.GetMusicSlot(mod, "Assets/Music/Ambience/Dungeon")}, {"ForestDay", MusicLoader.GetMusicSlot(mod, "Assets/Music/Ambience/ForestDay")}, {"ForestNight", MusicLoader.GetMusicSlot(mod, "Assets/Music/Ambience/ForestNight")}, - {"GlowingMushroomFields", MusicLoader.GetMusicSlot(mod, "Assets/Music/Ambience/GlowingMushroomFields")}, - {"GlowingMushroomGrove", MusicLoader.GetMusicSlot(mod, "Assets/Music/Ambience/GlowingMushroomGrove")}, + {"GlowingMushrooms", MusicLoader.GetMusicSlot(mod, "Assets/Music/Ambience/GlowingMushrooms")}, {"Hallow", MusicLoader.GetMusicSlot(mod, "Assets/Music/Ambience/Hallow")}, {"HallowUnderground", MusicLoader.GetMusicSlot(mod, "Assets/Music/Ambience/HallowUnderground")}, {"Jungle", MusicLoader.GetMusicSlot(mod, "Assets/Music/Ambience/Jungle")}, diff --git a/Common/MusicSceneBase.cs b/Common/MusicSceneBase.cs index e5b731b..c725006 100644 --- a/Common/MusicSceneBase.cs +++ b/Common/MusicSceneBase.cs @@ -32,7 +32,7 @@ namespace UnCalamityModMusic.Common public override int Music => MusicPathing.GetAmbienceSlot(AmbienceFilePath); - public override SceneEffectPriority Priority => MusicFlags.Town || MusicFlags.AnyWorkshopTier || MusicFlags.LanternFestival ? SceneEffectPriority.Environment : Priority; + public override SceneEffectPriority Priority => MusicFlags.Town || MusicFlags.WorkshopAnyTier || MusicFlags.LanternFestival ? SceneEffectPriority.Environment : Priority; public override float GetWeight(Player player) => 0.7f; diff --git a/Common/TileCounts.cs b/Common/TileCounts.cs index a518420..d0d977e 100644 --- a/Common/TileCounts.cs +++ b/Common/TileCounts.cs @@ -1,56 +1,93 @@ using System; +using System.Collections.Generic; +using System.Linq; using Terraria.ID; using Terraria.ModLoader; -using UnCalamityModMusic.Content.Tiles; namespace UnCalamityModMusic.Common { public class TileCounts : ModSystem { - internal static int WorkbenchTileCount; + internal static int GraniteTileCount; + internal static int MarbleTileCount; + + internal static int WorkBenchTileCount; internal static int FurnaceTileCount; internal static int AnvilTileCount; internal static int HellforgeTileCount; internal static int HardmodeAnvilTileCount; internal static int HardmodeForgeTileCount; - internal static int GraniteTileCount; - internal static int MarbleTileCount; - + internal static int AncientManipulatorTileCount; internal static int CosmicAnvilTileCount; - internal static int DraedonsForgeTileCount; + internal static int DraedonsForgeTileCount; + internal static int LabTileCount; internal static int StorageHeartTileCount; internal static int CraftingUnitTileCount; + internal static List ModdedWorkBenches; + + public override void PostSetupContent() + { + ModdedWorkBenches = ModdedWorkBenchIDs(); + } + public override void TileCountsAvailable(ReadOnlySpan tileCounts) { var calamityMod = ModLoader.TryGetMod("CalamityMod", out Mod calamitymod); - var magicStorage = ModLoader.TryGetMod("MagicStorage", out Mod magicstorage); - WorkbenchTileCount = tileCounts[TileID.WorkBenches]; - FurnaceTileCount = tileCounts[TileID.Furnaces]; - AnvilTileCount = tileCounts[TileID.Anvils]; - HellforgeTileCount = tileCounts[TileID.Hellforge]; - HardmodeAnvilTileCount = tileCounts[TileID.MythrilAnvil]; - HardmodeForgeTileCount = tileCounts[TileID.AdamantiteForge]; - GraniteTileCount = tileCounts[TileID.Granite]; + GraniteTileCount = tileCounts[TileID.Granite]; MarbleTileCount = tileCounts[TileID.Marble]; + WorkBenchTileCount = tileCounts[TileID.WorkBenches] + + ModdedWorkBenchTileCount(tileCounts, ModdedWorkBenches); + FurnaceTileCount = tileCounts[MusicFlags.Furnace]; + AnvilTileCount = tileCounts[MusicFlags.Anvil]; + HellforgeTileCount = tileCounts[MusicFlags.Hellforge]; + HardmodeAnvilTileCount = tileCounts[MusicFlags.HardmodeAnvil]; + HardmodeForgeTileCount = tileCounts[MusicFlags.HardmodeForge]; + AncientManipulatorTileCount = tileCounts[MusicFlags.AncientManipulator]; + CosmicAnvilTileCount = tileCounts[MusicFlags.CosmicAnvil]; + DraedonsForgeTileCount = tileCounts[MusicFlags.DraedonsForge]; + StorageHeartTileCount = tileCounts[MusicFlags.StorageHeart]; + CraftingUnitTileCount = tileCounts[MusicFlags.CraftingUnit]; + if (calamityMod) { - CosmicAnvilTileCount = tileCounts[calamitymod.Find("CosmicAnvil").Type]; - DraedonsForgeTileCount = tileCounts[calamitymod.Find("DraedonsForge").Type]; LabTileCount = tileCounts[calamitymod.Find("LaboratoryPanels").Type] + tileCounts[calamitymod.Find("LaboratoryPlating").Type] + tileCounts[calamitymod.Find("HazardChevronPanels").Type]; } - - if (magicStorage) - { - StorageHeartTileCount = tileCounts[magicstorage.Find("StorageHeart").Type]; - CraftingUnitTileCount = tileCounts[magicstorage.Find("CraftingAccess").Type]; - } } - } + + public static int ModdedWorkBenchTileCount(ReadOnlySpan tileCounts, IEnumerable IDs) + { + int workBenchCount = 0; + + if (IDs == null) + return 0; + + foreach (var id in IDs) + if (id >= 0 && id < tileCounts.Length) + workBenchCount += tileCounts[id]; + + return workBenchCount; + } + + public static List ModdedWorkBenchIDs() + { + List workBenchIDs = []; + + for (int id = 0; id < TileLoader.TileCount; id++) + { + ModTile modTile = TileLoader.GetTile(id); + + if (modTile != null && modTile.AdjTiles != null && modTile.AdjTiles.Contains(TileID.WorkBenches)) + workBenchIDs.Add(id); + } + + return workBenchIDs; + } + } } \ No newline at end of file diff --git a/Common/WorkshopDetection.cs b/Common/WorkshopDetection.cs index 2d2156d..4a4dcb5 100644 --- a/Common/WorkshopDetection.cs +++ b/Common/WorkshopDetection.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using System.Collections.Generic; +using System.Linq; using Terraria; using Terraria.ModLoader; @@ -7,60 +8,54 @@ namespace UnCalamityModMusic.Common { public class WorkshopDetection : GlobalTile { - internal static Dictionary> tileCenters = new Dictionary>(); + internal static Dictionary> tileCenters = []; public override void NearbyEffects(int i, int j, int type, bool closer) { - Vector2 tileCenter = new Vector2(i * 16 + 8, j * 16 + 8); + Vector2 tileCenter = new(i * 16 + 8, j * 16 + 8); if (closer) { if (!tileCenters.TryGetValue(type, out List centers)) { - centers = new List(); + centers = []; tileCenters[type] = centers; } - - bool found = centers.Count > 0; - - if (!found) - { - centers.Add(tileCenter); - } + centers.Add(tileCenter); } else { - if (tileCenters.TryGetValue(type, out List centers)) - { - for (int index = centers.Count - 1; index >= 0; index--) - { - centers.RemoveAt(index); - } - } + tileCenters.Clear(); } } public static float TileDistance(params int[] tileTypes) { Player player = Main.player[Main.myPlayer]; - float minDistanceSquared = float.MaxValue; + float closestDistance = float.MaxValue; foreach (int type in tileTypes) { if (tileCenters.TryGetValue(type, out List centers)) { - for (int index = 0; index < centers.Count; index++) + foreach (Vector2 center in centers) { - float distanceSquared = Vector2.DistanceSquared(centers[index], player.Center); - if (distanceSquared < minDistanceSquared) + float distance = Vector2.DistanceSquared(center, player.Center); + + if (distance <= closestDistance) { - minDistanceSquared = distanceSquared; + closestDistance = distance; } } } } - return minDistanceSquared; + return closestDistance; + } + + public static float TileDistance(List list, params int[] tileTypes) + { + return TileDistance(list.Concat(tileTypes).ToArray()); } } } diff --git a/Content/Items/GlowingMushroomFieldsMusicBox.cs b/Content/Items/GlowingMushroomsMusicBox.cs similarity index 63% rename from Content/Items/GlowingMushroomFieldsMusicBox.cs rename to Content/Items/GlowingMushroomsMusicBox.cs index 81ab952..023d61b 100644 --- a/Content/Items/GlowingMushroomFieldsMusicBox.cs +++ b/Content/Items/GlowingMushroomsMusicBox.cs @@ -3,10 +3,11 @@ using UnCalamityModMusic.Common; namespace UnCalamityModMusic.Content.Items { - public class GlowingMushroomFieldsMusicBox : MusicBoxItem + [LegacyName("GlowingMushroomFieldsMusicBox")] + public class GlowingMushroomsMusicBox : MusicBoxItem { - public override int MusicBoxTile => ModContent.TileType(); + public override int MusicBoxTile => ModContent.TileType(); - public override string MusicFilePath => "GlowingMushroomFields"; + public override string MusicFilePath => "GlowingMushrooms"; } } diff --git a/Content/Items/GlowingMushroomFieldsMusicBox.png b/Content/Items/GlowingMushroomsMusicBox.png similarity index 100% rename from Content/Items/GlowingMushroomFieldsMusicBox.png rename to Content/Items/GlowingMushroomsMusicBox.png diff --git a/Content/Items/WorkshopTier4MusicBox.cs b/Content/Items/WorkshopTier4MusicBox.cs index 821ad5d..5b77baf 100644 --- a/Content/Items/WorkshopTier4MusicBox.cs +++ b/Content/Items/WorkshopTier4MusicBox.cs @@ -1,5 +1,3 @@ -using Terraria; -using Terraria.ID; using Terraria.ModLoader; using UnCalamityModMusic.Common; @@ -11,15 +9,5 @@ namespace UnCalamityModMusic.Content.Items public override int MusicBoxTile => ModContent.TileType(); public override string MusicFilePath => "WorkshopTier4"; - - public override void MusicBoxRecipe() - { - // Contingent recipe for when Moon Lord is down - Recipe.Create(Type, 1) - .AddIngredient(ModContent.ItemType()) - .AddIngredient(ModContent.ItemType()) - .AddTile(TileID.TinkerersWorkbench) - .Register(); - } } } diff --git a/Content/Tiles/GlowingMushroomFieldsMusicBox.cs b/Content/Tiles/GlowingMushroomFieldsMusicBox.cs deleted file mode 100644 index 804db44..0000000 --- a/Content/Tiles/GlowingMushroomFieldsMusicBox.cs +++ /dev/null @@ -1,8 +0,0 @@ -using UnCalamityModMusic.Common; - -namespace UnCalamityModMusic.Content.Tiles -{ - public class GlowingMushroomFieldsMusicBox : MusicBoxTile - { - } -} \ No newline at end of file diff --git a/Content/Tiles/GlowingMushroomsMusicBox.cs b/Content/Tiles/GlowingMushroomsMusicBox.cs new file mode 100644 index 0000000..6e6051d --- /dev/null +++ b/Content/Tiles/GlowingMushroomsMusicBox.cs @@ -0,0 +1,10 @@ +using Terraria.ModLoader; +using UnCalamityModMusic.Common; + +namespace UnCalamityModMusic.Content.Tiles +{ + [LegacyName("GlowingMushroomFieldsMusicBox")] + public class GlowingMushroomsMusicBox : MusicBoxTile + { + } +} \ No newline at end of file diff --git a/Content/Tiles/GlowingMushroomFieldsMusicBox.png b/Content/Tiles/GlowingMushroomsMusicBox.png similarity index 100% rename from Content/Tiles/GlowingMushroomFieldsMusicBox.png rename to Content/Tiles/GlowingMushroomsMusicBox.png diff --git a/Content/Tiles/GlowingMushroomFieldsMusicBox_Highlight.png b/Content/Tiles/GlowingMushroomsMusicBox_Highlight.png similarity index 100% rename from Content/Tiles/GlowingMushroomFieldsMusicBox_Highlight.png rename to Content/Tiles/GlowingMushroomsMusicBox_Highlight.png diff --git a/Localization/en-US.hjson b/Localization/en-US.hjson index b5d001d..65ca557 100644 --- a/Localization/en-US.hjson +++ b/Localization/en-US.hjson @@ -33,22 +33,24 @@ Mods: { Label: "[i:MusicBoxOWRain] Override Otherworldly Music" Tooltip: ''' - Toggles whether VCMM music will play over Otherworldly music. + Toggles whether VCMM music will play above Otherworldly music. This option only works if the Party Girl's music toggle is enabled. ''' } OverrideAnahitasLureMusic: { Label: "[i:UnCalamityModMusic/OceanDayMusicBox] Override Anahita's Lure Music" - Tooltip: Toggles whether Ocean music will play over Anahita's Lure music. + Tooltip: Toggles whether Ocean music will play above Anahita's Lure music. } PrioritizeMusicFromOtherMods: { Label: "[i:WorldGlobe] Prioritize Music From Other Mods" Tooltip: ''' - Toggles whether other vanilla-replacing music should play over VCMM music. - Any further music customization should be found in other mod configs. + Toggles whether VCMM music will play below vanilla-replacing music from other mods. + VCMM music weight is lowered down to 40% when enabled. + Music weight is set to the neutral value of 50% when disabled. + Any further mod compatibility should be configured in other mods. ''' } } @@ -194,8 +196,8 @@ Mods: { Tooltip: Plays 'Amidst the Minerals' by Heart Plus Up! } - GlowingMushroomFieldsMusicBox: { - DisplayName: Music Box (Glowing Mushroom Fields) + GlowingMushroomsMusicBox: { + DisplayName: Music Box (Glowing Mushrooms) Tooltip: Plays 'Psychedelic Depths' by Heart Plus Up! } @@ -403,7 +405,7 @@ Mods: { ForestDayMorning: A Legend's Strife (Epiphany) ForestNight: Laze of the Sky Geodes: Amidst the Minerals - GlowingMushroomFields: Psychedelic Depths + GlowingMushrooms: Psychedelic Depths HardmodeInterlude: The Resurrection of a Cruel World JungleDay: Nature's Reprieve KingSlime: Gelatinous Monarch diff --git a/build.txt b/build.txt index e9ccdf4..0a7158b 100644 --- a/build.txt +++ b/build.txt @@ -1,5 +1,5 @@ author = The VCMM Dev Team -version = 2.1.2 +version = 2.1.3 displayName = Vanilla Calamity Mod Music weakReferences = CalamityMod homepage = https://calamitymod.com diff --git a/icon_small.png b/icon_small.png new file mode 100644 index 0000000..3d1d7c0 Binary files /dev/null and b/icon_small.png differ