mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-03-16 11:51:36 -07:00
Better MultiEffect
This commit is contained in:
parent
2f6ff1d22c
commit
ea4600beb3
2 changed files with 12 additions and 22 deletions
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue