Slight improvements to editor rendering / Renamed blockpart -> part

This commit is contained in:
Anuken 2019-01-23 08:51:21 -05:00
parent e9e2cd614d
commit c3883cdad0
11 changed files with 26 additions and 20 deletions

View File

@ -32,7 +32,7 @@ public class Blocks implements ContentList{
public static Block
//environment
air, blockpart, spawn, space, metalfloor, deepwater, water, tar, stone, craters, blackstone, dirt, sand, ice, snow,
air, part, spawn, space, metalfloor, deepwater, water, tar, stone, craters, blackstone, dirt, sand, ice, snow,
grass, shrub, rock, icerock, blackrock, rocks,
//crafting
@ -85,7 +85,7 @@ public class Blocks implements ContentList{
public void init(){}
};
blockpart = new BlockPart();
part = new BlockPart();
spawn = new Block("spawn"){
public void drawShadow(Tile tile){}

View File

@ -434,7 +434,7 @@ public class World implements ApplicationListener{
for(int x = 0; x < data.width(); x++){
data.read(marker);
tiles[x][y] = new Tile(x, y, marker.floor, marker.wall == Blocks.blockpart.id ? 0 : marker.wall, marker.rotation, marker.team);
tiles[x][y] = new Tile(x, y, marker.floor, marker.wall == Blocks.part.id ? 0 : marker.wall, marker.rotation, marker.team);
}
}

View File

@ -95,7 +95,7 @@ public class MapEditor{
public void draw(int x, int y, Block drawBlock, double chance){
byte writeID = drawBlock.id;
byte partID = Blocks.blockpart.id;
byte partID = Blocks.part.id;
byte rotationTeam = Pack.byteByte(drawBlock.rotate ? (byte)rotation : 0, drawBlock.synthetic() ? (byte)drawTeam.ordinal() : 0);
boolean isfloor = drawBlock instanceof Floor && drawBlock != Blocks.air;

View File

@ -8,6 +8,7 @@ import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.graphics.g2d.TextureRegion;
import io.anuke.arc.util.Disposable;
import io.anuke.arc.util.Pack;
import io.anuke.mindustry.content.Blocks;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.graphics.IndexedRenderer;
import io.anuke.mindustry.maps.MapTileData.DataPosition;
@ -110,15 +111,18 @@ public class MapRenderer implements Disposable{
TextureRegion region;
if(bw != 0){
int idxWall = (wx % chunksize) + (wy % chunksize) * chunksize;
int idxDecal = (wx % chunksize) + (wy % chunksize) * chunksize + chunksize * chunksize;
if(bw != 0 && (wall.synthetic() || wall == Blocks.part)){
region = wall.icon(Icon.full) == Core.atlas.find("____") ? Core.atlas.find("clear") : wall.icon(Icon.full);
if(wall.rotate){
mesh.draw((wx % chunksize) + (wy % chunksize) * chunksize, region,
mesh.draw(idxWall, region,
wx * tilesize + wall.offset(), wy * tilesize + wall.offset(),
region.getWidth() * Draw.scl, region.getHeight() * Draw.scl, rotation * 90 - 90);
}else{
mesh.draw((wx % chunksize) + (wy % chunksize) * chunksize, region,
mesh.draw(idxWall, region,
wx * tilesize + wall.offset() + (tilesize - region.getWidth() * Draw.scl)/2f,
wy * tilesize + wall.offset() + (tilesize - region.getHeight() * Draw.scl)/2f,
region.getWidth() * Draw.scl, region.getHeight() * Draw.scl);
@ -126,17 +130,19 @@ public class MapRenderer implements Disposable{
}else{
region = floor.icon(Icon.full);
mesh.draw((wx % chunksize) + (wy % chunksize) * chunksize, region, wx * tilesize, wy * tilesize, 8, 8);
mesh.draw(idxWall, region, wx * tilesize, wy * tilesize, 8, 8);
}
if(wall.update || wall.destructible){
mesh.setColor(team.color);
region = Core.atlas.find("block-border");
}else if(!wall.synthetic() && bw != 0){
region = wall.icon(Icon.full) == Core.atlas.find("____") ? Core.atlas.find("clear") : wall.icon(Icon.full);
}else{
region = Core.atlas.find("clear");
}
mesh.draw((wx % chunksize) + (wy % chunksize) * chunksize + chunksize * chunksize, region,
mesh.draw(idxDecal, region,
wx * tilesize - (wall.size/3) * tilesize, wy * tilesize - (wall.size/3) * tilesize,
region.getWidth() * Draw.scl, region.getHeight() * Draw.scl);
mesh.setColor(Color.WHITE);

View File

@ -87,7 +87,7 @@ public class MapIO{
int worldy = dy - 1 + y;
if(Structs.inBounds(worldx, worldy, pixmap.getWidth(), pixmap.getHeight())){
data.write(worldx, worldy, DataPosition.wall, Blocks.blockpart.id);
data.write(worldx, worldy, DataPosition.wall, Blocks.part.id);
data.write(worldx, worldy, DataPosition.rotationTeam, Pack.byteByte((byte)0, (byte)Team.blue.ordinal()));
data.write(worldx, worldy, DataPosition.link, Pack.byteByte((byte) (dx - 1 + 8), (byte) (dy - 1 + 8)));
}

View File

@ -101,7 +101,7 @@ public abstract class SaveFileVersion{
Tile tile = new Tile(x, y, floorid, wallid);
if(wallid == Blocks.blockpart.id){
if(wallid == Blocks.part.id){
tile.link = stream.readByte();
}else if(tile.entity != null){
byte tr = stream.readByte();

View File

@ -48,7 +48,7 @@ public class MapTileData{
read(marker);
//strip blockparts from map data, as they can be invalid
if(marker.wall == Blocks.blockpart.id){
if(marker.wall == Blocks.part.id){
marker.wall = Blocks.air.id;
}
@ -72,7 +72,7 @@ public class MapTileData{
int worldy = dy + offsety + y;
if(Structs.inBounds(worldx, worldy, width, height) && !(dx + offsetx == 0 && dy + offsety == 0)){
write(worldx, worldy, DataPosition.wall, Blocks.blockpart.id);
write(worldx, worldy, DataPosition.wall, Blocks.part.id);
write(worldx, worldy, DataPosition.link, Pack.byteByte((byte) (dx + offsetx + 8), (byte) (dy + offsety + 8)));
}
}

View File

@ -64,7 +64,7 @@ public class MapGenerator extends Generator{
marker.wall = 0;
}
tiles[x][y] = new Tile(x, y, marker.floor, marker.wall == Blocks.blockpart.id ? 0 : marker.wall, marker.rotation, marker.team);
tiles[x][y] = new Tile(x, y, marker.floor, marker.wall == Blocks.part.id ? 0 : marker.wall, marker.rotation, marker.team);
}
}

View File

@ -212,9 +212,9 @@ public class Tile implements Position, TargetTrait{
return link != 0;
}
/** Sets this to a linked tile, which sets the block to a blockpart. dx and dy can only be -8-7. */
/** Sets this to a linked tile, which sets the block to a part. dx and dy can only be -8-7. */
public void setLinked(byte dx, byte dy){
setBlock(Blocks.blockpart);
setBlock(Blocks.part);
link = Pack.byteByte((byte)(dx + 8), (byte)(dy + 8));
}

View File

@ -6,14 +6,14 @@ import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
/**
* Used for multiblocks. Each block that is not the center of the multiblock is a blockpart.
* Used for multiblocks. Each block that is not the center of the multiblock is a part.
* Think of these as delegates to the actual block; all events are passed to the target block.
* They are made to share all properties from the linked tile/block.
*/
public class BlockPart extends Block{
public BlockPart(){
super("blockpart");
super("part");
solid = false;
hasPower = hasItems = hasLiquids = true;
}

View File

@ -145,7 +145,7 @@ public class ApplicationTests{
if(x == bx && by == y){
assertEquals(world.tile(x, y).block(), Blocks.core);
}else{
assertTrue(world.tile(x, y).block() == Blocks.blockpart && world.tile(x, y).getLinked() == world.tile(bx, by));
assertTrue(world.tile(x, y).block() == Blocks.part && world.tile(x, y).getLinked() == world.tile(bx, by));
}
}
}
@ -236,7 +236,7 @@ public class ApplicationTests{
assertEquals(Blocks.copperWallLarge, world.tile(0, 0).block());
assertEquals(Blocks.air, world.tile(2, 2).block());
assertEquals(Blocks.blockpart, world.tile(1, 1).block());
assertEquals(Blocks.part, world.tile(1, 1).block());
}
@Test