From e79fa75f8b36d37798f74210b6c2a8f21c1ce12a Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 27 Sep 2025 00:36:35 -0400 Subject: [PATCH] Turret rotation ghost plan fix --- core/src/mindustry/core/Control.java | 1 + core/src/mindustry/graphics/BlockRenderer.java | 8 ++++---- core/src/mindustry/world/Block.java | 2 ++ .../mindustry/world/blocks/defense/turrets/Turret.java | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/src/mindustry/core/Control.java b/core/src/mindustry/core/Control.java index fa52cf2a96..840f7f2e6e 100644 --- a/core/src/mindustry/core/Control.java +++ b/core/src/mindustry/core/Control.java @@ -477,6 +477,7 @@ public class Control implements ApplicationListener, Loadable{ for(var build : previousBuildings){ Tile tile = world.tile(build.tileX(), build.tileY()); if(tile != null && tile.build == null && Build.validPlace(build.block, state.rules.defaultTeam, build.tileX(), build.tileY(), build.rotation, false, false)){ + build.addPlan(false, true); tile.setBlock(build.block, state.rules.defaultTeam, build.rotation, () -> build); build.changeTeam(Team.derelict); build.dropped(); //TODO: call pickedUp too? this may screw up power networks in a major way as they refer to potentially deleted entities diff --git a/core/src/mindustry/graphics/BlockRenderer.java b/core/src/mindustry/graphics/BlockRenderer.java index ebf8fc9b8d..f84ca8eb5b 100644 --- a/core/src/mindustry/graphics/BlockRenderer.java +++ b/core/src/mindustry/graphics/BlockRenderer.java @@ -310,13 +310,13 @@ public class BlockRenderer{ } if(brokenFade > 0.001f){ - for(BlockPlan block : player.team().data().plans){ - Block b = block.block; - if(!camera.bounds(Tmp.r1).grow(tilesize * 2f).overlaps(Tmp.r2.setSize(b.size * tilesize).setCenter(block.x * tilesize + b.offset, block.y * tilesize + b.offset))) continue; + for(BlockPlan plan : player.team().data().plans){ + Block b = plan.block; + if(!camera.bounds(Tmp.r1).grow(tilesize * 2f).overlaps(Tmp.r2.setSize(b.size * tilesize).setCenter(plan.x * tilesize + b.offset, plan.y * tilesize + b.offset))) continue; Draw.alpha(0.33f * brokenFade); Draw.mixcol(Color.white, 0.2f + Mathf.absin(Time.globalTime, 6f, 0.2f)); - Draw.rect(b.fullIcon, block.x * tilesize + b.offset, block.y * tilesize + b.offset, b.rotate ? block.rotation * 90 : 0f); + Draw.rect(b.fullIcon, plan.x * tilesize + b.offset, plan.y * tilesize + b.offset, b.rotate ? plan.rotation * 90 + plan.block.visualRotationOffset : 0f); } Draw.reset(); } diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index 3d49162912..00033dc64a 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -114,6 +114,8 @@ public class Block extends UnlockableContent implements Senseable{ public boolean rotateDraw = true; /** if rotate is true and this is false, the region won't rotate when drawing in the editor */ public boolean rotateDrawEditor = true; + /** visual rotation offset used in broken plan rendering */ + public float visualRotationOffset = 0f; /** if rotate = false and this is true, rotation will be locked at 0 when placing (default); advanced use only */ public boolean lockRotation = true; /** if true, schematic flips with this block are inverted. */ diff --git a/core/src/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/mindustry/world/blocks/defense/turrets/Turret.java index 87ab79bf8a..5601a6ac06 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/Turret.java @@ -160,6 +160,7 @@ public class Turret extends ReloadTurret{ quickRotate = false; drawArrow = false; rotateDrawEditor = false; + visualRotationOffset = -90f; } @Override