void Update() { if (!songPlayer) { return; } // Update context UpdatePlayerMusicEnvironment(); UpdatePlayerMusicWeather(); // Switch playlists if context changes or if not playing then select a new song bool overrideSong = false; if (currentPlayerMusicEnvironment != lastPlayerMusicEnvironment || currentPlayerMusicWeather != lastPlayerMusicWeather || !songPlayer.IsPlaying) { lastPlayerMusicEnvironment = currentPlayerMusicEnvironment; lastPlayerMusicWeather = currentPlayerMusicWeather; AssignPlaylist(); SelectCurrentSong(); overrideSong = true; } // Play song if (!songPlayer.IsPlaying || overrideSong) { PlayCurrentSong(); } }
void Update() { if (!songPlayer) { return; } // If streaming world is set, we can ignore track changes before init complete // This helps prevent music starting during first load or on wrong playlist if (StreamingWorld) { if (StreamingWorld.IsInit) { return; } } // Update context UpdatePlayerMusicEnvironment(); UpdatePlayerMusicWeather(); UpdatePlayerMusicTime(); // Update current playlist if context changed bool overrideSong = false; if (currentPlayerMusicEnvironment != lastPlayerMusicEnvironment || currentPlayerMusicWeather != lastPlayerMusicWeather || currentPlayerMusicTime != lastPlayerMusicTime || (!songPlayer.IsPlaying && playSong) || playingArrestedMusic != playerEntity.Arrested) { lastPlayerMusicEnvironment = currentPlayerMusicEnvironment; lastPlayerMusicWeather = currentPlayerMusicWeather; lastPlayerMusicTime = currentPlayerMusicTime; lastPlaylist = currentPlaylist; // Get playlist for current context AssignPlaylist(); // If current playlist is different from last playlist, pick a song from the current playlist if (currentPlaylist != lastPlaylist) { SelectCurrentSong(); overrideSong = true; } } // Play song if no song was playing or if playlist changed // Switch to another random song to prevent fatigue of hearing same song repeatedly if (!songPlayer.IsPlaying || overrideSong) { PlayCurrentSong(); } }
void Update() { if (!songPlayer) { return; } // If streaming world is set, we can ignore track changes before init complete // This helps prevent music starting during first load or on wrong playlist if (StreamingWorld) { if (StreamingWorld.IsInit) { return; } } // Update context UpdatePlayerMusicEnvironment(); UpdatePlayerMusicWeather(); UpdatePlayerMusicTime(); // Switch playlists if context changes or if not playing then select a new song bool overrideSong = false; if (currentPlayerMusicEnvironment != lastPlayerMusicEnvironment || currentPlayerMusicWeather != lastPlayerMusicWeather || currentPlayerMusicTime != lastPlayerMusicTime || (!songPlayer.IsPlaying && playSong)) { // Keep song if playing the same weather, but not when entering dungeons if (currentPlayerMusicWeather != PlayerMusicWeather.Normal && currentPlayerMusicWeather == lastPlayerMusicWeather && currentPlayerMusicEnvironment != PlayerMusicEnvironment.DungeonInterior) { return; } // Change song lastPlayerMusicEnvironment = currentPlayerMusicEnvironment; lastPlayerMusicWeather = currentPlayerMusicWeather; lastPlayerMusicTime = currentPlayerMusicTime; AssignPlaylist(); SelectCurrentSong(); overrideSong = true; } // Play song if (!songPlayer.IsPlaying || overrideSong) { PlayCurrentSong(); } }
void Update() { if (!songPlayer) { return; } // Update context UpdatePlayerMusicEnvironment(); UpdatePlayerMusicWeather(); UpdatePlayerMusicTime(); // Update current playlist if context changed bool overrideSong = false; if (currentPlayerMusicEnvironment != lastPlayerMusicEnvironment || currentPlayerMusicWeather != lastPlayerMusicWeather || currentPlayerMusicTime != lastPlayerMusicTime || (!songPlayer.IsPlaying && playSong) || playingArrestedMusic != playerEntity.Arrested) { lastPlayerMusicEnvironment = currentPlayerMusicEnvironment; lastPlayerMusicWeather = currentPlayerMusicWeather; lastPlayerMusicTime = currentPlayerMusicTime; lastPlaylist = currentPlaylist; // Get playlist for current context AssignPlaylist(); // If current playlist is different from last playlist, pick a song from the current playlist if (currentPlaylist != lastPlaylist) { SelectCurrentSong(); overrideSong = true; } } // Play song if no song was playing or if playlist changed // Switch to another random song to prevent fatigue of hearing same song repeatedly if (!songPlayer.IsPlaying || overrideSong) { PlayCurrentSong(); } }
void UpdatePlayerMusicEnvironment() { if (!playerEnterExit || !LocalPlayerGPS || !dfUnity) { return; } // Exteriors if (!playerEnterExit.IsPlayerInside) { if (LocalPlayerGPS.IsPlayerInLocationRect) { switch (LocalPlayerGPS.CurrentLocationType) { case DFRegion.LocationTypes.DungeonKeep: case DFRegion.LocationTypes.DungeonLabyrinth: case DFRegion.LocationTypes.DungeonRuin: currentPlayerMusicEnvironment = PlayerMusicEnvironment.DungeonExterior; break; case DFRegion.LocationTypes.GraveyardCommon: case DFRegion.LocationTypes.GraveyardForgotten: currentPlayerMusicEnvironment = PlayerMusicEnvironment.Graveyard; break; case DFRegion.LocationTypes.HomeFarms: case DFRegion.LocationTypes.HomePoor: case DFRegion.LocationTypes.HomeWealthy: case DFRegion.LocationTypes.Tavern: case DFRegion.LocationTypes.TownCity: case DFRegion.LocationTypes.TownHamlet: case DFRegion.LocationTypes.TownVillage: case DFRegion.LocationTypes.ReligionTemple: currentPlayerMusicEnvironment = PlayerMusicEnvironment.City; break; default: currentPlayerMusicEnvironment = PlayerMusicEnvironment.Wilderness; break; } } else { currentPlayerMusicEnvironment = PlayerMusicEnvironment.Wilderness; } return; } // Dungeons if (playerEnterExit.IsPlayerInsideDungeon) { if (playerEnterExit.IsPlayerInsideDungeonPalace) { currentPlayerMusicEnvironment = PlayerMusicEnvironment.Palace; } else { currentPlayerMusicEnvironment = PlayerMusicEnvironment.DungeonInterior; } return; } // Interiors if (playerEnterExit.IsPlayerInside) { switch (playerEnterExit.BuildingType) { case DFLocation.BuildingTypes.Alchemist: case DFLocation.BuildingTypes.Armorer: case DFLocation.BuildingTypes.Bank: case DFLocation.BuildingTypes.Bookseller: case DFLocation.BuildingTypes.ClothingStore: case DFLocation.BuildingTypes.FurnitureStore: case DFLocation.BuildingTypes.GemStore: case DFLocation.BuildingTypes.GeneralStore: case DFLocation.BuildingTypes.Library: case DFLocation.BuildingTypes.PawnShop: case DFLocation.BuildingTypes.WeaponSmith: currentPlayerMusicEnvironment = PlayerMusicEnvironment.Shop; break; case DFLocation.BuildingTypes.Tavern: currentPlayerMusicEnvironment = PlayerMusicEnvironment.Tavern; break; case DFLocation.BuildingTypes.GuildHall: currentPlayerMusicEnvironment = PlayerMusicEnvironment.Guild; break; case DFLocation.BuildingTypes.Palace: currentPlayerMusicEnvironment = PlayerMusicEnvironment.Palace; break; default: currentPlayerMusicEnvironment = PlayerMusicEnvironment.Interior; break; } return; } }
void UpdatePlayerMusicEnvironment() { if (!playerEnterExit || !LocalPlayerGPS || !dfUnity) return; // Exteriors if (!playerEnterExit.IsPlayerInside) { if (LocalPlayerGPS.IsPlayerInLocationRect) { switch (LocalPlayerGPS.CurrentLocationType) { case DFRegion.LocationTypes.DungeonKeep: case DFRegion.LocationTypes.DungeonLabyrinth: case DFRegion.LocationTypes.DungeonRuin: currentPlayerMusicEnvironment = PlayerMusicEnvironment.DungeonExterior; break; case DFRegion.LocationTypes.GraveyardCommon: case DFRegion.LocationTypes.GraveyardForgotten: currentPlayerMusicEnvironment = PlayerMusicEnvironment.Graveyard; break; case DFRegion.LocationTypes.HomeFarms: case DFRegion.LocationTypes.HomePoor: case DFRegion.LocationTypes.HomeWealthy: case DFRegion.LocationTypes.Tavern: case DFRegion.LocationTypes.TownCity: case DFRegion.LocationTypes.TownHamlet: case DFRegion.LocationTypes.TownVillage: case DFRegion.LocationTypes.ReligionTemple: currentPlayerMusicEnvironment = PlayerMusicEnvironment.City; break; default: currentPlayerMusicEnvironment = PlayerMusicEnvironment.Wilderness; break; } } else { currentPlayerMusicEnvironment = PlayerMusicEnvironment.Wilderness; } return; } // Dungeons if (playerEnterExit.IsPlayerInsideDungeon) { if (playerEnterExit.IsPlayerInsideDungeonPalace) currentPlayerMusicEnvironment = PlayerMusicEnvironment.Palace; else currentPlayerMusicEnvironment = PlayerMusicEnvironment.DungeonInterior; return; } // Interiors if (playerEnterExit.IsPlayerInside) { switch (playerEnterExit.BuildingType) { case DFLocation.BuildingTypes.Alchemist: case DFLocation.BuildingTypes.Armorer: case DFLocation.BuildingTypes.Bank: case DFLocation.BuildingTypes.Bookseller: case DFLocation.BuildingTypes.ClothingStore: case DFLocation.BuildingTypes.FurnitureStore: case DFLocation.BuildingTypes.GemStore: case DFLocation.BuildingTypes.GeneralStore: case DFLocation.BuildingTypes.Library: case DFLocation.BuildingTypes.PawnShop: case DFLocation.BuildingTypes.WeaponSmith: currentPlayerMusicEnvironment = PlayerMusicEnvironment.Shop; break; case DFLocation.BuildingTypes.Tavern: currentPlayerMusicEnvironment = PlayerMusicEnvironment.Tavern; break; case DFLocation.BuildingTypes.GuildHall: currentPlayerMusicEnvironment = PlayerMusicEnvironment.Guild; break; case DFLocation.BuildingTypes.Palace: currentPlayerMusicEnvironment = PlayerMusicEnvironment.Palace; break; default: currentPlayerMusicEnvironment = PlayerMusicEnvironment.Interior; break; } return; } }
void Update() { if (!songPlayer) return; // If streaming world is set, we can ignore track changes before init complete // This helps prevent music starting during first load or on wrong playlist if (StreamingWorld) { if (StreamingWorld.IsInit) return; } // Update context UpdatePlayerMusicEnvironment(); UpdatePlayerMusicWeather(); UpdatePlayerMusicTime(); // Switch playlists if context changes or if not playing then select a new song bool overrideSong = false; if (currentPlayerMusicEnvironment != lastPlayerMusicEnvironment || currentPlayerMusicWeather != lastPlayerMusicWeather || currentPlayerMusicTime != lastPlayerMusicTime || (!songPlayer.IsPlaying && playSong)) { // Keep song if playing the same weather, but not when entering dungeons if (currentPlayerMusicWeather != PlayerMusicWeather.Normal && currentPlayerMusicWeather == lastPlayerMusicWeather && currentPlayerMusicEnvironment != PlayerMusicEnvironment.DungeonInterior) { return; } // Change song lastPlayerMusicEnvironment = currentPlayerMusicEnvironment; lastPlayerMusicWeather = currentPlayerMusicWeather; lastPlayerMusicTime = currentPlayerMusicTime; AssignPlaylist(); SelectCurrentSong(); overrideSong = true; } // Play song if (!songPlayer.IsPlaying || overrideSong) PlayCurrentSong(); }