Skip to content

Conversation

@dylanlee082
Copy link
Contributor

Brief Description of What This PR Does

Add a check for context specific songs to ensure they are only played once in the category rotation. Once all songs have been played in a category and played once is reset then the context specific song would be played again.

NOTE: It seems like the randomness of this should be removed and always have the context specific song play first and then allow other songs to be played.

Related Issues

closes #5615

Progress Checklist

Note: before starting this checklist the PR should be marked as non-draft.

  • PR author has checked that this PR works as intended and doesn't
    break existing features:
    https://wiki.revolutionarygamesstudio.com/wiki/Testing_Checklist
    (this is important as to not waste the time of Thrive team
    members reviewing this PR)
  • Initial code review passed (this and further items should not be checked by the PR author)
  • Functionality is confirmed working by another person (see above checklist link)
  • Final code review is passed and code conforms to the
    styleguide.

Before merging all CI jobs should finish on this PR without errors, if
there are automatically detected style issues they should be fixed by
the PR author. Merging must follow our
styleguide.

@hhyyrylainen hhyyrylainen added this to the Release 0.8.4 milestone Sep 1, 2025
Copy link
Member

@hhyyrylainen hhyyrylainen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is slightly different than what I had in mind. Or at least I think so.
To me it looks like from the code that this suppresses context specific tracks after playing them once. However the issue calls for preventing a track from playing twice in a row. Meaning that after any other track has been played all the context specific tracks should again be eligible for playing.

@dylanlee082
Copy link
Contributor Author

That is correct, I originally went down that route, but ran into an issue trying to figure out the prior played song for comparison. The TrackList sets LastPlayedIndex and in other places uses that index on the tracks array to identify if the new song != old song, because the assumption is the list will always be in the same order. However, when the context random is hit a new array is created with new indexes, so I had different songs in the same index.

My change kept growing as I tried to work around that, so I was thinking of other ways to approach the issue and in my opinion this approach is simpler and more consistent with how I typically think of a playlist. If I were adding a new music set to music_tracks.json the only option I would think wouldn't respect PlayedOnce would be EntirelyRandom and the other options would go 1-10 or a random order, but still hit all songs.

However, I do recognize that since the contextual music is supposed to bring a consistent feel to an area of the game that playing Song A, Context Music, Song B, Context Music, Song C, Context Music does make sense. I can take another stab at the original changes. Would it be too expensive to store LastPlayedTrack instead of LastPlayedIndex for comparison, or I could compare against something unique per track like resourcePath or a generated id of some kind?

@hhyyrylainen
Copy link
Member

I think it would be a fine enough change for the jukebox class to remember what track it last played as I can foresee quite many situations where it is desirable to skip the immediately previously played track no matter what.

@revolutionary-bot
Copy link

We are currently in feature freeze until the next release.
If your PR is not just a simple fix, then it may take until the release to get reviewed and merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

Make context-specific selected music respect option to not play the same track twice in a row

5 participants