More fixes
This commit is contained in:
@@ -235,6 +235,11 @@ public class World implements ApplicationListener{
|
|||||||
|
|
||||||
try{
|
try{
|
||||||
createTiles(map.width, map.height);
|
createTiles(map.width, map.height);
|
||||||
|
for(int x = 0; x < map.width; x++){
|
||||||
|
for(int y = 0; y < map.height; y++){
|
||||||
|
tiles[x][y] = new Tile(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
MapIO.readTiles(map, tiles);
|
MapIO.readTiles(map, tiles);
|
||||||
prepareTiles(tiles);
|
prepareTiles(tiles);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package io.anuke.mindustry.editor;
|
|||||||
import io.anuke.arc.collection.ObjectMap;
|
import io.anuke.arc.collection.ObjectMap;
|
||||||
import io.anuke.arc.files.FileHandle;
|
import io.anuke.arc.files.FileHandle;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.util.Log;
|
|
||||||
import io.anuke.arc.util.Pack;
|
import io.anuke.arc.util.Pack;
|
||||||
import io.anuke.arc.util.Structs;
|
import io.anuke.arc.util.Structs;
|
||||||
import io.anuke.mindustry.content.Blocks;
|
import io.anuke.mindustry.content.Blocks;
|
||||||
@@ -17,8 +16,6 @@ import io.anuke.mindustry.world.blocks.Floor;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.world;
|
|
||||||
|
|
||||||
public class MapEditor{
|
public class MapEditor{
|
||||||
public static final int[] brushSizes = {1, 2, 3, 4, 5, 9, 15, 20};
|
public static final int[] brushSizes = {1, 2, 3, 4, 5, 9, 15, 20};
|
||||||
|
|
||||||
@@ -59,7 +56,7 @@ public class MapEditor{
|
|||||||
loading = false;
|
loading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void beginEdit(Tile[][] tiles) throws IOException{
|
public void beginEdit(Tile[][] tiles){
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
this.tiles = tiles;
|
this.tiles = tiles;
|
||||||
@@ -120,13 +117,12 @@ public class MapEditor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void draw(int x, int y, boolean paint, Block drawBlock, double chance){
|
public void draw(int x, int y, boolean paint, Block drawBlock, double chance){
|
||||||
//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;
|
||||||
|
|
||||||
if(drawBlock.isMultiblock()){
|
if(drawBlock.isMultiblock()){
|
||||||
x = Mathf.clamp(x, (drawBlock.size-1)/2, world.width() - drawBlock.size/2 - 1);
|
|
||||||
y = Mathf.clamp(y, (drawBlock.size-1)/2, world.height() - drawBlock.size/2 - 1);
|
x = Mathf.clamp(x, (drawBlock.size-1)/2, width() - drawBlock.size/2 - 1);
|
||||||
|
y = Mathf.clamp(y, (drawBlock.size-1)/2, height() - drawBlock.size/2 - 1);
|
||||||
|
|
||||||
int offsetx = -(drawBlock.size - 1) / 2;
|
int offsetx = -(drawBlock.size - 1) / 2;
|
||||||
int offsety = -(drawBlock.size - 1) / 2;
|
int offsety = -(drawBlock.size - 1) / 2;
|
||||||
@@ -137,7 +133,7 @@ public class MapEditor{
|
|||||||
int worldx = dx + offsetx + x;
|
int worldx = dx + offsetx + x;
|
||||||
int worldy = dy + offsety + y;
|
int worldy = dy + offsety + y;
|
||||||
|
|
||||||
if(Structs.inBounds(worldx, worldy, world.width(), world.height())){
|
if(Structs.inBounds(worldx, worldy, width(), height())){
|
||||||
Tile tile = tiles[worldx][worldy];
|
Tile tile = tiles[worldx][worldy];
|
||||||
|
|
||||||
if(i == 1){
|
if(i == 1){
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ public class MapIO{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void changed(){
|
protected void changed(){
|
||||||
|
super.changed();
|
||||||
int c = colorFor(Blocks.air, block(), getTeam());
|
int c = colorFor(Blocks.air, block(), getTeam());
|
||||||
if(c != black) wall.drawPixel(x, floor.getHeight() - 1 - y, c);
|
if(c != black) wall.drawPixel(x, floor.getHeight() - 1 - y, c);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import io.anuke.mindustry.gen.Serialization;
|
|||||||
import io.anuke.mindustry.type.ContentType;
|
import io.anuke.mindustry.type.ContentType;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.BlockPart;
|
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
@@ -44,7 +43,6 @@ public abstract class SaveFileVersion{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void writeMap(DataOutputStream stream) throws IOException{
|
public void writeMap(DataOutputStream stream) throws IOException{
|
||||||
|
|
||||||
//write world size
|
//write world size
|
||||||
stream.writeShort(world.width());
|
stream.writeShort(world.width());
|
||||||
stream.writeShort(world.height());
|
stream.writeShort(world.height());
|
||||||
@@ -59,7 +57,7 @@ public abstract class SaveFileVersion{
|
|||||||
for(int j = i + 1; j < world.width() * world.height() && consecutives < 255; j++){
|
for(int j = i + 1; j < world.width() * world.height() && consecutives < 255; j++){
|
||||||
Tile nextTile = world.tile(j % world.width(), j / world.width());
|
Tile nextTile = world.tile(j % world.width(), j / world.width());
|
||||||
|
|
||||||
if(nextTile.getFloorID() != tile.getFloorID() || nextTile.block() != Blocks.air || nextTile.getOre() != tile.getOre()){
|
if(nextTile.getFloorID() != tile.getFloorID() || nextTile.getOre() != tile.getOre()){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +73,7 @@ public abstract class SaveFileVersion{
|
|||||||
Tile tile = world.tile(i % world.width(), i / world.width());
|
Tile tile = world.tile(i % world.width(), i / world.width());
|
||||||
stream.writeByte(tile.getBlockID());
|
stream.writeByte(tile.getBlockID());
|
||||||
|
|
||||||
if(tile.block() instanceof BlockPart){
|
if(tile.block() == Blocks.part){
|
||||||
stream.writeByte(tile.link);
|
stream.writeByte(tile.link);
|
||||||
}else if(tile.entity != null){
|
}else if(tile.entity != null){
|
||||||
stream.writeByte(Pack.byteByte(tile.getTeamID(), tile.getRotation())); //team + rotation
|
stream.writeByte(Pack.byteByte(tile.getTeamID(), tile.getRotation())); //team + rotation
|
||||||
@@ -141,6 +139,7 @@ public abstract class SaveFileVersion{
|
|||||||
int x = i % width, y = i / width;
|
int x = i % width, y = i / width;
|
||||||
Block block = content.block(stream.readByte());
|
Block block = content.block(stream.readByte());
|
||||||
Tile tile = tiles[x][y];
|
Tile tile = tiles[x][y];
|
||||||
|
tile.setBlock(block);
|
||||||
|
|
||||||
if(block == Blocks.part){
|
if(block == Blocks.part){
|
||||||
tile.link = stream.readByte();
|
tile.link = stream.readByte();
|
||||||
@@ -172,8 +171,6 @@ public abstract class SaveFileVersion{
|
|||||||
|
|
||||||
i += consecutives;
|
i += consecutives;
|
||||||
}
|
}
|
||||||
|
|
||||||
tiles[x][y] = tile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
content.setTemporaryMapper(null);
|
content.setTemporaryMapper(null);
|
||||||
|
|||||||
@@ -79,6 +79,12 @@ public class MapGenerator extends Generator{
|
|||||||
@Override
|
@Override
|
||||||
public void generate(Tile[][] tiles){
|
public void generate(Tile[][] tiles){
|
||||||
try{
|
try{
|
||||||
|
for(int x = 0; x < width; x++){
|
||||||
|
for(int y = 0; y < height; y++){
|
||||||
|
tiles[x][y] = new Tile(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MapIO.readTiles(map, tiles);
|
MapIO.readTiles(map, tiles);
|
||||||
Array<Point2> players = new Array<>();
|
Array<Point2> players = new Array<>();
|
||||||
Array<Point2> enemies = new Array<>();
|
Array<Point2> enemies = new Array<>();
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ public class Tile implements Position, TargetTrait{
|
|||||||
public Tile(int x, int y){
|
public Tile(int x, int y){
|
||||||
this.x = (short) x;
|
this.x = (short) x;
|
||||||
this.y = (short) y;
|
this.y = (short) y;
|
||||||
|
wall = floor = (Floor)Blocks.air;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tile(int x, int y, byte floor, byte wall){
|
public Tile(int x, int y, byte floor, byte wall){
|
||||||
|
|||||||
Reference in New Issue
Block a user