From 6b7a63aba5118beee42575def38fccbc3b4e229e Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 19 Jul 2021 15:20:53 -0400 Subject: [PATCH] Cleanup --- core/src/mindustry/entities/Effect.java | 34 ++++++++----------- core/src/mindustry/graphics/Drawf.java | 3 +- .../blocks/production/GenericCrafter.java | 2 +- .../blocks/production/LiquidConverter.java | 2 +- .../world/blocks/production/SolidPump.java | 2 +- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/core/src/mindustry/entities/Effect.java b/core/src/mindustry/entities/Effect.java index 7b72ecdc01..492ab9af0f 100644 --- a/core/src/mindustry/entities/Effect.java +++ b/core/src/mindustry/entities/Effect.java @@ -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(); } } diff --git a/core/src/mindustry/graphics/Drawf.java b/core/src/mindustry/graphics/Drawf.java index 6c4ea7630b..7865312eb5 100644 --- a/core/src/mindustry/graphics/Drawf.java +++ b/core/src/mindustry/graphics/Drawf.java @@ -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); diff --git a/core/src/mindustry/world/blocks/production/GenericCrafter.java b/core/src/mindustry/world/blocks/production/GenericCrafter.java index 31e3093140..c6c688ae18 100644 --- a/core/src/mindustry/world/blocks/production/GenericCrafter.java +++ b/core/src/mindustry/world/blocks/production/GenericCrafter.java @@ -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); diff --git a/core/src/mindustry/world/blocks/production/LiquidConverter.java b/core/src/mindustry/world/blocks/production/LiquidConverter.java index 0b0ad4a0f9..c01dbfbc36 100644 --- a/core/src/mindustry/world/blocks/production/LiquidConverter.java +++ b/core/src/mindustry/world/blocks/production/LiquidConverter.java @@ -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); diff --git a/core/src/mindustry/world/blocks/production/SolidPump.java b/core/src/mindustry/world/blocks/production/SolidPump.java index ac5e778c47..d9168c82b1 100644 --- a/core/src/mindustry/world/blocks/production/SolidPump.java +++ b/core/src/mindustry/world/blocks/production/SolidPump.java @@ -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;