mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 20:19:26 +02:00
also payload driver
This commit is contained in:
@@ -239,41 +239,36 @@ public class OverDrawer {
|
|||||||
public static void drawMassPayloadLink(PayloadMassDriver.PayloadDriverBuild from){
|
public static void drawMassPayloadLink(PayloadMassDriver.PayloadDriverBuild from){
|
||||||
float sin = Mathf.absin(Time.time, 6f, 1f);
|
float sin = Mathf.absin(Time.time, 6f, 1f);
|
||||||
|
|
||||||
Groups.build.each(b -> b instanceof PayloadMassDriver.PayloadDriverBuild fromMass &&
|
//call every mass drivers that link to this driver
|
||||||
world.build(fromMass.link) == from &&
|
for(Building b : Groups.build) {
|
||||||
from.within(fromMass.x, fromMass.y, ((PayloadMassDriver)fromMass.block).range) &&
|
if (b != from && b instanceof PayloadMassDriver.PayloadDriverBuild fromMass && world.build(fromMass.link) == from && !linkedPayloadMasses.contains(fromMass)) {
|
||||||
!linkedPayloadMasses.contains(from), b -> {
|
linkedPayloadMasses.add(fromMass);
|
||||||
linkedPayloadMasses.add((PayloadMassDriver.PayloadDriverBuild) b);
|
drawMassPayloadLink(fromMass);
|
||||||
drawMassPayloadLink((PayloadMassDriver.PayloadDriverBuild) b);
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
if(world.build(from.link) instanceof PayloadMassDriver.PayloadDriverBuild to && from != to &&
|
|
||||||
to.within(from.x, from.y, ((PayloadMassDriver)from.block).range)){
|
|
||||||
Tmp.v1.set(from.x + from.block.offset, from.y + from.block.offset).sub(to.x, to.y).limit(from.block.size * tilesize + sin + 0.5f);
|
|
||||||
float x2 = from.x - Tmp.v1.x, y2 = from.y - Tmp.v1.y,
|
|
||||||
x1 = to.x + Tmp.v1.x, y1 = to.y + Tmp.v1.y;
|
|
||||||
int segs = (int)(to.dst(from.x, from.y)/tilesize);
|
|
||||||
|
|
||||||
|
//get and draw line between this mass driver and linked one
|
||||||
|
Building target = world.build(from.link);
|
||||||
|
if(target instanceof PayloadMassDriver.PayloadDriverBuild targetDriver) {
|
||||||
|
Tmp.v1.set(from.x + from.block.offset, from.y + from.block.offset).sub(targetDriver.x, targetDriver.y).limit(from.block.size * tilesize + sin + 0.5f);
|
||||||
|
float x2 = from.x - Tmp.v1.x, y2 = from.y - Tmp.v1.y, x1 = targetDriver.x + Tmp.v1.x, y1 = targetDriver.y + Tmp.v1.y;
|
||||||
|
int segs = (int) (targetDriver.dst(from.x, from.y) / tilesize);
|
||||||
Lines.stroke(4f, Pal.gray);
|
Lines.stroke(4f, Pal.gray);
|
||||||
Lines.dashLine(x1, y1, x2, y2, segs);
|
Lines.dashLine(x1, y1, x2, y2, segs);
|
||||||
Lines.stroke(2f, Pal.placing);
|
Lines.stroke(2f, Pal.placing);
|
||||||
Lines.dashLine(x1, y1, x2, y2, segs);
|
Lines.dashLine(x1, y1, x2, y2, segs);
|
||||||
Lines.stroke(1f, Pal.accent);
|
Lines.stroke(1f, Pal.accent);
|
||||||
Drawf.circles(from.x, from.y, (from.tile.block().size / 2f + 1) * tilesize + sin - 2f, Pal.accent);
|
Drawf.circles(from.x, from.y, (from.tile.block().size / 2f + 1) * tilesize + sin - 2f, Pal.accent);
|
||||||
|
Drawf.arrow(from.x, from.y, targetDriver.x, targetDriver.y, from.block.size * tilesize + sin, 4f + sin);
|
||||||
for(var shooter : from.waitingShooters){
|
for (Building shooter : from.waitingShooters) {
|
||||||
Drawf.circles(shooter.x, shooter.y, (from.tile.block().size / 2f + 1) * tilesize + sin - 2f);
|
Drawf.circles(shooter.x, shooter.y, (from.tile.block().size / 2f + 1) * tilesize + sin - 2f);
|
||||||
Drawf.arrow(shooter.x, shooter.y, from.x, from.y, from.block.size * tilesize + sin, 4f + sin);
|
Drawf.arrow(shooter.x, shooter.y, from.x, from.y, from.block.size * tilesize + sin, 4f + sin);
|
||||||
}
|
}
|
||||||
if(from.link != -1 && world.build(from.link) instanceof PayloadMassDriver.PayloadDriverBuild other && other.block == from.block && other.team == from.team && from.within(other, ((PayloadMassDriver)from.block).range)){
|
|
||||||
Building target = world.build(from.link);
|
//call method again when target links to another mass driver which isn't stored in array
|
||||||
Drawf.circles(target.x, target.y, (target.block().size / 2f + 1) * tilesize + sin - 2f);
|
if(!linkedPayloadMasses.contains(targetDriver)) {
|
||||||
Drawf.arrow(from.x, from.y, target.x, target.y, from.block.size * tilesize + sin, 4f + sin);
|
linkedPayloadMasses.add(targetDriver);
|
||||||
}
|
drawMassPayloadLink(targetDriver);
|
||||||
if(world.build(to.link) instanceof PayloadMassDriver.PayloadDriverBuild newTo && to != newTo &&
|
|
||||||
newTo.within(to.x, to.y, ((PayloadMassDriver)to.block).range) && !linkedPayloadMasses.contains(to)){
|
|
||||||
linkedPayloadMasses.add(to);
|
|
||||||
drawMassPayloadLink(to);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user