From 3a3c23d2f14e1169a01879f2a73a7bd8d996457b Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 3 May 2018 15:19:00 -0400 Subject: [PATCH] Fixed discarded shells appearing in water --- core/src/io/anuke/mindustry/core/Renderer.java | 11 +++-------- .../entities/effect/GroundEffectEntity.java | 14 +++++++++++++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index 9b640b88b4..877781582e 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -74,15 +74,14 @@ public class Renderer extends RendererModule{ Rectangle pos = rect2.setSize(effect.size).setCenter(x, y); if(view.overlaps(pos)){ - int id = 0; - if(!(effect instanceof GroundEffect) || ((GroundEffect)effect).isStatic) { + if(!(effect instanceof GroundEffect)) { EffectEntity entity = Pools.obtain(EffectEntity.class); entity.effect = effect; entity.color = color; entity.rotation = rotation; entity.lifetime = effect.lifetime; - id = entity.set(x, y).add(effectGroup).id; + entity.set(x, y).add(effectGroup); if(data instanceof Entity){ entity.setParent((Entity)data); @@ -96,10 +95,6 @@ public class Renderer extends RendererModule{ entity.rotation = rotation; entity.lifetime = effect.lifetime; entity.set(x, y).add(groundEffectGroup); - - if(((GroundEffect)effect).isStatic){ - entity.id = id; - } } } } @@ -241,7 +236,7 @@ public class Renderer extends RendererModule{ if(pixelate) Graphics.flushSurface(); - drawDebug(); + if(showPaths) drawDebug(); drawPlayerNames(); batch.end(); diff --git a/core/src/io/anuke/mindustry/entities/effect/GroundEffectEntity.java b/core/src/io/anuke/mindustry/entities/effect/GroundEffectEntity.java index d7c9a8e0d9..2d230d7294 100644 --- a/core/src/io/anuke/mindustry/entities/effect/GroundEffectEntity.java +++ b/core/src/io/anuke/mindustry/entities/effect/GroundEffectEntity.java @@ -1,5 +1,7 @@ package io.anuke.mindustry.entities.effect; +import io.anuke.mindustry.Vars; +import io.anuke.mindustry.world.Tile; import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Effects.Effect; import io.anuke.ucore.core.Timers; @@ -22,6 +24,10 @@ public class GroundEffectEntity extends EffectEntity { if (!once && time >= lifetime) { once = true; time = 0f; + Tile tile = Vars.world.tileWorld(x, y); + if(tile != null && tile.floor().liquid){ + remove(); + } } else if (once && time >= effect.staticLife) { remove(); } @@ -36,10 +42,16 @@ public class GroundEffectEntity extends EffectEntity { if(once && effect.isStatic) Effects.renderEffect(id, effect, color, lifetime, rotation, x, y, data); - else if(!effect.isStatic) + else Effects.renderEffect(id, effect, color, time, rotation, x, y, data); } + @Override + public void reset() { + super.reset(); + once = false; + } + public static class GroundEffect extends Effect{ public final float staticLife; public final boolean isStatic;