Correct team display on maps

This commit is contained in:
Anuken
2020-10-31 10:35:21 -04:00
parent 2c29a06eb5
commit 8d6ea6b197
5 changed files with 30 additions and 6 deletions

View File

@@ -79,12 +79,8 @@ public class MapIO{
CachedTile tile = new CachedTile(){
@Override
public void setBlock(Block type){
//previous state.
if(build != null && build.block instanceof CoreBlock){
map.teams.add(build.team.id);
}
super.setBlock(type);
int c = colorFor(block(), Blocks.air, Blocks.air, team());
if(c != black){
walls.draw(x, floors.getHeight() - 1 - y, c);
@@ -104,6 +100,27 @@ public class MapIO{
world.setGenerating(false);
}
@Override
public void onReadBuilding(){
//read team colors
if(tile.build != null){
int c = tile.build.team.color.rgba8888();
int size = tile.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++){
int drawx = tile.x + dx + offsetx, drawy = tile.y + dy + offsety;
walls.draw(drawx, floors.getHeight() - 1 - drawy, c);
}
}
if(tile.build.block instanceof CoreBlock){
map.teams.add(tile.build.team.id);
}
}
}
@Override
public Tile tile(int index){
tile.x = (short)(index % map.width);