Updated uCore / Added hidden sector saves
This commit is contained in:
@@ -1,12 +1,26 @@
|
||||
package io.anuke.mindustry.maps;
|
||||
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import io.anuke.mindustry.io.SaveIO;
|
||||
import io.anuke.ucore.util.Bits;
|
||||
|
||||
import static io.anuke.mindustry.Vars.control;
|
||||
|
||||
public class Sector{
|
||||
/**Position on the map, can be positive or negative.*/
|
||||
public short x, y;
|
||||
/**Whether this sector has already been captured. TODO statistics?*/
|
||||
public boolean unlocked;
|
||||
/**Slot ID of this sector's save. -1 means no save has been created.*/
|
||||
public int saveID = -1;
|
||||
/**Display texture. Needs to be disposed.*/
|
||||
public transient Texture texture;
|
||||
|
||||
public boolean hasSave(){
|
||||
return saveID != -1 && SaveIO.isSaveValid(saveID) && control.getSaves().getByID(saveID) != null;
|
||||
}
|
||||
|
||||
public int packedPosition(){
|
||||
return Bits.packInt(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package io.anuke.mindustry.maps;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.maps.generation.WorldGenerator.GenResult;
|
||||
import io.anuke.mindustry.world.ColorMapper;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.util.Geometry;
|
||||
import io.anuke.ucore.util.GridMap;
|
||||
@@ -19,7 +20,7 @@ public class Sectors{
|
||||
private GridMap<Sector> grid = new GridMap<>();
|
||||
|
||||
public Sectors(){
|
||||
|
||||
Settings.json().addClassTag("Sector", Sector.class);
|
||||
}
|
||||
|
||||
/**If a sector is not yet unlocked, returns null.*/
|
||||
@@ -34,9 +35,8 @@ public class Sectors{
|
||||
sector.unlocked = true;
|
||||
if(sector.texture == null) createTexture(sector);
|
||||
|
||||
//TODO fix
|
||||
for(GridPoint2 point : Geometry.d4){
|
||||
// createSector(sector.x + point.x, sector.y + point.y);
|
||||
createSector(sector.x + point.x, sector.y + point.y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,10 @@ public class Sectors{
|
||||
createTexture(sector);
|
||||
grid.put(sector.x, sector.y, sector);
|
||||
}
|
||||
|
||||
if(out.size == 0){
|
||||
unlockSector(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void save(){
|
||||
@@ -83,7 +87,7 @@ public class Sectors{
|
||||
|
||||
GenResult result = world.generator().generateTile(sector.x, sector.y, toX, toY);
|
||||
|
||||
int color = Color.rgba8888(result.floor.minimapColor);
|
||||
int color = ColorMapper.colorFor(result.floor, result.wall, Team.none, result.elevation);
|
||||
pixmap.drawPixel(x, sectorImageSize - 1 - y, color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,14 +180,14 @@ public class WorldGenerator{
|
||||
for(int y = 0; y < height; y++){
|
||||
Tile tile = tiles[x][y];
|
||||
|
||||
byte elevation = tile.elevation;
|
||||
byte elevation = tile.getElevation();
|
||||
|
||||
for(GridPoint2 point : Geometry.d4){
|
||||
if(!Mathf.inBounds(x + point.x, y + point.y, width, height)) continue;
|
||||
if(tiles[x + point.x][y + point.y].elevation < elevation){
|
||||
if(tiles[x + point.x][y + point.y].getElevation() < elevation){
|
||||
|
||||
if(Mathf.chance(0.05)){
|
||||
tile.elevation = -1;
|
||||
tile.setElevation(-1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user