From 57d000f767527795ac484dc0c3c78a8bf388944f Mon Sep 17 00:00:00 2001 From: zeutd <107938101+zeutd@users.noreply.github.com> Date: Tue, 29 Aug 2023 21:10:46 +0800 Subject: [PATCH] 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 --- core/src/mindustry/world/draw/DrawRegion.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/mindustry/world/draw/DrawRegion.java b/core/src/mindustry/world/draw/DrawRegion.java index 6ef9259105..86523ca492 100644 --- a/core/src/mindustry/world/draw/DrawRegion.java +++ b/core/src/mindustry/world/draw/DrawRegion.java @@ -13,6 +13,7 @@ public class DrawRegion extends DrawBlock{ public String suffix = ""; public boolean spinSprite = false; public boolean drawPlan = true; + public boolean buildingRotate = false; public float rotateSpeed, x, y, rotation; /** Any number <=0 disables layer changes. */ public float layer = -1; @@ -40,9 +41,9 @@ public class DrawRegion extends DrawBlock{ float z = Draw.z(); if(layer > 0) Draw.z(layer); 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{ - 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); } @@ -50,7 +51,7 @@ public class DrawRegion extends DrawBlock{ @Override public void drawPlan(Block block, BuildPlan plan, Eachable list){ if(!drawPlan) return; - Draw.rect(region, plan.drawx(), plan.drawy()); + Draw.rect(region, plan.drawx(), plan.drawy(), (buildingRotate ? plan.rotation * 90f : 0)); } @Override