Fixed #9463
This commit is contained in:
@@ -17,7 +17,7 @@ import static mindustry.Vars.*;
|
|||||||
|
|
||||||
/** Controls playback of multiple audio tracks.*/
|
/** Controls playback of multiple audio tracks.*/
|
||||||
public class SoundControl{
|
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 */
|
/** normal, ambient music, plays at any time */
|
||||||
public Seq<Music> ambientMusic = Seq.with();
|
public Seq<Music> ambientMusic = Seq.with();
|
||||||
@@ -28,6 +28,7 @@ public class SoundControl{
|
|||||||
|
|
||||||
protected Music lastRandomPlayed;
|
protected Music lastRandomPlayed;
|
||||||
protected Interval timer = new Interval(4);
|
protected Interval timer = new Interval(4);
|
||||||
|
protected long lastPlayed;
|
||||||
protected @Nullable Music current;
|
protected @Nullable Music current;
|
||||||
protected float fade;
|
protected float fade;
|
||||||
protected boolean silenced;
|
protected boolean silenced;
|
||||||
@@ -55,6 +56,10 @@ public class SoundControl{
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
setupFilters();
|
setupFilters();
|
||||||
|
|
||||||
|
Events.on(ResetEvent.class, e -> {
|
||||||
|
lastPlayed = Time.millis();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setupFilters(){
|
protected void setupFilters(){
|
||||||
@@ -160,9 +165,10 @@ public class SoundControl{
|
|||||||
silence();
|
silence();
|
||||||
|
|
||||||
//play music at intervals
|
//play music at intervals
|
||||||
if(timer.get(musicInterval)){
|
if(Time.timeSinceMillis(lastPlayed) > 1000 * musicInterval / 60f){
|
||||||
//chance to play it per interval
|
//chance to play it per interval
|
||||||
if(Mathf.chance(musicChance)){
|
if(Mathf.chance(musicChance)){
|
||||||
|
lastPlayed = Time.millis();
|
||||||
playRandom();
|
playRandom();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user