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;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user