Correct team display on maps
This commit is contained in:
@@ -79,12 +79,8 @@ public class MapIO{
|
|||||||
CachedTile tile = new CachedTile(){
|
CachedTile tile = new CachedTile(){
|
||||||
@Override
|
@Override
|
||||||
public void setBlock(Block type){
|
public void setBlock(Block type){
|
||||||
//previous state.
|
|
||||||
if(build != null && build.block instanceof CoreBlock){
|
|
||||||
map.teams.add(build.team.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
super.setBlock(type);
|
super.setBlock(type);
|
||||||
|
|
||||||
int c = colorFor(block(), Blocks.air, Blocks.air, team());
|
int c = colorFor(block(), Blocks.air, Blocks.air, team());
|
||||||
if(c != black){
|
if(c != black){
|
||||||
walls.draw(x, floors.getHeight() - 1 - y, c);
|
walls.draw(x, floors.getHeight() - 1 - y, c);
|
||||||
@@ -104,6 +100,27 @@ public class MapIO{
|
|||||||
world.setGenerating(false);
|
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
|
@Override
|
||||||
public Tile tile(int index){
|
public Tile tile(int index){
|
||||||
tile.x = (short)(index % map.width);
|
tile.x = (short)(index % map.width);
|
||||||
|
|||||||
@@ -263,6 +263,8 @@ public abstract class SaveVersion extends SaveFileReader{
|
|||||||
//skip the entity region, as the entity and its IO code are now gone
|
//skip the entity region, as the entity and its IO code are now gone
|
||||||
skipChunk(stream, true);
|
skipChunk(stream, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context.onReadBuilding();
|
||||||
}
|
}
|
||||||
}else if(hadData){
|
}else if(hadData){
|
||||||
tile.setBlock(block);
|
tile.setBlock(block);
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ public abstract class LegacySaveVersion extends SaveVersion{
|
|||||||
}catch(Throwable e){
|
}catch(Throwable e){
|
||||||
throw new IOException("Failed to read tile entity of block: " + block, e);
|
throw new IOException("Failed to read tile entity of block: " + block, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context.onReadBuilding();
|
||||||
}else{
|
}else{
|
||||||
int consecutives = stream.readUnsignedByte();
|
int consecutives = stream.readUnsignedByte();
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class Map implements Comparable<Map>, Publishable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Fi previewFile(){
|
public Fi previewFile(){
|
||||||
return Vars.mapPreviewDirectory.child((workshop ? file.parent().name() : file.nameWithoutExtension()) + ".png");
|
return Vars.mapPreviewDirectory.child((workshop ? file.parent().name() : file.nameWithoutExtension()) + "_v2.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Fi cacheFile(){
|
public Fi cacheFile(){
|
||||||
|
|||||||
@@ -20,4 +20,7 @@ public interface WorldContext{
|
|||||||
/** End generating, prepares tiles.*/
|
/** End generating, prepares tiles.*/
|
||||||
void end();
|
void end();
|
||||||
|
|
||||||
|
/** Called when a building is finished reading. */
|
||||||
|
default void onReadBuilding(){}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user