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