diff --git a/core/src/mindustry/graphics/Drawf.java b/core/src/mindustry/graphics/Drawf.java index 7865312eb5..e55e7b01a0 100644 --- a/core/src/mindustry/graphics/Drawf.java +++ b/core/src/mindustry/graphics/Drawf.java @@ -204,20 +204,24 @@ public class Drawf{ Draw.color(); } - public static void laser(Team team, TextureRegion line, TextureRegion edge, float x, float y, float x2, float y2, float scale){ - laser(team, line, edge, x, y, x2, y2, Mathf.angle(x2 - x, y2 - y), scale); - } - public static void laser(Team team, TextureRegion line, TextureRegion edge, float x, float y, float x2, float y2){ - laser(team, line, edge, x, y, x2, y2, Mathf.angle(x2 - x, y2 - y), 1f); + laser(team, line, edge, edge, x, y, x2, y2, 1f); } - public static void laser(Team team, TextureRegion line, TextureRegion edge, float x, float y, float x2, float y2, float rotation, float scale){ - float scl = 8f * scale * Draw.scl; - float vx = Mathf.cosDeg(rotation) * scl, vy = Mathf.sinDeg(rotation) * scl; + public static void laser(Team team, TextureRegion line, TextureRegion start, TextureRegion end, float x, float y, float x2, float y2){ + laser(team, line, start, end, x, y, x2, y2, 1f); + } - Draw.rect(edge, x, y, edge.width * scale * Draw.scl, edge.height * scale * Draw.scl, rotation + 180); - Draw.rect(edge, x2, y2, edge.width * scale * Draw.scl, edge.height * scale * Draw.scl, rotation); + public static void laser(Team team, TextureRegion line, TextureRegion edge, float x, float y, float x2, float y2, float scale){ + laser(team, line, edge, edge, x, y, x2, y2, scale); + } + + public static void laser(Team team, TextureRegion line, TextureRegion start, TextureRegion end, float x, float y, float x2, float y2, float scale){ + float scl = 8f * scale * Draw.scl, rot = Mathf.angle(x2 - x, y2 - y); + float vx = Mathf.cosDeg(rot) * scl, vy = Mathf.sinDeg(rot) * scl; + + Draw.rect(start, x, y, start.width * scale * Draw.scl, start.height * scale * Draw.scl, rot + 180); + Draw.rect(end, x2, y2, end.width * scale * Draw.scl, end.height * scale * Draw.scl, rot); Lines.stroke(12f * scale); Lines.line(line, x + vx, y + vy, x2 - vx, y2 - vy, false); diff --git a/core/src/mindustry/world/blocks/defense/turrets/TractorBeamTurret.java b/core/src/mindustry/world/blocks/defense/turrets/TractorBeamTurret.java index 50d0f39894..59cec32040 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/TractorBeamTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/TractorBeamTurret.java @@ -20,10 +20,6 @@ import static mindustry.Vars.*; public class TractorBeamTurret extends BaseTurret{ public final int timerTarget = timers++; public float retargetTime = 5f; - - public @Load("block-@size") TextureRegion baseRegion; - public @Load("@-laser") TextureRegion laser; - public @Load("@-laser-end") TextureRegion laserEnd; public float shootCone = 6f; public float shootLength = 5f; @@ -39,6 +35,11 @@ public class TractorBeamTurret extends BaseTurret{ public Sound shootSound = Sounds.tractorbeam; public float shootSoundVolume = 0.9f; + public @Load("block-@size") TextureRegion baseRegion; + public @Load("@-laser") TextureRegion laser; + public @Load(value = "@-laser-start", fallback = "@-laser-end") TextureRegion laserStart; + public @Load("@-laser-end") TextureRegion laserEnd; + public TractorBeamTurret(String name){ super(name); @@ -151,7 +152,7 @@ public class TractorBeamTurret extends BaseTurret{ Draw.mixcol(laserColor, Mathf.absin(4f, 0.6f)); - Drawf.laser(team, laser, laserEnd, + Drawf.laser(team, laser, laserStart, laserEnd, x + Angles.trnsx(ang, shootLength), y + Angles.trnsy(ang, shootLength), lastX, lastY, strength * efficiency() * laserWidth);