From 02966a091177b23dbdccd77bf32859383d865d81 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 20 Feb 2022 11:55:35 -0500 Subject: [PATCH] Fixed multiblock minimap shadows --- core/src/mindustry/content/UnitTypes.java | 3 --- .../mindustry/graphics/MinimapRenderer.java | 13 ++++++----- core/src/mindustry/world/Tile.java | 22 ++++++++----------- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index 3625214007..bf76252a3d 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -2917,7 +2917,6 @@ public class UnitTypes{ //endregion //region erekir - flying - /* avert = new ErekirUnitType("avert"){{ lowAltitude = false; flying = true; @@ -2936,8 +2935,6 @@ public class UnitTypes{ ); }}; - */ - quell = new ErekirUnitType("quell"){{ aiController = FlyingFollowAI::new; envDisabled = 0; diff --git a/core/src/mindustry/graphics/MinimapRenderer.java b/core/src/mindustry/graphics/MinimapRenderer.java index 1724fb5ec3..0f067c89c9 100644 --- a/core/src/mindustry/graphics/MinimapRenderer.java +++ b/core/src/mindustry/graphics/MinimapRenderer.java @@ -36,16 +36,17 @@ public class MinimapRenderer{ }); Events.on(TileChangeEvent.class, event -> { - //TODO don't update when the minimap is off? if(!ui.editor.isShown()){ update(event.tile); //update floor below block. - if(event.tile.block().solid && event.tile.y > 0){ - Tile tile = world.tile(event.tile.x, event.tile.y - 1); - if(tile.block() == Blocks.air){ - update(tile); - } + if(event.tile.block().solid && event.tile.y > 0 && event.tile.isCenter()){ + event.tile.getLinkedTiles(t -> { + Tile tile = world.tile(t.x, t.y - 1); + if(tile.block() == Blocks.air){ + update(tile); + } + }); } } }); diff --git a/core/src/mindustry/world/Tile.java b/core/src/mindustry/world/Tile.java index 5f36fdd2ba..28632bf598 100644 --- a/core/src/mindustry/world/Tile.java +++ b/core/src/mindustry/world/Tile.java @@ -236,8 +236,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{ //set up multiblock if(block.isMultiblock()){ - int offsetx = -(block.size - 1) / 2; - int offsety = -(block.size - 1) / 2; + int offset = -(block.size - 1) / 2; Building entity = this.build; Block block = this.block; @@ -245,8 +244,8 @@ public class Tile implements Position, QuadTreeObject, Displayable{ for(int pass = 0; pass < 2; pass++){ for(int dx = 0; dx < block.size; dx++){ for(int dy = 0; dy < block.size; dy++){ - int worldx = dx + offsetx + x; - int worldy = dy + offsety + y; + int worldx = dx + offset + x; + int worldy = dy + offset + y; if(!(worldx == x && worldy == y)){ Tile other = world.tile(worldx, worldy); @@ -434,12 +433,10 @@ public class Tile implements Position, QuadTreeObject, Displayable{ */ public void getLinkedTiles(Cons cons){ if(block.isMultiblock()){ - int size = block.size; - int offsetx = -(size - 1) / 2; - int offsety = -(size - 1) / 2; + int size = block.size, o = block.sizeOffset; for(int dx = 0; dx < size; dx++){ for(int dy = 0; dy < size; dy++){ - Tile other = world.tile(x + dx + offsetx, y + dy + offsety); + Tile other = world.tile(x + dx + o, y + dy + o); if(other != null) cons.get(other); } } @@ -474,11 +471,10 @@ public class Tile implements Position, QuadTreeObject, Displayable{ */ public void getLinkedTilesAs(Block block, Cons tmpArray){ if(block.isMultiblock()){ - int offsetx = -(block.size - 1) / 2; - int offsety = -(block.size - 1) / 2; - for(int dx = 0; dx < block.size; dx++){ - for(int dy = 0; dy < block.size; dy++){ - Tile other = world.tile(x + dx + offsetx, y + dy + offsety); + int size = block.size, o = block.sizeOffset; + for(int dx = 0; dx < size; dx++){ + for(int dy = 0; dy < size; dy++){ + Tile other = world.tile(x + dx + o, y + dy + o); if(other != null) tmpArray.get(other); } }