let DrawRegion drawer can draw regions rotate with building rotation (#8987)

* let DrawRegion drawer can draw regions that rotate with building rotation

create a variable buildingRotate that can select whether the region will rotate with building rotation or not

* let DrawRegion drawer can draw regions rotate with building rotation

create a variable buildingRotate that can select whether the region will rotate with building rotation or not
make modders needn't to use DrawSideRegion to make this effect

* Update DrawRegion.java
This commit is contained in:
zeutd
2023-08-29 21:10:46 +08:00
committed by GitHub
parent 3ac9ae29ee
commit 57d000f767

View File

@@ -13,6 +13,7 @@ public class DrawRegion extends DrawBlock{
public String suffix = ""; public String suffix = "";
public boolean spinSprite = false; public boolean spinSprite = false;
public boolean drawPlan = true; public boolean drawPlan = true;
public boolean buildingRotate = false;
public float rotateSpeed, x, y, rotation; public float rotateSpeed, x, y, rotation;
/** Any number <=0 disables layer changes. */ /** Any number <=0 disables layer changes. */
public float layer = -1; public float layer = -1;
@@ -40,9 +41,9 @@ public class DrawRegion extends DrawBlock{
float z = Draw.z(); float z = Draw.z();
if(layer > 0) Draw.z(layer); if(layer > 0) Draw.z(layer);
if(spinSprite){ if(spinSprite){
Drawf.spinSprite(region, build.x + x, build.y + y, build.totalProgress() * rotateSpeed + rotation); Drawf.spinSprite(region, build.x + x, build.y + y, build.totalProgress() * rotateSpeed + rotation + (buildingRotate ? build.rotdeg() : 0));
}else{ }else{
Draw.rect(region, build.x + x, build.y + y, build.totalProgress() * rotateSpeed + rotation); Draw.rect(region, build.x + x, build.y + y, build.totalProgress() * rotateSpeed + rotation + (buildingRotate ? build.rotdeg() : 0));
} }
Draw.z(z); Draw.z(z);
} }
@@ -50,7 +51,7 @@ public class DrawRegion extends DrawBlock{
@Override @Override
public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){ public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){
if(!drawPlan) return; if(!drawPlan) return;
Draw.rect(region, plan.drawx(), plan.drawy()); Draw.rect(region, plan.drawx(), plan.drawy(), (buildingRotate ? plan.rotation * 90f : 0));
} }
@Override @Override