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();
}
}

View file

@ -41,6 +41,7 @@ public class Drawf{
Draw.reset();
}
/** Sets Draw.z to the text layer, and returns the previous layer. */
public static float text(){
float z = Draw.z();
if(renderer.pixelator.enabled()){
@ -275,7 +276,7 @@ public class Drawf{
Draw.reset();
}
/** Draws a sprite that should be lightwise correct. Provided sprite must be symmetrical. */
/** Draws a sprite that should be light-wise correct, when rotated. Provided sprite must be symmetrical in shape. */
public static void spinSprite(TextureRegion region, float x, float y, float r){
r = Mathf.mod(r, 90f);
Draw.rect(region, x, y, r);

View file

@ -120,7 +120,7 @@ public class GenericCrafter extends Block{
warmup = Mathf.approachDelta(warmup, 1f, warmupSpeed);
if(Mathf.chanceDelta(updateEffectChance)){
updateEffect.at(getX() + Mathf.range(size * 4f), getY() + Mathf.range(size * 4));
updateEffect.at(x + Mathf.range(size * 4f), y + Mathf.range(size * 4));
}
}else{
warmup = Mathf.approachDelta(warmup, 0f, warmupSpeed);

View file

@ -49,7 +49,7 @@ public class LiquidConverter extends GenericCrafter{
if(cons.valid()){
if(Mathf.chanceDelta(updateEffectChance)){
updateEffect.at(getX() + Mathf.range(size * 4f), getY() + Mathf.range(size * 4));
updateEffect.at(x + Mathf.range(size * 4f), y + Mathf.range(size * 4));
}
warmup = Mathf.lerpDelta(warmup, 1f, 0.02f);

View file

@ -108,7 +108,7 @@ public class SolidPump extends Pump{
lastPump = maxPump;
warmup = Mathf.lerpDelta(warmup, 1f, 0.02f);
if(Mathf.chance(delta() * updateEffectChance))
updateEffect.at(getX() + Mathf.range(size * 2f), getY() + Mathf.range(size * 2f));
updateEffect.at(x + Mathf.range(size * 2f), y + Mathf.range(size * 2f));
}else{
warmup = Mathf.lerpDelta(warmup, 0f, 0.02f);
lastPump = 0f;