This commit is contained in:
Anuken 2024-01-17 08:51:18 -05:00
parent 944797f8e1
commit 22b1639b6f

View file

@ -17,7 +17,7 @@ import static mindustry.Vars.*;
/** Controls playback of multiple audio tracks.*/
public class SoundControl{
public float finTime = 120f, foutTime = 120f, musicInterval = 3f * Time.toMinutes, musicChance = 0.6f, musicWaveChance = 0.46f;
public float finTime = 120f, foutTime = 120f, musicInterval = 3f * Time.toMinutes, musicChance = 0.8f, musicWaveChance = 0.46f;
/** normal, ambient music, plays at any time */
public Seq<Music> ambientMusic = Seq.with();
@ -28,6 +28,7 @@ public class SoundControl{
protected Music lastRandomPlayed;
protected Interval timer = new Interval(4);
protected long lastPlayed;
protected @Nullable Music current;
protected float fade;
protected boolean silenced;
@ -55,6 +56,10 @@ public class SoundControl{
}));
setupFilters();
Events.on(ResetEvent.class, e -> {
lastPlayed = Time.millis();
});
}
protected void setupFilters(){
@ -160,9 +165,10 @@ public class SoundControl{
silence();
//play music at intervals
if(timer.get(musicInterval)){
if(Time.timeSinceMillis(lastPlayed) > 1000 * musicInterval / 60f){
//chance to play it per interval
if(Mathf.chance(musicChance)){
lastPlayed = Time.millis();
playRandom();
}
}