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
commit 729aa6e20e
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);
}
protected void create(float x, float y, float rotation, Color color, Object data){
if(headless || this == Fx.none || !Vars.renderer.enableEffects) return;
public boolean shouldCreate(){
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(!initialized){
@ -150,7 +154,7 @@ public class Effect{
if(startDelay <= 0f){
add(x, y, rotation, color, data);
}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;
import arc.graphics.*;
import mindustry.entities.*;
/** Renders multiple particle effects at once. */
@ -7,33 +8,18 @@ public class MultiEffect extends Effect{
public Effect[] effects = {};
public MultiEffect(){
clip = 100f;
}
public MultiEffect(Effect... effects){
this();
this.effects = effects;
}
@Override
public void init(){
for(Effect f : effects){
f.init();
clip = Math.max(clip, f.clip);
lifetime = Math.max(lifetime, f.lifetime);
}
}
public void create(float x, float y, float rotation, Color color, Object data){
if(!shouldCreate()) return;
@Override
public void render(EffectContainer e){
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);
for(var effect : effects){
effect.create(x, y, rotation, color, data);
}
}
}