Fixed discarded shells appearing in water

This commit is contained in:
Anuken 2018-05-03 15:19:00 -04:00
parent 2af750cfec
commit 3a3c23d2f1
2 changed files with 16 additions and 9 deletions

View File

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

View File

@ -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;