Added prototype planet sector land system

This commit is contained in:
Anuken
2020-01-20 12:05:26 -05:00
parent 01e7397df5
commit 27d6bf067e
17 changed files with 1902 additions and 1734 deletions

View File

@@ -156,7 +156,7 @@ public abstract class BasicGenerator extends RandomGenerator{
block = tiles.getn(x, y).block();
ore = tiles.getn(x, y).overlay();
r.get(x, y);
tiles.set(x, y, new Tile(x, y, floor.id, ore.id, block.id));
tiles.set(x, y, new Tile(x, y, floor, ore, block));
}
}
}

View File

@@ -24,7 +24,7 @@ public abstract class RandomGenerator extends Generator{
block = Blocks.air;
ore = Blocks.air;
generate(x, y);
tiles.set(x, y, new Tile(x, y, floor.id, ore.id, block.id));
tiles.set(x, y, new Tile(x, y, floor, ore, block));
}
}

View File

@@ -2,9 +2,10 @@ package mindustry.maps.planet;
import arc.graphics.*;
import arc.math.geom.*;
import mindustry.world.*;
public interface PlanetGenerator{
float getHeight(Vec3 position);
Color getColor(Vec3 position);
//void generate(Vec3 position, Tile tile);
void generate(Vec3 position, TileGen tile);
}

View File

@@ -3,15 +3,28 @@ package mindustry.maps.planet;
import arc.graphics.*;
import arc.math.*;
import arc.math.geom.*;
import arc.struct.*;
import arc.util.*;
import arc.util.noise.*;
import mindustry.content.*;
import mindustry.world.*;
public class TestPlanetGenerator implements PlanetGenerator{
Pixmap pix = new Pixmap("planets/colors.png");
Pixmap pix;
Simplex noise = new Simplex();
int waterLevel = 5;
float water = waterLevel / (float)(pix.getHeight());
float water;
float scl = 5f;
Array<Block> blocks = Array.with(Blocks.sporeMoss, Blocks.moss, Blocks.ice, Blocks.snow, Blocks.sand, Blocks.darksand, Blocks.darksandWater, Blocks.darksandTaintedWater);
public TestPlanetGenerator(){
try{
pix = new Pixmap("planets/colors.png");
water = waterLevel / (float)(pix.getHeight());
}catch(Exception ignored){
}
}
@Override
public float getHeight(Vec3 position){
@@ -35,6 +48,13 @@ public class TestPlanetGenerator implements PlanetGenerator{
height *= 1.2f;
height = Mathf.clamp(height);
return Tmp.c1.set(pix.getPixel((int)(temp * (pix.getWidth()-1)), (int)((1f-height) * (pix.getHeight()-1))));
Color color = Tmp.c1.set(pix.getPixel((int)(temp * (pix.getWidth()-1)), (int)((1f-height) * (pix.getHeight()-1))));
return blocks.min(c -> color.diff(c.color)).color;
}
@Override
public void generate(Vec3 position, TileGen tile){
Color color = getColor(position);
tile.floor = blocks.min(c -> color.diff(c.color));
}
}