public MusicPlaylist(World world, MusicPlaylistInfo info) { this.info = info; this.world = world; if (info.DisableWorldSounds) { Game.Sound.DisableWorldSounds = true; } IsMusicInstalled = world.Map.Rules.InstalledMusic.Any(); if (!IsMusicInstalled) { return; } playlist = world.Map.Rules.InstalledMusic .Where(a => !a.Value.Hidden) .Select(a => a.Value) .ToArray(); random = playlist.Shuffle(Game.CosmeticRandom).ToArray(); IsMusicAvailable = playlist.Any(); if (SongExists(info.BackgroundMusic)) { currentSong = currentBackgroundSong = world.Map.Rules.Music[info.BackgroundMusic]; CurrentSongIsBackground = true; } else { // Start playback with a random song currentSong = random.FirstOrDefault(); } if (SongExists(info.StartingMusic)) { currentSong = world.Map.Rules.Music[info.StartingMusic]; CurrentSongIsBackground = false; } Play(); }
public MusicPlaylist(World world, MusicPlaylistInfo info) { this.info = info; this.world = world; IsMusicInstalled = world.Map.Rules.InstalledMusic.Any(); if (!IsMusicInstalled) { return; } playlist = world.Map.Rules.InstalledMusic .Where(a => !a.Value.Hidden) .Select(a => a.Value) .ToArray(); random = playlist.Shuffle(Game.CosmeticRandom).ToArray(); IsMusicAvailable = playlist.Any(); if (SongExists(info.BackgroundMusic)) { currentSong = currentBackgroundSong = world.Map.Rules.Music[info.BackgroundMusic]; CurrentSongIsBackground = true; } else { // Start playback with a random song, but only if the player has installed more music var installData = Game.ModData.Manifest.Get <ContentInstaller>(); if (playlist.Length > installData.ShippedSoundtracks) { currentSong = random.FirstOrDefault(); } } if (SongExists(info.StartingMusic)) { currentSong = world.Map.Rules.Music[info.StartingMusic]; CurrentSongIsBackground = false; } Play(); }