Slight improvements to editor rendering / Renamed blockpart -> part
This commit is contained in:
@@ -32,7 +32,7 @@ public class Blocks implements ContentList{
|
|||||||
public static Block
|
public static Block
|
||||||
|
|
||||||
//environment
|
//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,
|
grass, shrub, rock, icerock, blackrock, rocks,
|
||||||
|
|
||||||
//crafting
|
//crafting
|
||||||
@@ -85,7 +85,7 @@ public class Blocks implements ContentList{
|
|||||||
public void init(){}
|
public void init(){}
|
||||||
};
|
};
|
||||||
|
|
||||||
blockpart = new BlockPart();
|
part = new BlockPart();
|
||||||
|
|
||||||
spawn = new Block("spawn"){
|
spawn = new Block("spawn"){
|
||||||
public void drawShadow(Tile tile){}
|
public void drawShadow(Tile tile){}
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ public class World implements ApplicationListener{
|
|||||||
for(int x = 0; x < data.width(); x++){
|
for(int x = 0; x < data.width(); x++){
|
||||||
data.read(marker);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public class MapEditor{
|
|||||||
|
|
||||||
public void draw(int x, int y, Block drawBlock, double chance){
|
public void draw(int x, int y, Block drawBlock, double chance){
|
||||||
byte writeID = drawBlock.id;
|
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);
|
byte rotationTeam = Pack.byteByte(drawBlock.rotate ? (byte)rotation : 0, drawBlock.synthetic() ? (byte)drawTeam.ordinal() : 0);
|
||||||
|
|
||||||
boolean isfloor = drawBlock instanceof Floor && drawBlock != Blocks.air;
|
boolean isfloor = drawBlock instanceof Floor && drawBlock != Blocks.air;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import io.anuke.arc.graphics.g2d.Draw;
|
|||||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||||
import io.anuke.arc.util.Disposable;
|
import io.anuke.arc.util.Disposable;
|
||||||
import io.anuke.arc.util.Pack;
|
import io.anuke.arc.util.Pack;
|
||||||
|
import io.anuke.mindustry.content.Blocks;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.graphics.IndexedRenderer;
|
import io.anuke.mindustry.graphics.IndexedRenderer;
|
||||||
import io.anuke.mindustry.maps.MapTileData.DataPosition;
|
import io.anuke.mindustry.maps.MapTileData.DataPosition;
|
||||||
@@ -110,15 +111,18 @@ public class MapRenderer implements Disposable{
|
|||||||
|
|
||||||
TextureRegion region;
|
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);
|
region = wall.icon(Icon.full) == Core.atlas.find("____") ? Core.atlas.find("clear") : wall.icon(Icon.full);
|
||||||
|
|
||||||
if(wall.rotate){
|
if(wall.rotate){
|
||||||
mesh.draw((wx % chunksize) + (wy % chunksize) * chunksize, region,
|
mesh.draw(idxWall, region,
|
||||||
wx * tilesize + wall.offset(), wy * tilesize + wall.offset(),
|
wx * tilesize + wall.offset(), wy * tilesize + wall.offset(),
|
||||||
region.getWidth() * Draw.scl, region.getHeight() * Draw.scl, rotation * 90 - 90);
|
region.getWidth() * Draw.scl, region.getHeight() * Draw.scl, rotation * 90 - 90);
|
||||||
}else{
|
}else{
|
||||||
mesh.draw((wx % chunksize) + (wy % chunksize) * chunksize, region,
|
mesh.draw(idxWall, region,
|
||||||
wx * tilesize + wall.offset() + (tilesize - region.getWidth() * Draw.scl)/2f,
|
wx * tilesize + wall.offset() + (tilesize - region.getWidth() * Draw.scl)/2f,
|
||||||
wy * tilesize + wall.offset() + (tilesize - region.getHeight() * Draw.scl)/2f,
|
wy * tilesize + wall.offset() + (tilesize - region.getHeight() * Draw.scl)/2f,
|
||||||
region.getWidth() * Draw.scl, region.getHeight() * Draw.scl);
|
region.getWidth() * Draw.scl, region.getHeight() * Draw.scl);
|
||||||
@@ -126,17 +130,19 @@ public class MapRenderer implements Disposable{
|
|||||||
}else{
|
}else{
|
||||||
region = floor.icon(Icon.full);
|
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){
|
if(wall.update || wall.destructible){
|
||||||
mesh.setColor(team.color);
|
mesh.setColor(team.color);
|
||||||
region = Core.atlas.find("block-border");
|
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{
|
}else{
|
||||||
region = Core.atlas.find("clear");
|
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,
|
wx * tilesize - (wall.size/3) * tilesize, wy * tilesize - (wall.size/3) * tilesize,
|
||||||
region.getWidth() * Draw.scl, region.getHeight() * Draw.scl);
|
region.getWidth() * Draw.scl, region.getHeight() * Draw.scl);
|
||||||
mesh.setColor(Color.WHITE);
|
mesh.setColor(Color.WHITE);
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class MapIO{
|
|||||||
int worldy = dy - 1 + y;
|
int worldy = dy - 1 + y;
|
||||||
|
|
||||||
if(Structs.inBounds(worldx, worldy, pixmap.getWidth(), pixmap.getHeight())){
|
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.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)));
|
data.write(worldx, worldy, DataPosition.link, Pack.byteByte((byte) (dx - 1 + 8), (byte) (dy - 1 + 8)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ public abstract class SaveFileVersion{
|
|||||||
|
|
||||||
Tile tile = new Tile(x, y, floorid, wallid);
|
Tile tile = new Tile(x, y, floorid, wallid);
|
||||||
|
|
||||||
if(wallid == Blocks.blockpart.id){
|
if(wallid == Blocks.part.id){
|
||||||
tile.link = stream.readByte();
|
tile.link = stream.readByte();
|
||||||
}else if(tile.entity != null){
|
}else if(tile.entity != null){
|
||||||
byte tr = stream.readByte();
|
byte tr = stream.readByte();
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class MapTileData{
|
|||||||
read(marker);
|
read(marker);
|
||||||
|
|
||||||
//strip blockparts from map data, as they can be invalid
|
//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;
|
marker.wall = Blocks.air.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ public class MapTileData{
|
|||||||
int worldy = dy + offsety + y;
|
int worldy = dy + offsety + y;
|
||||||
|
|
||||||
if(Structs.inBounds(worldx, worldy, width, height) && !(dx + offsetx == 0 && dy + offsety == 0)){
|
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)));
|
write(worldx, worldy, DataPosition.link, Pack.byteByte((byte) (dx + offsetx + 8), (byte) (dy + offsety + 8)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public class MapGenerator extends Generator{
|
|||||||
marker.wall = 0;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -212,9 +212,9 @@ public class Tile implements Position, TargetTrait{
|
|||||||
return link != 0;
|
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){
|
public void setLinked(byte dx, byte dy){
|
||||||
setBlock(Blocks.blockpart);
|
setBlock(Blocks.part);
|
||||||
link = Pack.byteByte((byte)(dx + 8), (byte)(dy + 8));
|
link = Pack.byteByte((byte)(dx + 8), (byte)(dy + 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ import io.anuke.mindustry.world.Block;
|
|||||||
import io.anuke.mindustry.world.Tile;
|
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.
|
* 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.
|
* They are made to share all properties from the linked tile/block.
|
||||||
*/
|
*/
|
||||||
public class BlockPart extends Block{
|
public class BlockPart extends Block{
|
||||||
|
|
||||||
public BlockPart(){
|
public BlockPart(){
|
||||||
super("blockpart");
|
super("part");
|
||||||
solid = false;
|
solid = false;
|
||||||
hasPower = hasItems = hasLiquids = true;
|
hasPower = hasItems = hasLiquids = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ public class ApplicationTests{
|
|||||||
if(x == bx && by == y){
|
if(x == bx && by == y){
|
||||||
assertEquals(world.tile(x, y).block(), Blocks.core);
|
assertEquals(world.tile(x, y).block(), Blocks.core);
|
||||||
}else{
|
}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.copperWallLarge, world.tile(0, 0).block());
|
||||||
assertEquals(Blocks.air, world.tile(2, 2).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
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user