From ea2adbd63bd314b9c0ab1c2bdde44af410f2086f Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 4 May 2020 10:57:57 -0400 Subject: [PATCH] Editor fixes --- core/src/mindustry/editor/EditorTile.java | 7 +++++++ core/src/mindustry/entities/def/PayloadComp.java | 16 ++++++++++++++++ core/src/mindustry/world/Tile.java | 3 ++- desktop/build.gradle | 7 +++---- tests/src/test/java/ApplicationTests.java | 14 ++++++++++++++ 5 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 core/src/mindustry/entities/def/PayloadComp.java diff --git a/core/src/mindustry/editor/EditorTile.java b/core/src/mindustry/editor/EditorTile.java index 10b75e1e85..d8bd7acd16 100644 --- a/core/src/mindustry/editor/EditorTile.java +++ b/core/src/mindustry/editor/EditorTile.java @@ -38,6 +38,13 @@ public class EditorTile extends Tile{ super.setFloor(type); } + @Override + public void updateOcclusion(){ + super.updateOcclusion(); + + ui.editor.editor.renderer().updatePoint(x, y); + } + @Override public void setBlock(Block type, Team team, int rotation){ if(state.isGame()){ diff --git a/core/src/mindustry/entities/def/PayloadComp.java b/core/src/mindustry/entities/def/PayloadComp.java new file mode 100644 index 0000000000..a0a41df5a0 --- /dev/null +++ b/core/src/mindustry/entities/def/PayloadComp.java @@ -0,0 +1,16 @@ +package mindustry.entities.def; + +import arc.util.ArcAnnotate.*; +import mindustry.annotations.Annotations.*; +import mindustry.world.blocks.payloads.*; + +/** An entity that holds a payload. */ +@Component +abstract class PayloadComp{ + //TODO multiple payloads? + @Nullable Payload payload; + + boolean hasPayload(){ + return payload != null; + } +} diff --git a/core/src/mindustry/world/Tile.java b/core/src/mindustry/world/Tile.java index 7d3177ca36..12a6a51601 100644 --- a/core/src/mindustry/world/Tile.java +++ b/core/src/mindustry/world/Tile.java @@ -491,12 +491,13 @@ public class Tile implements Position, QuadTreeObject{ //remove this tile's dangling entities if(entity.block().isMultiblock()){ + int cx = entity.tileX(), cy = entity.tileY(); int size = entity.block().size; int offsetx = -(size - 1) / 2; int offsety = -(size - 1) / 2; 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(cx + dx + offsetx, cy + dy + offsety); if(other != null){ //reset entity and block *manually* - thus, preChanged() will not be called anywhere else, for multiblocks if(other != this){ //do not remove own entity so it can be processed in changed() diff --git a/desktop/build.gradle b/desktop/build.gradle index ca984a3d2c..a55b0c07e3 100644 --- a/desktop/build.gradle +++ b/desktop/build.gradle @@ -23,7 +23,7 @@ def hashDirectory = { ByteBuffer buffer = ByteBuffer.allocate(16) def files = [] root.eachFileRecurse{ file -> - files += file + if(!file.name.startsWith(".")) files += file } files.sort() @@ -48,13 +48,12 @@ task run(dependsOn: classes, type: JavaExec){ jvmArgs("-XstartOnFirstThread", "-Djava.awt.headless=true") } - spriteHashFile.parentFile.mkdirs() - + /*spriteHashFile.parentFile.mkdirs() String spriteHash = hashDirectory() if(spriteHashFile.exists() && spriteHashFile.text != spriteHash){ dependsOn ":tools:pack" } - spriteHashFile.text = spriteHash + spriteHashFile.text = spriteHash*/ if(project.hasProperty("args")){ args Eval.me(project.getProperties()["args"]) diff --git a/tests/src/test/java/ApplicationTests.java b/tests/src/test/java/ApplicationTests.java index 1252fe9e43..1802564b3f 100644 --- a/tests/src/test/java/ApplicationTests.java +++ b/tests/src/test/java/ApplicationTests.java @@ -269,6 +269,20 @@ public class ApplicationTests{ assertTrue(tank.entity.liquids().current() == Liquids.water, "Tank has no water"); } + @Test + void blockOverlapRemoved(){ + world.loadMap(testMap); + state.set(State.playing); + + //edge block + world.tile(1, 1).setBlock(Blocks.coreShard); + assertEquals(Blocks.coreShard, world.tile(0, 0).block()); + + //this should overwrite the block + world.tile(2, 2).setBlock(Blocks.coreShard); + assertEquals(Blocks.air, world.tile(0, 0).block()); + } + @Test void conveyorCrash(){ world.loadMap(testMap);