Planet constructor tweaks

This commit is contained in:
Anuken
2021-06-09 22:18:54 -04:00
parent 1ce6772601
commit 35be671d86
2 changed files with 21 additions and 19 deletions

View File

@@ -15,7 +15,7 @@ public class Planets implements ContentList{
@Override
public void load(){
sun = new Planet("sun", null, 0, 2){{
sun = new Planet("sun", null, 2){{
bloom = true;
accessible = false;
@@ -32,7 +32,7 @@ public class Planets implements ContentList{
);
}};
erekir = new Planet("erekir", sun, 2, 1){{
erekir = new Planet("erekir", sun, 1, 2){{
generator = new ErekirPlanetGenerator();
meshLoader = () -> new HexMesh(this, 4);
atmosphereColor = Color.valueOf("f07218");
@@ -42,7 +42,7 @@ public class Planets implements ContentList{
tidalLock = true;
}};
tantros = new Planet("tantros", sun, 2, 1){{
tantros = new Planet("tantros", sun, 1, 2){{
generator = new TantrosPlanetGenerator();
meshLoader = () -> new HexMesh(this, 4);
atmosphereColor = Color.valueOf("3db899");
@@ -51,7 +51,7 @@ public class Planets implements ContentList{
atmosphereRadOut = 0.3f;
}};
serpulo = new Planet("serpulo", sun, 3, 1){{
serpulo = new Planet("serpulo", sun, 1, 3){{
generator = new SerpuloPlanetGenerator();
meshLoader = () -> new HexMesh(this, 6);
atmosphereColor = Color.valueOf("3c1b8f");

View File

@@ -30,7 +30,7 @@ public class Planet extends UnlockableContent{
/** Generator that will make the planet. Can be null for planets that don't need to be landed on. */
public @Nullable PlanetGenerator generator;
/** Array of sectors; directly maps to tiles in the grid. */
public Seq<Sector> sectors;
public Seq<Sector> sectors = new Seq<>();
/** Radius of this planet's sphere. Does not take into account satellites. */
public float radius;
/** Atmosphere radius adjustment parameters. */
@@ -72,25 +72,12 @@ public class Planet extends UnlockableContent{
/** Loads the mesh. Clientside only. Defaults to a boring sphere mesh. */
protected Prov<PlanetMesh> meshLoader = () -> new ShaderSphereMesh(this, Shaders.unlit, 2);
public Planet(String name, Planet parent, int sectorSize, float radius){
public Planet(String name, Planet parent, float radius){
super(name);
this.radius = radius;
this.parent = parent;
if(sectorSize > 0){
grid = PlanetGrid.create(sectorSize);
sectors = new Seq<>(grid.tiles.length);
for(int i = 0; i < grid.tiles.length; i++){
sectors.add(new Sector(this, grid.tiles[i]));
}
sectorApproxRadius = sectors.first().tile.v.dst(sectors.first().tile.corners[0].v);
}else{
sectors = new Seq<>();
}
//total radius is initially just the radius
totalRadius += radius;
@@ -110,6 +97,21 @@ public class Planet extends UnlockableContent{
for(solarSystem = this; solarSystem.parent != null; solarSystem = solarSystem.parent);
}
public Planet(String name, Planet parent, float radius, int sectorSize){
this(name, parent, radius);
if(sectorSize > 0){
grid = PlanetGrid.create(sectorSize);
sectors.ensureCapacity(grid.tiles.length);
for(int i = 0; i < grid.tiles.length; i++){
sectors.add(new Sector(this, grid.tiles[i]));
}
sectorApproxRadius = sectors.first().tile.v.dst(sectors.first().tile.corners[0].v);
}
}
public @Nullable Sector getLastSector(){
if(sectors.isEmpty()){
return null;