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

◆ FindReplacementTrack()

IAudioTrack Terraria.Audio.LegacyAudioSystem.FindReplacementTrack ( List< IContentSource > sources,
string assetPath )
inlineprivate

Definition at line 77 of file LegacyAudioSystem.cs.

78 {
79 IAudioTrack audioTrack = null;
80 for (int i = 0; i < sources.Count; i++)
81 {
83 if (!val.HasAsset(assetPath))
84 {
85 continue;
86 }
87 string extension = val.GetExtension(assetPath);
88 try
89 {
90 IAudioTrack audioTrack2 = null;
91 switch (extension)
92 {
93 case ".ogg":
94 audioTrack2 = new OGGAudioTrack(val.OpenStream(assetPath));
95 break;
96 case ".wav":
97 audioTrack2 = new WAVAudioTrack(val.OpenStream(assetPath));
98 break;
99 case ".mp3":
100 audioTrack2 = new MP3AudioTrack(val.OpenStream(assetPath));
101 break;
102 }
103 if (audioTrack2 != null)
104 {
105 audioTrack?.Dispose();
107 }
108 }
109 catch
110 {
111 string textToShow = "A resource pack failed to load " + assetPath + "!";
112 Main.IssueReporter.AddReport(textToShow);
113 Main.IssueReporterIndicator.AttemptLettingPlayerKnow();
114 }
115 }
116 return audioTrack;
117 }
Stream OpenStream(string fullAssetName)
Must be threadsafe!
bool HasAsset(string assetName)
Checks Rejections and GetExtension to determine if an asset exists.
string GetExtension(string assetName)
Must be threadsafe!

References System.Collections.Generic.Dictionary< TKey, TValue >.Count, ReLogic.Content.Sources.IContentSource.GetExtension(), ReLogic.Content.Sources.IContentSource.HasAsset(), Terraria.Main.IssueReporter, Terraria.Main.IssueReporterIndicator, and ReLogic.Content.Sources.IContentSource.OpenStream().

Referenced by Terraria.Audio.LegacyAudioSystem.LoadFromSources().