SCal Acceptance event

This commit is contained in:
NycroV committed 2024-05-28 18:54:55 -04:00
1 parent cbc8f1b0d6
commit e218a655b1
2 files changed
+23 -1

No files matched your search

+23 -1
View File
@@ -1,4 +1,7 @@
using Terraria;
using System.Collections.Generic;
using System.Reflection;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using AbyssLayer1MusicBox = CalamityModMusic.Items.Placeables.AbyssLayer1MusicBox;
using AbyssLayer2MusicBox = CalamityModMusic.Items.Placeables.AbyssLayer2MusicBox;
@@ -141,6 +144,25 @@ namespace CalamityModMusic
AddMusicBox("Sounds/Music/Interlude1", ModContent.ItemType<Interlude1MusicBox>(), ModContent.TileType<Tiles.Interlude1MusicBox>());
AddMusicBox("Sounds/Music/Interlude2", ModContent.ItemType<Interlude2MusicBox>(), ModContent.TileType<Tiles.Interlude2MusicBox>());
AddMusicBox("Sounds/Music/Interlude3", ModContent.ItemType<Interlude3MusicBox>(), ModContent.TileType<Tiles.Interlude3MusicBox>());
// This makes it so that the SCal "Acceptance" event records a regular acceptance music box, despite them
// technically being 2 separate tracks
if (!Main.dedServ)
{
// `musicToItem` is a Dictionary of music slots to item types that is used to
// convert music boxes while music is playing
//
// It is marked as internal, so we need to use reflection to modify it directly, but
// by doing so we can make it so that 2 different tracks point to the same music box
FieldInfo info = typeof(MusicLoader).GetField("musicToItem", BindingFlags.NonPublic | BindingFlags.Static);
var musicToItem = (Dictionary<int, int>)info.GetValue(null);
int musicSlot = MusicLoader.GetMusicSlot(CalamityModMusic.Instance, "CalamitasDefeat_LongFade");
int itemType = ModContent.ItemType<CalamitasDefeatMusicBox>();
musicToItem[musicSlot] = itemType;
info.SetValue(null, musicToItem);
}
}
}
}
Binary file not shown.