Editor crude multiblock support, indexed renderer Z support
This commit is contained in:
@@ -101,14 +101,16 @@ public class MapRenderer {
|
||||
|
||||
if (floor != Blocks.air && Draw.hasRegion(fregion)) {
|
||||
TextureRegion region = Draw.region(fregion);
|
||||
mesh.draw((wx % chunksize) + (wy % chunksize)*chunksize, region, wx * tilesize, wy * tilesize, 8, 8);
|
||||
mesh.draw((wx % chunksize) + (wy % chunksize)*chunksize, region, wx * tilesize, wy * tilesize, -1f, 8, 8);
|
||||
}
|
||||
|
||||
String wregion = Draw.hasRegion(wall.name) ? wall.name : wall.name + "1";
|
||||
|
||||
if (wall != Blocks.air && Draw.hasRegion(wregion)) {
|
||||
TextureRegion region = Draw.region(wregion);
|
||||
mesh.draw((wx % chunksize) + (wy % chunksize)*chunksize + chunksize*chunksize, region, wx * tilesize, wy * tilesize, 8, 8);
|
||||
mesh.draw((wx % chunksize) + (wy % chunksize)*chunksize + chunksize*chunksize, region,
|
||||
wx * tilesize - Math.max(region.getRegionWidth()-16f, 0), wy * tilesize - Math.max(region.getRegionHeight()-16f, 0), 0f,
|
||||
region.getRegionWidth(), region.getRegionHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package io.anuke.mindustry.world;
|
||||
|
||||
import com.badlogic.gdx.utils.IntArray;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.io.MapTileData;
|
||||
import io.anuke.mindustry.io.MapTileData.TileDataMarker;
|
||||
import io.anuke.mindustry.world.blocks.Blocks;
|
||||
@@ -20,16 +22,50 @@ public class WorldGenerator {
|
||||
/**Should fill spawns with the correct spawnpoints.*/
|
||||
public static void generate(Tile[][] tiles, MapTileData data){
|
||||
Noise.setSeed(world.getSeed());
|
||||
|
||||
IntArray multiblocks = new IntArray();
|
||||
|
||||
for(int x = 0; x < data.width(); x ++){
|
||||
for(int y = 0; y < data.height(); y ++){
|
||||
TileDataMarker tile = data.read();
|
||||
tiles[x][y] = new Tile(x, y, tile.floor, tile.wall, tile.rotation, tile.team);
|
||||
|
||||
if(tiles[x][y].block().isMultiblock()){
|
||||
multiblocks.add(tiles[x][y].packedPosition());
|
||||
}
|
||||
|
||||
//TODO ores, plants, extra decoration?
|
||||
}
|
||||
}
|
||||
|
||||
//place multiblocks now
|
||||
for(int i = 0; i < multiblocks.size; i ++){
|
||||
int pos = multiblocks.get(i);
|
||||
|
||||
int x = pos % tiles.length;
|
||||
int y = pos / tiles[0].length;
|
||||
|
||||
Block result = tiles[x][y].block();
|
||||
Team team = tiles[x][y].getTeam();
|
||||
|
||||
int offsetx = -(result.size-1)/2;
|
||||
int offsety = -(result.size-1)/2;
|
||||
|
||||
for(int dx = 0; dx < result.size; dx ++){
|
||||
for(int dy = 0; dy < result.size; dy ++){
|
||||
int worldx = dx + offsetx + x;
|
||||
int worldy = dy + offsety + y;
|
||||
if(!(worldx == x && worldy == y)){
|
||||
Tile toplace = world.tile(worldx, worldy);
|
||||
if(toplace != null) {
|
||||
toplace.setLinked((byte) (dx + offsetx), (byte) (dy + offsety));
|
||||
toplace.setTeam(team);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int x = 0; x < data.width(); x ++){
|
||||
for(int y = 0; y < data.height(); y ++) {
|
||||
tiles[x][y].updateOcclusion();
|
||||
|
||||
@@ -4,7 +4,6 @@ import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
|
||||
import static io.anuke.mindustry.Vars.debug;
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
@@ -21,11 +20,6 @@ public class CoreBlock extends StorageBlock {
|
||||
hasInventory = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int handleDamage(Tile tile, int amount){
|
||||
return debug ? 0 : amount;
|
||||
}
|
||||
|
||||
public void onDestroyed(Tile tile){
|
||||
//TODO more dramatic effects
|
||||
super.onDestroyed(tile);
|
||||
|
||||
Reference in New Issue
Block a user