mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-10 10:47:13 +07:00
Updated uCore / Added hidden sector saves
This commit is contained in:
parent
c2c2551607
commit
71016f0d7c
@ -27,7 +27,7 @@ allprojects {
|
||||
gdxVersion = '1.9.8'
|
||||
roboVMVersion = '2.3.0'
|
||||
aiVersion = '1.8.1'
|
||||
uCoreVersion = 'e4eec58b02'
|
||||
uCoreVersion = '3e5e261181'
|
||||
|
||||
getVersionString = {
|
||||
String buildVersion = getBuildVersion()
|
||||
|
@ -50,9 +50,11 @@ text.addplayers=Add/Remove Players
|
||||
text.customgame=Custom Game
|
||||
text.campaign=Campaign
|
||||
text.sectors=Sectors
|
||||
text.sector=Selected Sector: {0}
|
||||
text.sector=Selected Sector: [LIGHT_GRAY]{0}
|
||||
text.sector.deploy=Deploy
|
||||
text.sector.resume=Resume
|
||||
text.sector.locked=[scarlet][[LOCKED]
|
||||
text.sector.unexplored=[accent][[Unexplored]
|
||||
text.quit=Quit
|
||||
text.maps=Maps
|
||||
text.maps.none=[LIGHT_GRAY]No maps found!
|
||||
|
@ -46,6 +46,7 @@ public class Vars{
|
||||
public static final float itemSize = 5f;
|
||||
public static final int tilesize = 8;
|
||||
public static final int sectorSize = 256;
|
||||
public static final int invalidSector = Integer.MAX_VALUE;
|
||||
public static final Locale[] locales = {new Locale("en"), new Locale("fr"), new Locale("ru"), new Locale("uk", "UA"), new Locale("pl"),
|
||||
new Locale("de"), new Locale("pt", "BR"), new Locale("ko"), new Locale("in", "ID"),
|
||||
new Locale("ita"), new Locale("es"), new Locale("zh","TW")};
|
||||
|
@ -11,10 +11,7 @@ import io.anuke.mindustry.game.EventType.TileChangeEvent;
|
||||
import io.anuke.mindustry.game.EventType.WorldLoadEvent;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.io.MapIO;
|
||||
import io.anuke.mindustry.maps.Map;
|
||||
import io.anuke.mindustry.maps.MapMeta;
|
||||
import io.anuke.mindustry.maps.Maps;
|
||||
import io.anuke.mindustry.maps.Sectors;
|
||||
import io.anuke.mindustry.maps.*;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.maps.generation.WorldGenerator;
|
||||
@ -31,6 +28,7 @@ import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class World extends Module{
|
||||
private Map currentMap;
|
||||
private Sector currentSector;
|
||||
private Tile[][] tiles;
|
||||
private Pathfinder pathfinder = new Pathfinder();
|
||||
private BlockIndexer indexer = new BlockIndexer();
|
||||
@ -43,6 +41,10 @@ public class World extends Module{
|
||||
|
||||
public World(){
|
||||
maps.load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
sectors.load();
|
||||
}
|
||||
|
||||
@ -105,6 +107,10 @@ public class World extends Module{
|
||||
return currentMap;
|
||||
}
|
||||
|
||||
public Sector getSector(){
|
||||
return currentSector;
|
||||
}
|
||||
|
||||
public void setMap(Map map){
|
||||
this.currentMap = map;
|
||||
}
|
||||
@ -206,8 +212,9 @@ public class World extends Module{
|
||||
Events.fire(WorldLoadEvent.class);
|
||||
}
|
||||
|
||||
/**Loads up a procedural map. This does not call play(), but calls reset().*/
|
||||
public void loadProceduralMap(int sectorX, int sectorY){
|
||||
/**Loads up a sector map. This does not call play(), but calls reset().*/
|
||||
public void loadSector(Sector sector){
|
||||
currentSector = sector;
|
||||
Timers.mark();
|
||||
Timers.mark();
|
||||
|
||||
@ -219,13 +226,13 @@ public class World extends Module{
|
||||
|
||||
Tile[][] tiles = createTiles(width, height);
|
||||
|
||||
Map map = new Map("Sector [" + sectorX + ", " + sectorY + "]", new MapMeta(0, new ObjectMap<>(), width, height, null), true, () -> null);
|
||||
Map map = new Map("Sector [" + sector.x + ", " + sector.y + "]", new MapMeta(0, new ObjectMap<>(), width, height, null), true, () -> null);
|
||||
setMap(map);
|
||||
|
||||
EntityPhysics.resizeTree(0, 0, width * tilesize, height * tilesize);
|
||||
|
||||
Timers.mark();
|
||||
generator.generateMap(tiles, sectorX, sectorY);
|
||||
generator.generateMap(tiles, sector.x, sector.y);
|
||||
Log.info("Time to generate base map: {0}", Timers.elapsed());
|
||||
|
||||
Log.info("Time to generate fully without additional events: {0}", Timers.elapsed());
|
||||
@ -236,6 +243,7 @@ public class World extends Module{
|
||||
}
|
||||
|
||||
public void loadMap(Map map){
|
||||
currentSector = null;
|
||||
beginMapLoad();
|
||||
this.currentMap = map;
|
||||
|
||||
|
@ -244,7 +244,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
}
|
||||
|
||||
//on slope
|
||||
if(tile.elevation == -1){
|
||||
if(tile.getElevation() == -1){
|
||||
velocity.scl(0.7f);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package io.anuke.mindustry.game;
|
||||
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.IntMap;
|
||||
import com.badlogic.gdx.utils.TimeUtils;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.game.EventType.StateChangeEvent;
|
||||
@ -21,6 +22,7 @@ import static io.anuke.mindustry.Vars.*;
|
||||
public class Saves{
|
||||
private int nextSlot;
|
||||
private Array<SaveSlot> saves = new ThreadArray<>();
|
||||
private IntMap<SaveSlot> saveMap = new IntMap<>();
|
||||
private SaveSlot current;
|
||||
private boolean saving;
|
||||
private float time;
|
||||
@ -44,6 +46,7 @@ public class Saves{
|
||||
if(SaveIO.isSaveValid(index)){
|
||||
SaveSlot slot = new SaveSlot(index);
|
||||
saves.add(slot);
|
||||
saveMap.put(slot.index, slot);
|
||||
slot.meta = SaveIO.getData(index);
|
||||
nextSlot = Math.max(index + 1, nextSlot);
|
||||
}
|
||||
@ -99,16 +102,18 @@ public class Saves{
|
||||
return saving;
|
||||
}
|
||||
|
||||
public void addSave(String name){
|
||||
public SaveSlot addSave(String name){
|
||||
SaveSlot slot = new SaveSlot(nextSlot);
|
||||
nextSlot++;
|
||||
slot.setName(name);
|
||||
saves.add(slot);
|
||||
saveMap.put(slot.index, slot);
|
||||
SaveIO.saveToSlot(slot.index);
|
||||
slot.meta = SaveIO.getData(slot.index);
|
||||
current = slot;
|
||||
|
||||
saveSlots();
|
||||
return slot;
|
||||
}
|
||||
|
||||
public SaveSlot importSave(FileHandle file) throws IOException{
|
||||
@ -117,12 +122,17 @@ public class Saves{
|
||||
nextSlot++;
|
||||
slot.setName(file.nameWithoutExtension());
|
||||
saves.add(slot);
|
||||
saveMap.put(slot.index, slot);
|
||||
slot.meta = SaveIO.getData(slot.index);
|
||||
current = slot;
|
||||
saveSlots();
|
||||
return slot;
|
||||
}
|
||||
|
||||
public SaveSlot getByID(int id){
|
||||
return saveMap.get(id);
|
||||
}
|
||||
|
||||
public Array<SaveSlot> getSaveSlots(){
|
||||
return saves;
|
||||
}
|
||||
@ -157,6 +167,10 @@ public class Saves{
|
||||
current = this;
|
||||
}
|
||||
|
||||
public boolean isHidden(){
|
||||
return meta.sector != invalidSector;
|
||||
}
|
||||
|
||||
public String getPlayTime(){
|
||||
return Strings.formatMillis(current == this ? totalPlaytime : meta.timePlayed);
|
||||
}
|
||||
@ -223,11 +237,16 @@ public class Saves{
|
||||
}
|
||||
|
||||
public void delete(){
|
||||
SaveIO.fileFor(index).delete();
|
||||
if(!gwt){ //can't delete files
|
||||
SaveIO.fileFor(index).delete();
|
||||
}
|
||||
saves.removeValue(this, true);
|
||||
saveMap.remove(index);
|
||||
if(this == current){
|
||||
current = null;
|
||||
}
|
||||
|
||||
saveSlots();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,15 +139,8 @@ public class MinimapRenderer implements Disposable{
|
||||
}
|
||||
|
||||
private int colorFor(Tile tile){
|
||||
int color = tile.breakable() ? tile.target().getTeam().intColor : ColorMapper.getBlockColor(tile.block());
|
||||
if(color == 0) color = ColorMapper.getBlockColor(tile.floor());
|
||||
if(tile.elevation > 0){
|
||||
float mul = 1.1f + tile.elevation / 4f;
|
||||
tmpColor.set(color);
|
||||
tmpColor.mul(mul, mul, mul, 1f);
|
||||
color = Color.rgba8888(tmpColor);
|
||||
}
|
||||
return color;
|
||||
tile = tile.target();
|
||||
return ColorMapper.colorFor(tile.floor(), tile.block(), tile.getTeam(), tile.getElevation());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,14 +14,15 @@ public abstract class SaveFileVersion{
|
||||
}
|
||||
|
||||
public SaveMeta getData(DataInputStream stream) throws IOException{
|
||||
long time = stream.readLong(); //read last saved time
|
||||
long time = stream.readLong();
|
||||
long playtime = stream.readLong();
|
||||
int build = stream.readInt();
|
||||
byte mode = stream.readByte(); //read the gamemode
|
||||
String map = stream.readUTF(); //read the map
|
||||
int wave = stream.readInt(); //read the wave
|
||||
byte difficulty = stream.readByte(); //read the difficulty
|
||||
return new SaveMeta(version, time, playtime, build, mode, map, wave, Difficulty.values()[difficulty]);
|
||||
int sector = stream.readInt();
|
||||
byte mode = stream.readByte();
|
||||
String map = stream.readUTF();
|
||||
int wave = stream.readInt();
|
||||
byte difficulty = stream.readByte();
|
||||
return new SaveMeta(version, time, playtime, build, sector, mode, map, wave, Difficulty.values()[difficulty]);
|
||||
}
|
||||
|
||||
public abstract void read(DataInputStream stream) throws IOException;
|
||||
|
@ -14,16 +14,18 @@ public class SaveMeta{
|
||||
public int build;
|
||||
public String date;
|
||||
public long timePlayed;
|
||||
public int sector;
|
||||
public GameMode mode;
|
||||
public Map map;
|
||||
public int wave;
|
||||
public Difficulty difficulty;
|
||||
|
||||
public SaveMeta(int version, long date, long timePlayed, int build, int mode, String map, int wave, Difficulty difficulty){
|
||||
public SaveMeta(int version, long date, long timePlayed, int build, int sector, int mode, String map, int wave, Difficulty difficulty){
|
||||
this.version = version;
|
||||
this.build = build;
|
||||
this.date = Platform.instance.format(new Date(date));
|
||||
this.timePlayed = timePlayed;
|
||||
this.sector = sector;
|
||||
this.mode = GameMode.values()[mode];
|
||||
this.map = world.maps().getByName(map);
|
||||
this.wave = wave;
|
||||
|
@ -38,6 +38,7 @@ public class Save16 extends SaveFileVersion{
|
||||
stream.readLong(); //time
|
||||
stream.readLong(); //total playtime
|
||||
stream.readInt(); //build
|
||||
stream.readInt(); //sector ID
|
||||
|
||||
//general state
|
||||
byte mode = stream.readByte();
|
||||
@ -102,7 +103,7 @@ public class Save16 extends SaveFileVersion{
|
||||
byte elevation = stream.readByte();
|
||||
|
||||
Tile tile = new Tile(x, y, floorid, wallid);
|
||||
tile.elevation = elevation;
|
||||
tile.setElevation(elevation);
|
||||
|
||||
if(wallid == Blocks.blockpart.id){
|
||||
tile.link = stream.readByte();
|
||||
@ -136,7 +137,7 @@ public class Save16 extends SaveFileVersion{
|
||||
for(int j = i + 1; j < i + 1 + consecutives; j++){
|
||||
int newx = j % width, newy = j / width;
|
||||
Tile newTile = new Tile(newx, newy, floorid, wallid);
|
||||
newTile.elevation = elevation;
|
||||
newTile.setElevation(elevation);
|
||||
tiles[newx][newy] = newTile;
|
||||
}
|
||||
|
||||
@ -156,6 +157,7 @@ public class Save16 extends SaveFileVersion{
|
||||
stream.writeLong(TimeUtils.millis()); //last saved
|
||||
stream.writeLong(headless ? 0 : control.getSaves().getTotalPlaytime()); //playtime
|
||||
stream.writeInt(Version.build); //build
|
||||
stream.writeInt(world.getSector() == null ? invalidSector : world.getSector().packedPosition()); //sector ID
|
||||
|
||||
//--GENERAL STATE--
|
||||
stream.writeByte(state.mode.ordinal()); //gamemode
|
||||
@ -212,7 +214,7 @@ public class Save16 extends SaveFileVersion{
|
||||
|
||||
stream.writeByte(tile.getFloorID());
|
||||
stream.writeByte(tile.getWallID());
|
||||
stream.writeByte(tile.elevation);
|
||||
stream.writeByte(tile.getElevation());
|
||||
|
||||
if(tile.block() instanceof BlockPart){
|
||||
stream.writeByte(tile.link);
|
||||
@ -232,7 +234,7 @@ public class Save16 extends SaveFileVersion{
|
||||
for(int j = i + 1; j < world.width() * world.height() && consecutives < 255; j++){
|
||||
Tile nextTile = world.tile(j);
|
||||
|
||||
if(nextTile.getFloorID() != tile.getFloorID() || nextTile.getWallID() != 0 || nextTile.elevation != tile.elevation){
|
||||
if(nextTile.getFloorID() != tile.getFloorID() || nextTile.getWallID() != 0 || nextTile.getElevation() != tile.getElevation()){
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class NetworkIO{
|
||||
|
||||
stream.writeByte(tile.getFloorID());
|
||||
stream.writeByte(tile.getWallID());
|
||||
stream.writeByte(tile.elevation);
|
||||
stream.writeByte(tile.getElevation());
|
||||
|
||||
if(tile.block() instanceof BlockPart){
|
||||
stream.writeByte(tile.link);
|
||||
@ -84,7 +84,7 @@ public class NetworkIO{
|
||||
for(int j = i + 1; j < world.width() * world.height() && consecutives < 255; j++){
|
||||
Tile nextTile = world.tile(j);
|
||||
|
||||
if(nextTile.getFloorID() != tile.getFloorID() || nextTile.getWallID() != 0 || nextTile.elevation != tile.elevation){
|
||||
if(nextTile.getFloorID() != tile.getFloorID() || nextTile.getWallID() != 0 || nextTile.getElevation() != tile.getElevation()){
|
||||
break;
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ public class NetworkIO{
|
||||
byte elevation = stream.readByte();
|
||||
|
||||
Tile tile = new Tile(x, y, floorid, wallid);
|
||||
tile.elevation = elevation;
|
||||
tile.setElevation(elevation);
|
||||
|
||||
if(wallid == Blocks.blockpart.id){
|
||||
tile.link = stream.readByte();
|
||||
@ -205,7 +205,7 @@ public class NetworkIO{
|
||||
for(int j = i + 1; j < i + 1 + consecutives; j++){
|
||||
int newx = j % width, newy = j / width;
|
||||
Tile newTile = new Tile(newx, newy, floorid, wallid);
|
||||
newTile.elevation = elevation;
|
||||
newTile.setElevation(elevation);
|
||||
tiles[newx][newy] = newTile;
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ public class LevelDialog extends FloatingDialog{
|
||||
Timers.run(5f, () -> {
|
||||
Cursors.restoreCursor();
|
||||
threads.run(() -> {
|
||||
world.loadProceduralMap(0, 0);
|
||||
world.loadSector(0, 0);
|
||||
logic.play();
|
||||
Gdx.app.postRunnable(ui.loadfrag::hide);
|
||||
});
|
||||
|
@ -56,6 +56,7 @@ public class LoadDialog extends FloatingDialog{
|
||||
Array<SaveSlot> array = control.getSaves().getSaveSlots();
|
||||
|
||||
for(SaveSlot slot : array){
|
||||
if(slot.isHidden()) continue;
|
||||
|
||||
TextButton button = new TextButton("[accent]" + slot.getName(), "clear");
|
||||
button.getLabelCell().growX().left();
|
||||
@ -140,7 +141,10 @@ public class LoadDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
public void addSetup(){
|
||||
if(control.getSaves().getSaveSlots().size == 0){
|
||||
boolean valids = false;
|
||||
for(SaveSlot slot : control.getSaves().getSaveSlots()) if(!slot.isHidden()) valids = true;
|
||||
|
||||
if(!valids){
|
||||
|
||||
slots.row();
|
||||
slots.addButton("$text.save.none", "clear", () -> {
|
||||
|
@ -12,6 +12,7 @@ import io.anuke.ucore.scene.Element;
|
||||
import io.anuke.ucore.scene.event.ClickListener;
|
||||
import io.anuke.ucore.scene.event.InputEvent;
|
||||
import io.anuke.ucore.scene.event.InputListener;
|
||||
import io.anuke.ucore.scene.ui.TextButton;
|
||||
import io.anuke.ucore.scene.utils.Cursors;
|
||||
import io.anuke.ucore.scene.utils.ScissorStack;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
@ -26,15 +27,18 @@ public class SectorsDialog extends FloatingDialog{
|
||||
public SectorsDialog(){
|
||||
super("$text.sectors");
|
||||
|
||||
addCloseButton();
|
||||
setup();
|
||||
shown(this::setup);
|
||||
}
|
||||
|
||||
void setup(){
|
||||
content().clear();
|
||||
buttons().clear();
|
||||
|
||||
addCloseButton();
|
||||
|
||||
content().label(() -> Bundles.format("text.sector", selected == null ? "<none>" :
|
||||
selected.x + ", " + selected.y + (!selected.unlocked ? Bundles.get("text.sector.locked") : "")));
|
||||
(selected.x + ", " + selected.y + (!selected.unlocked ? " " + Bundles.get("text.sector.locked") : ""))
|
||||
+ (selected.saveID == -1 && selected.unlocked ? " " + Bundles.get("text.sector.unexplored") : "")));
|
||||
content().row();
|
||||
content().add(new SectorView()).grow();
|
||||
content().row();
|
||||
@ -42,10 +46,22 @@ public class SectorsDialog extends FloatingDialog{
|
||||
hide();
|
||||
|
||||
ui.loadLogic(() -> {
|
||||
world.loadProceduralMap(selected.x, selected.y);
|
||||
logic.play();
|
||||
if(!selected.hasSave()){
|
||||
world.loadSector(selected);
|
||||
logic.play();
|
||||
selected.saveID = control.getSaves().addSave("sector-" + selected.packedPosition()).index;
|
||||
world.sectors().save();
|
||||
}else{
|
||||
control.getSaves().getByID(selected.saveID).load();
|
||||
logic.play();
|
||||
}
|
||||
});
|
||||
}).size(230f, 64f).disabled(b -> selected == null);
|
||||
}).size(230f, 64f).name("deploy-button").disabled(b -> selected == null || !selected.unlocked);
|
||||
}
|
||||
|
||||
void selectSector(Sector sector){
|
||||
buttons().<TextButton>find("deploy-button").setText(sector.hasSave() ? "$text.sector.resume" : "$text.sector.deploy");
|
||||
selected = sector;
|
||||
}
|
||||
|
||||
class SectorView extends Element{
|
||||
@ -110,22 +126,20 @@ public class SectorsDialog extends FloatingDialog{
|
||||
float drawX = x + width/2f+ sectorX * sectorSize - offsetX * sectorSize - panX % sectorSize;
|
||||
float drawY = y + height/2f + sectorY * sectorSize - offsetY * sectorSize - panY % sectorSize;
|
||||
|
||||
if(world.sectors().get(sectorX, sectorY) == null){
|
||||
world.sectors().unlockSector(sectorX, sectorY);
|
||||
}
|
||||
|
||||
Sector sector = world.sectors().get(sectorX, sectorY);
|
||||
|
||||
if(sector == null) continue;
|
||||
if(sector != null && sector.texture != null){
|
||||
Draw.color(Color.WHITE);
|
||||
Draw.rect(sector.texture, drawX, drawY, sectorSize, sectorSize);
|
||||
}
|
||||
|
||||
Draw.color(Color.WHITE);
|
||||
Draw.rect(sector.texture, drawX, drawY, sectorSize, sectorSize);
|
||||
|
||||
if(sector == selected){
|
||||
if(sector == null){
|
||||
Draw.color(Color.DARK_GRAY);
|
||||
}else if(sector == selected){
|
||||
Draw.color(Palette.place);
|
||||
}else if(Mathf.inRect(mouse.x, mouse.y, drawX - sectorSize/2f, drawY - sectorSize/2f, drawX + sectorSize/2f, drawY + sectorSize/2f)){
|
||||
if(clicked){
|
||||
selected = sector;
|
||||
selectSector(sector);
|
||||
}
|
||||
Draw.color(Palette.remove);
|
||||
}else if (sector.unlocked){
|
||||
@ -134,7 +148,7 @@ public class SectorsDialog extends FloatingDialog{
|
||||
Draw.color(Color.LIGHT_GRAY);
|
||||
}
|
||||
|
||||
Lines.stroke(selected == sector ? 5f : 3f);
|
||||
Lines.stroke(sector != null && selected == sector ? 5f : 3f);
|
||||
Lines.crect(drawX, drawY, sectorSize, sectorSize);
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,13 @@ import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.IntMap;
|
||||
import com.badlogic.gdx.utils.ObjectIntMap;
|
||||
import io.anuke.mindustry.game.Content;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.type.ContentList;
|
||||
|
||||
public class ColorMapper implements ContentList{
|
||||
private static IntMap<Block> blockMap = new IntMap<>();
|
||||
private static ObjectIntMap<Block> colorMap = new ObjectIntMap<>();
|
||||
private static Color tmpColor = new Color();
|
||||
|
||||
public static Block getByColor(int color){
|
||||
return blockMap.get(color);
|
||||
@ -19,6 +21,18 @@ public class ColorMapper implements ContentList{
|
||||
return colorMap.get(block, 0);
|
||||
}
|
||||
|
||||
public static int colorFor(Block floor, Block wall, Team team, int elevation){
|
||||
int color = wall.breakable ? team.intColor : getBlockColor(wall);
|
||||
if(color == 0) color = ColorMapper.getBlockColor(floor);
|
||||
if(elevation > 0){
|
||||
float mul = 1.1f + elevation / 4f;
|
||||
tmpColor.set(color);
|
||||
tmpColor.mul(mul, mul, mul, 1f);
|
||||
color = Color.rgba8888(tmpColor);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
for(Block block : Block.all()){
|
||||
|
@ -34,8 +34,6 @@ public class Tile implements PosTrait, TargetTrait{
|
||||
public short x, y;
|
||||
/** Tile traversal cost. */
|
||||
public byte cost = 1;
|
||||
/** Elevation of tile. */
|
||||
public byte elevation;
|
||||
/** Position of cliffs around the tile, packed into bits 0-8. */
|
||||
public byte cliffs;
|
||||
/** Tile entity, usually null. */
|
||||
@ -47,6 +45,8 @@ public class Tile implements PosTrait, TargetTrait{
|
||||
private byte rotation;
|
||||
/** Team ordinal. */
|
||||
private byte team;
|
||||
/** Tile elevation. -1 means slope.*/
|
||||
private byte elevation;
|
||||
|
||||
public Tile(int x, int y){
|
||||
this.x = (short) x;
|
||||
@ -65,7 +65,7 @@ public class Tile implements PosTrait, TargetTrait{
|
||||
this.floor = (Floor) Block.getByID(floor);
|
||||
this.wall = Block.getByID(wall);
|
||||
this.rotation = rotation;
|
||||
this.elevation = elevation;
|
||||
this.setElevation(elevation);
|
||||
changed();
|
||||
this.team = team;
|
||||
}
|
||||
@ -201,6 +201,14 @@ public class Tile implements PosTrait, TargetTrait{
|
||||
this.rotation = dump;
|
||||
}
|
||||
|
||||
public byte getElevation(){
|
||||
return elevation;
|
||||
}
|
||||
|
||||
public void setElevation(int elevation){
|
||||
this.elevation = (byte)elevation;
|
||||
}
|
||||
|
||||
public boolean passable(){
|
||||
Block block = block();
|
||||
Block floor = floor();
|
||||
@ -217,7 +225,7 @@ public class Tile implements PosTrait, TargetTrait{
|
||||
Block block = block();
|
||||
Block floor = floor();
|
||||
return block.solid || cliffs != 0 || (floor.solid && (block == Blocks.air || block.solidifes)) || block.isSolidFor(this)
|
||||
|| (isLinked() && getLinked().block().isSolidFor(getLinked()));
|
||||
|| (isLinked() && getLinked().block().isSolidFor(getLinked()));
|
||||
}
|
||||
|
||||
public boolean breakable(){
|
||||
@ -453,6 +461,6 @@ public class Tile implements PosTrait, TargetTrait{
|
||||
Block floor = floor();
|
||||
|
||||
return floor.name() + ":" + block.name() + "[" + x + "," + y + "] " + "entity=" + (entity == null ? "null" : ClassReflection.getSimpleName(entity.getClass())) +
|
||||
(link != 0 ? " link=[" + (Bits.getLeftByte(link) - 8) + ", " + (Bits.getRightByte(link) - 8) + "]" : "");
|
||||
(link != 0 ? " link=[" + (Bits.getLeftByte(link) - 8) + ", " + (Bits.getRightByte(link) - 8) + "]" : "");
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ import io.anuke.mindustry.world.meta.BlockGroup;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
|
||||
public class Splitter extends Block{
|
||||
protected float speed = 8f;
|
||||
protected float speed = 7f;
|
||||
|
||||
public Splitter(String name){
|
||||
super(name);
|
||||
|
@ -104,13 +104,11 @@ public class ServerControl extends Module{
|
||||
world.loadMap(map);
|
||||
}else{
|
||||
info("Selected a procedural map.");
|
||||
world.loadProceduralMap();
|
||||
logic.play();
|
||||
playSectorMap();
|
||||
}
|
||||
}else{
|
||||
info("Selected a procedural map.");
|
||||
world.loadProceduralMap();
|
||||
logic.play();
|
||||
playSectorMap();
|
||||
}
|
||||
}else{
|
||||
state.set(State.menu);
|
||||
@ -181,17 +179,17 @@ public class ServerControl extends Module{
|
||||
|
||||
logic.reset();
|
||||
world.loadMap(result);
|
||||
logic.play();
|
||||
}else{
|
||||
Log.info("&ly&fiNo map specified, so a procedural one was generated.");
|
||||
world.loadProceduralMap();
|
||||
playSectorMap();
|
||||
}
|
||||
|
||||
}else{
|
||||
Log.info("&ly&fiNo map specified, so a procedural one was generated.");
|
||||
world.loadProceduralMap();
|
||||
playSectorMap();
|
||||
}
|
||||
|
||||
logic.play();
|
||||
info("Map loaded.");
|
||||
|
||||
host();
|
||||
@ -807,6 +805,11 @@ public class ServerControl extends Module{
|
||||
}
|
||||
}
|
||||
|
||||
private void playSectorMap(){
|
||||
world.loadSector(world.sectors().get(0, 0));
|
||||
logic.play();
|
||||
}
|
||||
|
||||
private void host(){
|
||||
try{
|
||||
Net.host(port);
|
||||
|
Loading…
Reference in New Issue
Block a user