Moved over map generator / Fixed logic updating on both threads

This commit is contained in:
Anuken
2018-06-20 11:09:44 -04:00
parent 33a278ccb4
commit 56bb23400a
9 changed files with 41 additions and 280 deletions

View File

@@ -102,7 +102,7 @@ public class Logic extends Module {
@Override
public void update(){
if(!doUpdate) return;
if(threads.isEnabled() && !threads.isOnThread()) return;
if(!state.is(State.menu)){

View File

@@ -111,6 +111,10 @@ public class ThreadHandler {
return enabled;
}
public boolean isOnThread(){
return impl.isOnThread();
}
private void runLogic(){
try {
while (true) {

View File

@@ -39,6 +39,9 @@ public class FloorRenderer {
}
public void drawFloor(){
if(cache == null){
return;
}
OrthographicCamera camera = Core.camera;
@@ -103,6 +106,10 @@ public class FloorRenderer {
}
public void beginDraw(){
if(cache == null){
return;
}
cbatch.setProjectionMatrix(Core.camera.combined);
cbatch.beginDraw();
@@ -110,10 +117,18 @@ public class FloorRenderer {
}
public void endDraw(){
if(cache == null){
return;
}
cbatch.endDraw();
}
public void drawLayer(CacheLayer layer){
if(cache == null){
return;
}
OrthographicCamera camera = Core.camera;
int crangex = (int)(camera.viewportWidth * camera.zoom / (chunksize * tilesize))+1;

View File

@@ -0,0 +1,85 @@
package io.anuke.mindustry.world.mapgen;
public class GenProperties {
public long seed;
public MapStyle maps;
public OreStyle ores;
public RiverType riverType;
public RiverStyle rivers;
public TerrainStyle terrains;
public FoliageStyle foliage;
public EnvironmentStyle environment;
enum MapStyle{
/**256x512*/
longY,
/**128x256*/
smallY,
/**128x128*/
small,
/**256x256*/
normal
}
enum OreStyle{
/**'vanilla' noise-distributed ores*/
normal,
/**ores hug the walls*/
nearWalls,
/**ores hug all liquid rivers*/
nearRivers,
/**large veins*/
largeVeins
}
enum RiverType{
lava,
water,
oil,
none
}
enum RiverStyle{
/**long thin river spanning entire map*/
longThin,
/**long river branching into many others*/
longBranch,
/**one long, thick river*/
longThick,
/**short, thick river that ends in a lake*/
shortLake
}
enum TerrainStyle{
/**bordered around by the normal material*/
normal,
/**everything is islands*/
waterIslands,
/**everything is islands: lava edition*/
lavaIslands
}
enum FoliageStyle{
patches,
veins,
blobs,
ridges
}
enum FoilageType{
grass,
sand,
darkStone,
ice,
}
enum EnvironmentStyle{
desert,
stoneDesert,
grassy,
dark,
darkStone,
stone,
icy,
}
}

View File

@@ -0,0 +1,20 @@
package io.anuke.mindustry.world.mapgen;
import io.anuke.mindustry.io.MapTileData;
import io.anuke.ucore.noise.RidgedPerlin;
import io.anuke.ucore.noise.Simplex;
public class ProcGen {
public RidgedPerlin rid = new RidgedPerlin(1, 1);
public Simplex sim = new Simplex();
public MapTileData generate(GenProperties props){
MapTileData data = new MapTileData(300, 300);
for (int x = 0; x < data.width(); x++) {
for (int y = 0; y < data.height(); y++) {
}
}
return null;
}
}