This commit is contained in:
Anuken
2021-07-19 15:20:53 -04:00
parent 0c46d5088c
commit 6b7a63aba5
5 changed files with 20 additions and 23 deletions

View File

@@ -141,27 +141,23 @@ public class Effect{
}
public static void create(Effect effect, float x, float y, float rotation, Color color, Object data){
if(headless || effect == Fx.none) return;
if(Core.settings.getBool("effects")){
Rect view = Core.camera.bounds(Tmp.r1);
Rect pos = Tmp.r2.setSize(effect.clip).setCenter(x, y);
if(headless || effect == Fx.none || !Core.settings.getBool("effects")) return;
if(view.overlaps(pos)){
if(!effect.initialized){
effect.initialized = true;
effect.init();
}
EffectState entity = EffectState.create();
entity.effect = effect;
entity.rotation = rotation;
entity.data = data;
entity.lifetime = effect.lifetime;
entity.set(x, y);
entity.color.set(color);
if(effect.followParent && data instanceof Posc) entity.parent = ((Posc)data);
entity.add();
if(Core.camera.bounds(Tmp.r1).overlaps(Tmp.r2.setCentered(x, y, effect.clip))){
if(!effect.initialized){
effect.initialized = true;
effect.init();
}
EffectState entity = EffectState.create();
entity.effect = effect;
entity.rotation = rotation;
entity.data = data;
entity.lifetime = effect.lifetime;
entity.set(x, y);
entity.color.set(color);
if(effect.followParent && data instanceof Posc p) entity.parent = p;
entity.add();
}
}