From 6d280981809d43379ecc7365131030744586e999 Mon Sep 17 00:00:00 2001 From: genNAowl <68400583+genNAowl@users.noreply.github.com> Date: Thu, 3 Jun 2021 11:31:23 -0700 Subject: [PATCH] Fix Boat Trails Being Drawn on Land (#5340) * update * Revert "update" This reverts commit 6ff3523276c0d0ff8847262055ea728e3294615f. * Hacky Implementation * Revert "Hacky Implementation" This reverts commit 632121312d0189428f51927c9dde585dba67e147. * Not so Hacky Implementation Co-authored-by: Leonwang4234 <62972692+Leonwang4234@users.noreply.github.com> Co-authored-by: Leonwang4234 Co-authored-by: Anuken --- core/src/mindustry/entities/comp/WaterMoveComp.java | 4 +++- core/src/mindustry/graphics/Trail.java | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/mindustry/entities/comp/WaterMoveComp.java b/core/src/mindustry/entities/comp/WaterMoveComp.java index 346a2898f8..220386e31d 100644 --- a/core/src/mindustry/entities/comp/WaterMoveComp.java +++ b/core/src/mindustry/entities/comp/WaterMoveComp.java @@ -15,6 +15,8 @@ import mindustry.type.*; import mindustry.world.*; import mindustry.world.blocks.environment.*; +import static mindustry.Vars.*; + @Component abstract class WaterMoveComp implements Posc, Velc, Hitboxc, Flyingc, Unitc{ @Import float x, y, rotation; @@ -31,7 +33,7 @@ abstract class WaterMoveComp implements Posc, Velc, Hitboxc, Flyingc, Unitc{ int sign = i == 0 ? -1 : 1; float cx = Angles.trnsx(rotation - 90, type.trailX * sign, type.trailY) + x, cy = Angles.trnsy(rotation - 90, type.trailX * sign, type.trailY) + y; - t.update(cx, cy); + t.update(cx, cy, world.floorWorld(cx, cy).isLiquid ? 1 : 0); } } diff --git a/core/src/mindustry/graphics/Trail.java b/core/src/mindustry/graphics/Trail.java index fc998e64ea..5fc194c51d 100644 --- a/core/src/mindustry/graphics/Trail.java +++ b/core/src/mindustry/graphics/Trail.java @@ -40,6 +40,7 @@ public class Trail{ float[] items = points.items; int i = points.size - 3; float x1 = items[i], y1 = items[i + 1], w1 = items[i + 2], w = w1 * width / (points.size/3) * i/3f * 2f; + if(w1 <= 0.001f) return; Draw.rect("hcircle", x1, y1, w, w, -Mathf.radDeg * lastAngle + 180f); Draw.reset(); } @@ -56,6 +57,7 @@ public class Trail{ float size = width / (points.size/3); float z1 = lastAngle; float z2 = -Angles.angleRad(x2, y2, lx, ly); + if(w1 <= 0.001f || w2 <= 0.001f) continue; float cx = Mathf.sin(z1) * i/3f * size * w1, cy = Mathf.cos(z1) * i/3f * size * w1, nx = Mathf.sin(z2) * (i/3f + 1) * size * w2, ny = Mathf.cos(z2) * (i/3f + 1) * size * w2;