Hacky Implementation
This commit is contained in:
@@ -15,6 +15,8 @@ import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
//just a proof of concept
|
||||
@Component
|
||||
abstract class WaterMoveComp implements Posc, Velc, Hitboxc, Flyingc, Unitc{
|
||||
@@ -32,7 +34,8 @@ 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, 1f, !world.floorWorld(cx, cy).isLiquid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ public class Trail{
|
||||
|
||||
public Trail(int length){
|
||||
this.length = length;
|
||||
points = new FloatSeq(length*3);
|
||||
points = new FloatSeq(length*4);
|
||||
}
|
||||
|
||||
public Trail copy(){
|
||||
@@ -31,15 +31,16 @@ public class Trail{
|
||||
}
|
||||
|
||||
public int size(){
|
||||
return points.size/3;
|
||||
return points.size/4;
|
||||
}
|
||||
|
||||
public void drawCap(Color color, float width){
|
||||
if(points.size > 0){
|
||||
Draw.color(color);
|
||||
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;
|
||||
int i = points.size - 4;
|
||||
if(items[i + 3] == 0) return;
|
||||
float x1 = items[i], y1 = items[i + 1], w1 = items[i + 2], w = w1 * width / (points.size/4) * i/4f * 2f;
|
||||
Draw.rect("hcircle", x1, y1, w, w, -Mathf.radDeg * lastAngle + 180f);
|
||||
Draw.reset();
|
||||
}
|
||||
@@ -50,15 +51,17 @@ public class Trail{
|
||||
float[] items = points.items;
|
||||
float lx = lastX, ly = lastY, lastAngle = this.lastAngle;
|
||||
|
||||
for(int i = 0; i < points.size - 3; i+= 3){
|
||||
for(int i = 0; i < points.size - 4; i+= 4){
|
||||
if(items[i + 3] == 0 || items[i + 7] == 0) continue;
|
||||
|
||||
float x1 = items[i], y1 = items[i + 1], w1 = items[i + 2],
|
||||
x2 = items[i + 3], y2 = items[i + 4], w2 = items[i + 5];
|
||||
float size = width / (points.size/3);
|
||||
x2 = items[i + 4], y2 = items[i + 5], w2 = items[i + 6];
|
||||
float size = width / (points.size/4);
|
||||
float z1 = lastAngle;
|
||||
float z2 = -Angles.angleRad(x2, y2, lx, ly);
|
||||
|
||||
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;
|
||||
float cx = Mathf.sin(z1) * i/4f * size * w1, cy = Mathf.cos(z1) * i/4f * size * w1,
|
||||
nx = Mathf.sin(z2) * (i/4f + 1) * size * w2, ny = Mathf.cos(z2) * (i/4f + 1) * size * w2;
|
||||
Fill.quad(x1 - cx, y1 - cy, x1 + cx, y1 + cy, x2 + nx, y2 + ny, x2 - nx, y2 - ny);
|
||||
|
||||
lastAngle = z2;
|
||||
@@ -72,8 +75,8 @@ public class Trail{
|
||||
/** Removes the last point from the trail at intervals. */
|
||||
public void shorten(){
|
||||
if((counter += Time.delta) >= 0.99f){
|
||||
if(points.size >= 3){
|
||||
points.removeRange(0, 2);
|
||||
if(points.size >= 4){
|
||||
points.removeRange(0, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,14 +88,19 @@ public class Trail{
|
||||
|
||||
/** Adds a new point to the trail at intervals. */
|
||||
public void update(float x, float y, float width){
|
||||
update(x, y, width, false);
|
||||
}
|
||||
|
||||
/** Adds a new point to the trail at intervals. */
|
||||
public void update(float x, float y, float width, boolean hidden){
|
||||
if((counter += Time.delta) >= 0.99f){
|
||||
if(points.size > length*3){
|
||||
points.removeRange(0, 2);
|
||||
if(points.size > length*4){
|
||||
points.removeRange(0, 3);
|
||||
}
|
||||
|
||||
lastAngle = -Angles.angleRad(x, y, lastX, lastY);
|
||||
|
||||
points.add(x, y, width);
|
||||
points.add(x, y, width, hidden ? 0 : 1);
|
||||
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
|
||||
Reference in New Issue
Block a user