TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ AddMusic()

static void Terraria.ModLoader.MusicLoader.AddMusic ( Mod mod,
string musicPath )
inlinestatic

Registers a new music track with the provided mod and its local path to the sound file.

Parameters
modThe mod that owns the music track.
musicPathThe provided mod's local path to the music track file, case-sensitive and without extensions.

Definition at line 90 of file MusicLoader.cs.

91 {
92 if (!mod.loading)
93 {
94 throw new Exception("AddMusic can only be called during mod loading.");
95 }
96 int id = ReserveMusicID();
97 string chosenExtension = "";
98 foreach (string item in supportedExtensions.Where((string extension) => mod.FileExists(musicPath + extension)))
99 {
100 chosenExtension = item;
101 }
102 if (string.IsNullOrEmpty(chosenExtension))
103 {
104 throw new ArgumentException("Given path found no files matching the extensions [ " + string.Join(", ", supportedExtensions) + " ]");
105 }
106 musicPath = mod.Name + "/" + musicPath;
109 }
static readonly string[] supportedExtensions
static readonly Dictionary< string, int > musicByPath
static readonly Dictionary< string, string > musicExtensions

References Terraria.ModLoader.Mod.loading, Terraria.ModLoader.MusicLoader.musicByPath, Terraria.ModLoader.MusicLoader.musicExtensions, Terraria.ModLoader.MusicLoader.ReserveMusicID(), and Terraria.ModLoader.MusicLoader.supportedExtensions.

Referenced by Terraria.ModLoader.MusicLoader.AutoloadMusic().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: