Editor crude multiblock support, indexed renderer Z support
This commit is contained in:
Binary file not shown.
@@ -1,7 +1,7 @@
|
|||||||
#Autogenerated file. Do not modify.
|
#Autogenerated file. Do not modify.
|
||||||
#Sat Mar 24 11:10:41 EDT 2018
|
#Sat Mar 24 18:18:45 EDT 2018
|
||||||
version=release
|
version=release
|
||||||
androidBuildCode=633
|
androidBuildCode=635
|
||||||
name=Mindustry
|
name=Mindustry
|
||||||
code=3.4
|
code=3.4
|
||||||
build=custom build
|
build=custom build
|
||||||
|
|||||||
@@ -101,14 +101,16 @@ public class MapRenderer {
|
|||||||
|
|
||||||
if (floor != Blocks.air && Draw.hasRegion(fregion)) {
|
if (floor != Blocks.air && Draw.hasRegion(fregion)) {
|
||||||
TextureRegion region = Draw.region(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";
|
String wregion = Draw.hasRegion(wall.name) ? wall.name : wall.name + "1";
|
||||||
|
|
||||||
if (wall != Blocks.air && Draw.hasRegion(wregion)) {
|
if (wall != Blocks.air && Draw.hasRegion(wregion)) {
|
||||||
TextureRegion region = Draw.region(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;
|
package io.anuke.mindustry.world;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.utils.IntArray;
|
||||||
import com.badlogic.gdx.utils.ObjectMap;
|
import com.badlogic.gdx.utils.ObjectMap;
|
||||||
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.io.MapTileData;
|
import io.anuke.mindustry.io.MapTileData;
|
||||||
import io.anuke.mindustry.io.MapTileData.TileDataMarker;
|
import io.anuke.mindustry.io.MapTileData.TileDataMarker;
|
||||||
import io.anuke.mindustry.world.blocks.Blocks;
|
import io.anuke.mindustry.world.blocks.Blocks;
|
||||||
@@ -20,16 +22,50 @@ public class WorldGenerator {
|
|||||||
/**Should fill spawns with the correct spawnpoints.*/
|
/**Should fill spawns with the correct spawnpoints.*/
|
||||||
public static void generate(Tile[][] tiles, MapTileData data){
|
public static void generate(Tile[][] tiles, MapTileData data){
|
||||||
Noise.setSeed(world.getSeed());
|
Noise.setSeed(world.getSeed());
|
||||||
|
|
||||||
|
IntArray multiblocks = new IntArray();
|
||||||
|
|
||||||
for(int x = 0; x < data.width(); x ++){
|
for(int x = 0; x < data.width(); x ++){
|
||||||
for(int y = 0; y < data.height(); y ++){
|
for(int y = 0; y < data.height(); y ++){
|
||||||
TileDataMarker tile = data.read();
|
TileDataMarker tile = data.read();
|
||||||
tiles[x][y] = new Tile(x, y, tile.floor, tile.wall, tile.rotation, tile.team);
|
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?
|
//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 x = 0; x < data.width(); x ++){
|
||||||
for(int y = 0; y < data.height(); y ++) {
|
for(int y = 0; y < data.height(); y ++) {
|
||||||
tiles[x][y].updateOcclusion();
|
tiles[x][y].updateOcclusion();
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import io.anuke.mindustry.net.Net;
|
|||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.world.Tile;
|
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.state;
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Vars.world;
|
||||||
|
|
||||||
@@ -21,11 +20,6 @@ public class CoreBlock extends StorageBlock {
|
|||||||
hasInventory = false;
|
hasInventory = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int handleDamage(Tile tile, int amount){
|
|
||||||
return debug ? 0 : amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onDestroyed(Tile tile){
|
public void onDestroyed(Tile tile){
|
||||||
//TODO more dramatic effects
|
//TODO more dramatic effects
|
||||||
super.onDestroyed(tile);
|
super.onDestroyed(tile);
|
||||||
|
|||||||
Reference in New Issue
Block a user