mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-12-15 15:20:57 -08:00
Fixed #9463
This commit is contained in:
parent
944797f8e1
commit
22b1639b6f
1 changed files with 8 additions and 2 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue