Possible empty sectors
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
package io.anuke.mindustry.maps;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
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 com.badlogic.gdx.utils.async.AsyncExecutor;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.game.Difficulty;
|
||||
@@ -33,6 +35,7 @@ public class Sectors{
|
||||
private final GridMap<Sector> grid = new GridMap<>();
|
||||
private final SectorPresets presets = new SectorPresets();
|
||||
private final Array<Item> allOres = Item.getAllOres();
|
||||
private AsyncExecutor executor = new AsyncExecutor(6);
|
||||
|
||||
public void playSector(Sector sector){
|
||||
if(sector.hasSave() && SaveIO.breakingVersions.contains(sector.getSave().getBuild())){
|
||||
@@ -125,6 +128,10 @@ public class Sectors{
|
||||
if(sector.texture == null){
|
||||
threads.runGraphics(() -> createTexture(sector));
|
||||
}
|
||||
|
||||
if(sector.missions.size == 0){
|
||||
completeSector(sector.x, sector.y);
|
||||
}
|
||||
}
|
||||
|
||||
public void abandonSector(Sector sector){
|
||||
@@ -217,6 +224,10 @@ public class Sectors{
|
||||
|
||||
/**Generates a mission for a sector. This is deterministic and the same for each client.*/
|
||||
private void generate(Sector sector){
|
||||
//25% chance for no missions, empty sector
|
||||
if(Mathf.randomSeed(sector.getSeed() + 213) < 0.4){
|
||||
return;
|
||||
}
|
||||
|
||||
//50% chance to get a wave mission
|
||||
if(Mathf.randomSeed(sector.getSeed() + 6) < 0.5){
|
||||
@@ -259,24 +270,33 @@ public class Sectors{
|
||||
sector.texture.dispose();
|
||||
}
|
||||
|
||||
Pixmap pixmap = new Pixmap(sectorImageSize, sectorImageSize, Format.RGBA8888);
|
||||
GenResult secResult = new GenResult();
|
||||
executor.submit(() -> {
|
||||
Pixmap pixmap = new Pixmap(sectorImageSize, sectorImageSize, Format.RGBA8888);
|
||||
GenResult result = new GenResult();
|
||||
GenResult secResult = new GenResult();
|
||||
|
||||
for(int x = 0; x < pixmap.getWidth(); x++){
|
||||
for(int y = 0; y < pixmap.getHeight(); y++){
|
||||
int toX = x * sectorSize / sectorImageSize;
|
||||
int toY = y * sectorSize / sectorImageSize;
|
||||
for(int x = 0; x < pixmap.getWidth(); x++){
|
||||
for(int y = 0; y < pixmap.getHeight(); y++){
|
||||
int toX = x * sectorSize / sectorImageSize;
|
||||
int toY = y * sectorSize / sectorImageSize;
|
||||
|
||||
GenResult result = world.generator.generateTile(sector.x, sector.y, toX, toY, false);
|
||||
world.generator.generateTile(secResult, sector.x, sector.y, toX, ((y+1) * sectorSize / sectorImageSize), false, null, null);
|
||||
world.generator.generateTile(result, sector.x, sector.y, toX, toY, false, null, null);
|
||||
world.generator.generateTile(secResult, sector.x, sector.y, toX, ((y+1) * sectorSize / sectorImageSize), false, null, null);
|
||||
|
||||
int color = ColorMapper.colorFor(result.floor, result.wall, Team.none, result.elevation, secResult.elevation > result.elevation ? (byte)(1 << 6) : (byte)0);
|
||||
pixmap.drawPixel(x, pixmap.getHeight() - 1 - y, color);
|
||||
int color = ColorMapper.colorFor(result.floor, result.wall, Team.none, result.elevation, secResult.elevation > result.elevation ? (byte)(1 << 6) : (byte)0);
|
||||
pixmap.drawPixel(x, pixmap.getHeight() - 1 - y, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sector.texture = new Texture(pixmap);
|
||||
pixmap.dispose();
|
||||
Gdx.app.postRunnable(() -> {
|
||||
sector.texture = new Texture(pixmap);
|
||||
pixmap.dispose();
|
||||
});
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -135,28 +135,29 @@ public class SectorsDialog extends FloatingDialog{
|
||||
int sectorX = offsetX + x;
|
||||
int sectorY = offsetY + y;
|
||||
|
||||
float drawX = x + width/2f+ sectorX * padSectorSize - offsetX * padSectorSize - panX % padSectorSize;
|
||||
float drawY = y + height/2f + sectorY * padSectorSize - offsetY * padSectorSize - panY % padSectorSize;
|
||||
float drawX = x + width/2f+ sectorX * padSectorSize - offsetX * padSectorSize - panX % padSectorSize + padSectorSize/2f;
|
||||
float drawY = y + height/2f + sectorY * padSectorSize - offsetY * padSectorSize - panY % padSectorSize + padSectorSize/2f;
|
||||
|
||||
Sector sector = world.sectors.get(sectorX, sectorY);
|
||||
int width = 1;
|
||||
int height = 1;
|
||||
|
||||
if(sector == null || sector.texture == null){
|
||||
Draw.color(Color.DARK_GRAY);
|
||||
Draw.rect(Draw.getBlankRegion(), drawX, drawY, sectorSize * width + 1f, sectorSize * height + 1f);
|
||||
continue;
|
||||
}
|
||||
|
||||
drawX += (width)/2f*padSectorSize;
|
||||
drawY += (height)/2f*padSectorSize;
|
||||
|
||||
Draw.colorl(!sector.complete ? 0.3f : 1f);
|
||||
Draw.rect(sector.texture, drawX, drawY, sectorSize * width + 1f, sectorSize * height + 1f);
|
||||
|
||||
float stroke = 4f;
|
||||
if(sector.missions.size == 0) continue;
|
||||
|
||||
Draw.color(Color.DARK_GRAY);
|
||||
Fill.square(drawX, drawY - 5f, Unit.dp.scl(10f), 45f);
|
||||
|
||||
if(sector == selected){
|
||||
Draw.color(Palette.place);
|
||||
stroke = 6f;
|
||||
}else if(Mathf.inRect(mouse.x, mouse.y, drawX - padSectorSize/2f * width, drawY - padSectorSize/2f * height,
|
||||
drawX + padSectorSize/2f * width, drawY + padSectorSize/2f * height)){
|
||||
if(clicked){
|
||||
@@ -169,13 +170,12 @@ public class SectorsDialog extends FloatingDialog{
|
||||
Draw.color(Color.LIGHT_GRAY);
|
||||
}
|
||||
|
||||
Lines.stroke(Unit.dp.scl(stroke));
|
||||
Fill.square(drawX, drawY, Unit.dp.scl(10f), 45f);
|
||||
//Lines.crect(drawX, drawY, sectorSize * width + paddingx, sectorSize * height + paddingy, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Draw.color(Palette.accent);
|
||||
Draw.color(Color.GRAY);
|
||||
Lines.stroke(Unit.dp.scl(4f));
|
||||
//Lines.crect(x + width/2f, y + height/2f, width, height);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user