Exemplo n.º 1
0
 //minimize GC alloc of struct.Equals(object o) with this method instead
 public bool Equals(PlayerMusicContext pmc)
 {
     return(environment == pmc.environment &&
            weather == pmc.weather &&
            time == pmc.time &&
            arrested == pmc.arrested);
 }
Exemplo n.º 2
0
        void UpdateSong(bool forceChange = false)
        {
            if (!songPlayer)
            {
                return;
            }

            // Play song if no song was playing or if playlist changed
            // Switch to another random song to prevent fatigue of hearing same song repeatedly

            PlayerMusicUpdateContext();

            // Update current playlist if context changed
            if (!currentContext.Equals(lastContext) || (!songPlayer.IsPlaying && playSong) || forceChange)
            {
                lastContext = currentContext;

                SongFiles[] 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 || forceChange)
                {
                    PlayAnotherSong();
                    return;
                }
            }

            if (!songPlayer.IsPlaying)
            {
                PlayCurrentSong();
            }
        }