Fixed block targeting bug

This commit is contained in:
Anuken 2018-08-15 18:18:57 -04:00
parent 36c01fde94
commit d58cc18136
5 changed files with 16 additions and 9 deletions

View File

@ -142,7 +142,7 @@ public class BlockIndexer{
for(int ty = ry * structQuadrantSize; ty < (ry + 1) * structQuadrantSize && ty < world.height(); ty++){
Tile other = world.tile(tx, ty);
if(other == null || other.entity == null || !pred.test(other)) continue;
if(other == null || other.entity == null || other.getTeam() != team || !pred.test(other)) continue;
TileEntity e = other.entity;
@ -246,7 +246,6 @@ public class BlockIndexer{
int quadrantX = tile.x / structQuadrantSize;
int quadrantY = tile.y / structQuadrantSize;
int index = quadrantX + quadrantY * quadWidth();
//Log.info("Updating quadrant: {0} {1}", quadrantX, quadrantY);
for(TeamData data : state.teams.getTeams()){

View File

@ -297,7 +297,7 @@ public class World extends Module{
}
public void setBlock(Tile tile, Block block, Team team){
tile.setBlock(block);
tile.setBlock(block, team);
if(block.isMultiblock()){
int offsetx = -(block.size - 1) / 2;
int offsety = -(block.size - 1) / 2;

View File

@ -584,6 +584,11 @@ public class MobileInput extends InputHandler implements GestureListener{
@Override
public void update(){
if(state.is(State.menu)){
selection.clear();
removals.clear();
mode = none;
}
//reset state when not placing
if(mode == none){

View File

@ -167,8 +167,13 @@ public class Tile implements PosTrait, TargetTrait{
}
public void setBlock(Block type, Team team){
setBlock(type);
setTeam(team);
synchronized(tileSetLock){
preChanged();
this.wall = type;
this.team = (byte)team.ordinal();
this.link = 0;
changed();
}
}
public void setBlock(Block type){
@ -393,6 +398,7 @@ public class Tile implements PosTrait, TargetTrait{
if(entity != null){
entity.removeFromProximity();
}
team = 0;
}
}
@ -404,8 +410,6 @@ public class Tile implements PosTrait, TargetTrait{
entity = null;
}
team = 0;
Block block = block();
if(block.hasEntity()){

View File

@ -55,7 +55,6 @@ public class BuildBlock extends Block{
public static void onConstructFinish(Tile tile, Block block, int builderID, byte rotation, Team team){
tile.setRotation(rotation);
world.setBlock(tile, block, team);
tile.setTeam(team);
Effects.effect(Fx.placeBlock, tile.drawx(), tile.drawy(), block.size);
//last builder was this local client player, call placed()
@ -236,7 +235,7 @@ public class BuildBlock extends Block{
progress = Mathf.clamp(progress - amount);
if(progress <= 0 || debug || state.mode.infiniteResources){
if(progress <= 0 || state.mode.infiniteResources){
Call.onDeconstructFinish(tile, this.recipe == null ? previous : this.recipe.result);
}
}