Merge remote-tracking branch 'origin/7.0-features' into 7.0-features

This commit is contained in:
Epowerj
2022-04-13 22:09:57 -04:00
2 changed files with 12 additions and 22 deletions

View File

@ -138,8 +138,12 @@ public class Effect{
create(x, y, rotation, Color.white, data); create(x, y, rotation, Color.white, data);
} }
protected void create(float x, float y, float rotation, Color color, Object data){ public boolean shouldCreate(){
if(headless || this == Fx.none || !Vars.renderer.enableEffects) return; return !headless && this != Fx.none && Vars.renderer.enableEffects;
}
public void create(float x, float y, float rotation, Color color, Object data){
if(!shouldCreate()) return;
if(Core.camera.bounds(Tmp.r1).overlaps(Tmp.r2.setCentered(x, y, clip))){ if(Core.camera.bounds(Tmp.r1).overlaps(Tmp.r2.setCentered(x, y, clip))){
if(!initialized){ if(!initialized){
@ -150,7 +154,7 @@ public class Effect{
if(startDelay <= 0f){ if(startDelay <= 0f){
add(x, y, rotation, color, data); add(x, y, rotation, color, data);
}else{ }else{
Time.runTask(startDelay, () -> add(x, y, rotation, color, data)); Time.run(startDelay, () -> add(x, y, rotation, color, data));
} }
} }
} }

View File

@ -1,5 +1,6 @@
package mindustry.entities.effect; package mindustry.entities.effect;
import arc.graphics.*;
import mindustry.entities.*; import mindustry.entities.*;
/** Renders multiple particle effects at once. */ /** Renders multiple particle effects at once. */
@ -7,33 +8,18 @@ public class MultiEffect extends Effect{
public Effect[] effects = {}; public Effect[] effects = {};
public MultiEffect(){ public MultiEffect(){
clip = 100f;
} }
public MultiEffect(Effect... effects){ public MultiEffect(Effect... effects){
this();
this.effects = effects; this.effects = effects;
} }
@Override @Override
public void init(){ public void create(float x, float y, float rotation, Color color, Object data){
for(Effect f : effects){ if(!shouldCreate()) return;
f.init();
clip = Math.max(clip, f.clip);
lifetime = Math.max(lifetime, f.lifetime);
}
}
@Override for(var effect : effects){
public void render(EffectContainer e){ effect.create(x, y, rotation, color, data);
int index = 0;
for(Effect f : effects){
int i = ++index;
e.scaled(f.lifetime, cont -> {
cont.id = e.id + i;
f.render(cont);
});
clip = Math.max(clip, f.clip);
} }
} }
} }