1using Microsoft.Xna.Framework.Audio;
 
    3using System.Collections.Generic;
 
   13        private static readonly IDictionary<SoundType, int> 
nextSound = 
new Dictionary<SoundType, int>();
 
   14        internal static readonly IDictionary<SoundType, IDictionary<string, int>> sounds = 
new Dictionary<SoundType, IDictionary<string, int>>();
 
   15        internal static readonly IDictionary<SoundType, IDictionary<int, ModSound>> modSounds = 
new Dictionary<SoundType, IDictionary<int, ModSound>>();
 
   16        internal static SoundEffect[] customSounds = 
new SoundEffect[0];
 
   17        internal static SoundEffectInstance[] customSoundInstances = 
new SoundEffectInstance[0];
 
   22        internal static readonly IDictionary<int, int> musicToItem = 
new Dictionary<int, int>();
 
   23        internal static readonly IDictionary<int, int> itemToMusic = 
new Dictionary<int, int>();
 
   24        internal static readonly IDictionary<int, IDictionary<int, int>> tileToMusic = 
new Dictionary<int, IDictionary<int, int>>();
 
   29                sounds[type] = 
new Dictionary<string, int>();
 
   30                modSounds[type] = 
new Dictionary<int, ModSound>();
 
   34        internal static int ReserveSoundID(
SoundType type) {
 
   48            if (sounds[type].ContainsKey(sound)) {
 
   49                return sounds[type][sound];
 
   61        internal static LegacySoundStyle GetLegacySoundSlot(
SoundType type, 
string sound) {
 
   62            if (sounds[type].ContainsKey(sound)) {
 
   63                return new LegacySoundStyle((
int)type, sounds[type][sound]);
 
   70        internal static void ResizeAndFillArrays() {
 
   82                foreach (
string sound 
in sounds[type].Keys) {
 
   85                        GetSoundArray(type)[slot] = ModContent.GetSound(sound);
 
   86                        GetSoundInstanceArray(type)[slot] = GetSoundArray(type)[slot]?.CreateInstance() ?? 
null;
 
   89                        Main.music[slot] = ModContent.GetMusic(sound) ?? 
null;
 
   95        internal static void Unload() {
 
  102                sounds[type].Clear();
 
  103                modSounds[type].Clear();
 
  111        internal static bool PlayModSound(
int type, 
int style, 
float volume, 
float pan, ref SoundEffectInstance soundEffectInstance) {
 
  129            if (!modSounds[soundType].ContainsKey(style)) {
 
  132            soundEffectInstance = modSounds[soundType][style].PlaySound(ref GetSoundInstanceArray(soundType)[style], volume, pan, soundType);
 
  136        internal static int GetNumVanilla(
SoundType type) {
 
  141                    return Main.maxItemSounds + 1;
 
  143                    return Main.maxNPCHitSounds + 1;
 
  145                    return Main.maxNPCKilledSounds + 1;
 
  147                    return Main.maxMusic;
 
  152        internal static SoundEffect[] GetSoundArray(
SoundType type) {
 
  157                    return Main.soundItem;
 
  159                    return Main.soundNPCHit;
 
  161                    return Main.soundNPCKilled;
 
  166        internal static SoundEffectInstance[] GetSoundInstanceArray(
SoundType type) {
 
  169                    return customSoundInstances;
 
  171                    return Main.soundInstanceItem;
 
  173                    return Main.soundInstanceNPCHit;
 
  175                    return Main.soundInstanceNPCKilled;
 
This class is used to keep track of and support the existence of custom sounds that have been added t...
 
const int customSoundType
This value should be passed as the first parameter to Main.PlaySound whenever you want to play a cust...
 
static readonly IDictionary< SoundType, int > nextSound
 
static int GetSoundSlot(SoundType type, string sound)
Returns the style (last parameter passed to Main.PlaySound) of the sound corresponding to the given S...
 
static int SoundCount(SoundType type)
 
SoundType
This is an enum of the types of sound you can add to the game. This is used for determining whether a...