mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-13 01:07:30 +07:00
SoundEffect's sound should be delayed by its startDelay (#9502)
* SoundEffect's sound should be delayed by its startDelay * h
This commit is contained in:
@ -21,18 +21,32 @@ public class SoundEffect extends Effect{
|
|||||||
public Effect effect;
|
public Effect effect;
|
||||||
|
|
||||||
public SoundEffect(){
|
public SoundEffect(){
|
||||||
|
startDelay = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SoundEffect(Sound sound, Effect effect){
|
public SoundEffect(Sound sound, Effect effect){
|
||||||
|
this();
|
||||||
this.sound = sound;
|
this.sound = sound;
|
||||||
this.effect = effect;
|
this.effect = effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(){
|
||||||
|
if(startDelay < 0){
|
||||||
|
startDelay = effect.startDelay;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create(float x, float y, float rotation, Color color, Object data){
|
public void create(float x, float y, float rotation, Color color, Object data){
|
||||||
if(!shouldCreate()) return;
|
if(!shouldCreate()) return;
|
||||||
|
|
||||||
sound.at(x, y, Mathf.random(minPitch, maxPitch), Mathf.random(minVolume, maxVolume));
|
if(startDelay > 0){
|
||||||
|
Time.run(startDelay, () -> sound.at(x, y, Mathf.random(minPitch, maxPitch), Mathf.random(minVolume, maxVolume)));
|
||||||
|
}else{
|
||||||
|
sound.at(x, y, Mathf.random(minPitch, maxPitch), Mathf.random(minVolume, maxVolume));
|
||||||
|
}
|
||||||
|
|
||||||
effect.create(x, y, rotation, color, data);
|
effect.create(x, y, rotation, color, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user