Drawf.Laser with different ends (#5301)

* Laser with different ends

* Allow usage of different ended TractorBeamTurret lasers

* oops

* aaaa

* too. many. commits.

* Remove rotation

* I shouldn't be allowed to edit from the browser.
This commit is contained in:
MEEP of Faith 2021-07-20 08:22:17 -07:00 committed by GitHub
parent 6e967dce70
commit 7656aedb6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 15 deletions

View file

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

View file

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