Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add contextual music rarity #5609

Merged
merged 5 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions simulation_parameters/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ public static class Constants

public const float BASE_CELL_DENSITY = 1000;

public const int CONTEXTUAL_MUSIC_RARITY = 3;

public const float MICROBE_MOVEMENT_SOUND_EMIT_COOLDOWN = 1.3f;

// Note that the rotation speed is reversed, i.e. lower values mean faster
Expand Down
13 changes: 12 additions & 1 deletion src/general/Jukebox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,18 @@ private void PlayNextTrackFromList(TrackList list, Func<int, AudioPlayer> getPla
if (tracks.Length == 0)
return;

var random = new XoShiRo128starstar();

if (random.Next(0, Constants.CONTEXTUAL_MUSIC_RARITY) == 0)
{
var contextMusicOnly = tracks.Where(c => c.ExclusiveToContexts != null).ToArray();

if (contextMusicOnly.Length > 0)
{
dligr marked this conversation as resolved.
Show resolved Hide resolved
tracks = contextMusicOnly;
}
}

if (mode == TrackList.Order.Sequential)
{
list.LastPlayedIndex = (list.LastPlayedIndex + 1) % tracks.Length;
Expand All @@ -564,7 +576,6 @@ private void PlayNextTrackFromList(TrackList list, Func<int, AudioPlayer> getPla
}
else
{
var random = new XoShiRo128starstar();
int nextIndex;

if (mode == TrackList.Order.Random)
Expand Down