private void AutoloadSounds(IList <Type> modSounds) { IList <string> sounds = ModLoader.GetSounds(this); string soundDir = Name + "/Sounds/"; IDictionary <string, Type> modSoundNames = new Dictionary <string, Type>(); foreach (Type type in modSounds) { string modSoundName = (type.Namespace + "." + type.Name).Replace('.', '/'); modSoundNames[modSoundName] = type; } foreach (string sound in sounds) { if (sound.IndexOf(soundDir) == 0) { string substring = sound.Substring(soundDir.Length); SoundType soundType = SoundType.Custom; if (substring.IndexOf("Item/") == 0) { soundType = SoundType.Item; } else if (substring.IndexOf("NPCHit/") == 0) { soundType = SoundType.NPCHit; } else if (substring.IndexOf("NPCKilled/") == 0) { soundType = SoundType.NPCKilled; } else if (substring.IndexOf("Music/") == 0) { soundType = SoundType.Music; } string className = sound.Replace('/', '.'); ModSound modSound = null; if (modSoundNames.ContainsKey(sound)) { modSound = (ModSound)Activator.CreateInstance(modSoundNames[sound]); } AddSound(soundType, sound, modSound); } } }