Horizontal shifting of pistons (also adds proper icons for pistons) (#8345)

* Horizontal offset for pistons

* might as well fix icons in the meantime

* Make a positive offset shift to the right
This commit is contained in:
MEEPofFaith 2023-05-10 10:10:48 -07:00 committed by GitHub
parent c7ad9d0250
commit a5eda4fb2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 784 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

View file

@ -9,14 +9,14 @@ import mindustry.gen.*;
import mindustry.world.*;
public class DrawPistons extends DrawBlock{
public float sinMag = 4f, sinScl = 6f, sinOffset = 50f, sideOffset = 0f, lenOffset = -1f, angleOffset = 0f;
public float sinMag = 4f, sinScl = 6f, sinOffset = 50f, sideOffset = 0f, lenOffset = -1f, horiOffset = 0f, angleOffset = 0f;
public int sides = 4;
public String suffix = "-piston";
public TextureRegion region1, region2, regiont;
public TextureRegion region1, region2, regiont, iconRegion;
@Override
public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){
Draw.rect(iconRegion, plan.drawx(), plan.drawy());
}
@Override
@ -32,7 +32,8 @@ public class DrawPistons extends DrawBlock{
Draw.yscl = -1f;
}
Draw.rect(reg, build.x + Angles.trnsx(angle, len), build.y + Angles.trnsy(angle, len), angle);
Tmp.v1.trns(angle, len, -horiOffset);
Draw.rect(reg, build.x + Tmp.v1.x, build.y + Tmp.v1.y, angle);
Draw.yscl = 1f;
}
@ -45,5 +46,11 @@ public class DrawPistons extends DrawBlock{
region1 = Core.atlas.find(block.name + suffix + "0", block.name + suffix);
region2 = Core.atlas.find(block.name + suffix + "1", block.name + suffix);
regiont = Core.atlas.find(block.name + suffix + "-t");
iconRegion = Core.atlas.find(block.name + suffix + "-icon");
}
@Override
public TextureRegion[] icons(Block block){
return new TextureRegion[]{iconRegion};
}
}