mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-30 04:10:41 -08:00
Duct bridge input display
This commit is contained in:
parent
8962992ef9
commit
95da46bfa2
3 changed files with 60 additions and 19 deletions
|
|
@ -372,10 +372,6 @@ public class Blocks implements ContentList{
|
|||
variants = 3;
|
||||
}};
|
||||
|
||||
//glowBlob = new Prop("glowblob"){{
|
||||
// variants = 1;
|
||||
//}};
|
||||
|
||||
boulder = new Prop("boulder"){{
|
||||
variants = 2;
|
||||
stone.asFloor().decoration = this;
|
||||
|
|
|
|||
|
|
@ -611,7 +611,7 @@ public class UnitTypes implements ContentList{
|
|||
|
||||
bullet = new LiquidBulletType(Liquids.slag){{
|
||||
damage = 11;
|
||||
speed = 2.3f;
|
||||
speed = 2.4f;
|
||||
drag = 0.01f;
|
||||
shootEffect = Fx.shootSmall;
|
||||
lifetime = 56f;
|
||||
|
|
|
|||
|
|
@ -79,16 +79,14 @@ public class DuctBridge extends Block{
|
|||
Placement.calculateNodes(points, this, rotation, (point, other) -> Math.max(Math.abs(point.x - other.x), Math.abs(point.y - other.y)) <= range);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||
super.drawPlace(x, y, rotation, valid);
|
||||
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid, boolean line){
|
||||
int length = range;
|
||||
Building found = null;
|
||||
int dx = Geometry.d4x(rotation), dy = Geometry.d4y(rotation);
|
||||
|
||||
//find the link
|
||||
for(int i = 1; i <= range; i++){
|
||||
Tile other = world.tile(x + Geometry.d4x(rotation) * i, y + Geometry.d4y(rotation) * i);
|
||||
Tile other = world.tile(x + dx * i, y + dy * i);
|
||||
|
||||
if(other != null && other.build instanceof DuctBridgeBuild build && build.team == player.team()){
|
||||
length = i;
|
||||
|
|
@ -97,17 +95,29 @@ public class DuctBridge extends Block{
|
|||
}
|
||||
}
|
||||
|
||||
Drawf.dashLine(Pal.placing,
|
||||
x * tilesize + Geometry.d4[rotation].x * (tilesize / 2f + 2),
|
||||
y * tilesize + Geometry.d4[rotation].y * (tilesize / 2f + 2),
|
||||
x * tilesize + Geometry.d4[rotation].x * (length) * tilesize,
|
||||
y * tilesize + Geometry.d4[rotation].y * (length) * tilesize
|
||||
);
|
||||
|
||||
if(found != null){
|
||||
Drawf.square(found.x, found.y, found.block.size * tilesize/2f + 2.5f, 0f);
|
||||
if(line || found != null){
|
||||
Drawf.dashLine(Pal.placing,
|
||||
x * tilesize + dx * (tilesize / 2f + 2),
|
||||
y * tilesize + dy * (tilesize / 2f + 2),
|
||||
x * tilesize + dx * (length) * tilesize,
|
||||
y * tilesize + dy * (length) * tilesize
|
||||
);
|
||||
}
|
||||
|
||||
if(found != null){
|
||||
if(line){
|
||||
Drawf.square(found.x, found.y, found.block.size * tilesize/2f + 2.5f, 0f);
|
||||
}else{
|
||||
Drawf.square(found.x, found.y, 2f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||
super.drawPlace(x, y, rotation, valid);
|
||||
|
||||
drawPlace(x, y, rotation, valid, true);
|
||||
}
|
||||
|
||||
public void drawBridge(int rotation, float x1, float y1, float x2, float y2){
|
||||
|
|
@ -156,6 +166,41 @@ public class DuctBridge extends Block{
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSelect(){
|
||||
drawPlace(tile.x, tile.y, rotation, true, false);
|
||||
//draw incoming bridges
|
||||
for(int dir = 0; dir < 4; dir++){
|
||||
if(dir != rotation){
|
||||
int dx = Geometry.d4x(dir), dy = Geometry.d4y(dir);
|
||||
int length = range;
|
||||
Building found = null;
|
||||
|
||||
//find the link
|
||||
for(int i = 1; i <= range; i++){
|
||||
Tile other = world.tile(tile.x + dx * i, tile.y + dy * i);
|
||||
|
||||
if(other != null && other.build instanceof DuctBridgeBuild build && build.team == player.team() && (build.rotation + 2) % 4 == dir){
|
||||
length = i;
|
||||
found = other.build;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(found != null){
|
||||
Drawf.dashLine(Pal.place,
|
||||
found.x - dx * (tilesize / 2f + 2),
|
||||
found.y - dy * (tilesize / 2f + 2),
|
||||
found.x - dx * (length) * tilesize,
|
||||
found.y - dy * (length) * tilesize
|
||||
);
|
||||
|
||||
Drawf.square(found.x, found.y, 2f, 45f, Pal.place);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public DuctBridgeBuild findLink(){
|
||||
for(int i = 1; i <= range; i++){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue