Editor fixes

This commit is contained in:
Anuken
2020-05-04 10:57:57 -04:00
parent 90505a8e19
commit ea2adbd63b
5 changed files with 42 additions and 5 deletions

View File

@@ -38,6 +38,13 @@ public class EditorTile extends Tile{
super.setFloor(type); super.setFloor(type);
} }
@Override
public void updateOcclusion(){
super.updateOcclusion();
ui.editor.editor.renderer().updatePoint(x, y);
}
@Override @Override
public void setBlock(Block type, Team team, int rotation){ public void setBlock(Block type, Team team, int rotation){
if(state.isGame()){ if(state.isGame()){

View File

@@ -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;
}
}

View File

@@ -491,12 +491,13 @@ public class Tile implements Position, QuadTreeObject{
//remove this tile's dangling entities //remove this tile's dangling entities
if(entity.block().isMultiblock()){ if(entity.block().isMultiblock()){
int cx = entity.tileX(), cy = entity.tileY();
int size = entity.block().size; int size = entity.block().size;
int offsetx = -(size - 1) / 2; int offsetx = -(size - 1) / 2;
int offsety = -(size - 1) / 2; int offsety = -(size - 1) / 2;
for(int dx = 0; dx < size; dx++){ for(int dx = 0; dx < size; dx++){
for(int dy = 0; dy < size; dy++){ 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){ if(other != null){
//reset entity and block *manually* - thus, preChanged() will not be called anywhere else, for multiblocks //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() if(other != this){ //do not remove own entity so it can be processed in changed()

View File

@@ -23,7 +23,7 @@ def hashDirectory = {
ByteBuffer buffer = ByteBuffer.allocate(16) ByteBuffer buffer = ByteBuffer.allocate(16)
def files = [] def files = []
root.eachFileRecurse{ file -> root.eachFileRecurse{ file ->
files += file if(!file.name.startsWith(".")) files += file
} }
files.sort() files.sort()
@@ -48,13 +48,12 @@ task run(dependsOn: classes, type: JavaExec){
jvmArgs("-XstartOnFirstThread", "-Djava.awt.headless=true") jvmArgs("-XstartOnFirstThread", "-Djava.awt.headless=true")
} }
spriteHashFile.parentFile.mkdirs() /*spriteHashFile.parentFile.mkdirs()
String spriteHash = hashDirectory() String spriteHash = hashDirectory()
if(spriteHashFile.exists() && spriteHashFile.text != spriteHash){ if(spriteHashFile.exists() && spriteHashFile.text != spriteHash){
dependsOn ":tools:pack" dependsOn ":tools:pack"
} }
spriteHashFile.text = spriteHash spriteHashFile.text = spriteHash*/
if(project.hasProperty("args")){ if(project.hasProperty("args")){
args Eval.me(project.getProperties()["args"]) args Eval.me(project.getProperties()["args"])

View File

@@ -269,6 +269,20 @@ public class ApplicationTests{
assertTrue(tank.entity.liquids().current() == Liquids.water, "Tank has no water"); 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 @Test
void conveyorCrash(){ void conveyorCrash(){
world.loadMap(testMap); world.loadMap(testMap);