From c788f4a7f8c01206118b00b5491c1589ff7b6968 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 8 Jan 2022 22:21:59 -0500 Subject: [PATCH] Planet launch candidate system --- core/src/mindustry/content/Planets.java | 20 +++++++++++++------ .../maps/planet/AsteroidGenerator.java | 3 ++- core/src/mindustry/type/Planet.java | 13 ++++++++++++ core/src/mindustry/type/Sector.java | 4 ++++ .../mindustry/ui/dialogs/PlanetDialog.java | 11 ++++++++-- 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/core/src/mindustry/content/Planets.java b/core/src/mindustry/content/Planets.java index c3c7e19247..8ddcb84f63 100644 --- a/core/src/mindustry/content/Planets.java +++ b/core/src/mindustry/content/Planets.java @@ -18,7 +18,10 @@ public class Planets{ sun, erekir, tantros, - serpulo; + serpulo, + gier, + notva, + verilus; public static void load(){ sun = new Planet("sun", null, 4f){{ @@ -52,7 +55,8 @@ public class Planets{ lightDstFrom = 0.2f; }}; - makeAsteroid("gier", erekir, Blocks.ferricStoneWall, Blocks.carbonWall, 0.4f, 7, 1f, gen -> { + //TODO names + gier = makeAsteroid("gier", erekir, Blocks.ferricStoneWall, Blocks.carbonWall, 0.4f, 7, 1f, gen -> { gen.min = 25; gen.max = 35; gen.carbonChance = 0.6f; @@ -60,7 +64,7 @@ public class Planets{ gen.berylChance = 0.1f; }); - makeAsteroid("notva", sun, Blocks.ferricStoneWall, Blocks.beryllicStoneWall, 0.55f, 9, 1.3f, gen -> { + notva = makeAsteroid("notva", sun, Blocks.ferricStoneWall, Blocks.beryllicStoneWall, 0.55f, 9, 1.3f, gen -> { gen.berylChance = 0.8f; gen.iceChance = 0f; gen.carbonChance = 0.01f; @@ -91,16 +95,20 @@ public class Planets{ landCloudColor = Pal.spore.cpy().a(0.5f); }}; - makeAsteroid("verlius", sun, Blocks.stoneWall, Blocks.iceWall, 0.5f, 12, 2f, gen -> { + verilus = makeAsteroid("verlius", sun, Blocks.stoneWall, Blocks.iceWall, 0.5f, 12, 2f, gen -> { gen.berylChance = 0f; gen.iceChance = 0.6f; gen.carbonChance = 0.1f; gen.ferricChance = 0f; }); + + //define launch candidates after all planets initialize + serpulo.launchCandidates.add(gier); + gier.launchCandidates.add(erekir); } - private static void makeAsteroid(String name, Planet parent, Block base, Block tint, float tintThresh, int pieces, float scale, Cons cgen){ - new Planet(name, parent, 0.12f){{ + private static Planet makeAsteroid(String name, Planet parent, Block base, Block tint, float tintThresh, int pieces, float scale, Cons cgen){ + return new Planet(name, parent, 0.12f){{ hasAtmosphere = false; updateLighting = false; sectors.add(new Sector(this, Ptile.empty)); diff --git a/core/src/mindustry/maps/planet/AsteroidGenerator.java b/core/src/mindustry/maps/planet/AsteroidGenerator.java index 3416db7f22..279b3835b8 100644 --- a/core/src/mindustry/maps/planet/AsteroidGenerator.java +++ b/core/src/mindustry/maps/planet/AsteroidGenerator.java @@ -109,8 +109,9 @@ public class AsteroidGenerator extends BlankPlanetGenerator{ //copper only generates on ferric stone ore(Blocks.oreCopper, Blocks.ferricStone, 5f, 0.8f * copperScale); - //thorium only generates on beryllic stone + //thorium only generates on beryllic stone and graphitic stone ore(Blocks.oreThorium, Blocks.beryllicStone, 4f, 0.9f * thoriumScl); + ore(Blocks.oreThorium, Blocks.carbonStone, 4f, 0.9f * thoriumScl); wallOre(Blocks.carbonWall, Blocks.graphiticWall, 35f, 0.57f * graphiteScale); diff --git a/core/src/mindustry/type/Planet.java b/core/src/mindustry/type/Planet.java index 016d358b83..064deb1077 100644 --- a/core/src/mindustry/type/Planet.java +++ b/core/src/mindustry/type/Planet.java @@ -89,6 +89,8 @@ public class Planet extends UnlockableContent{ public Seq children = new Seq<>(); /** Default root node shown when the tech tree is opened here. */ public @Nullable TechNode techTree; + /** Planets that can be launched to from this one. Made mutual in init(). */ + public Seq launchCandidates = new Seq<>(); /** Loads the mesh. Clientside only. Defaults to a boring sphere mesh. */ protected Prov meshLoader = () -> new ShaderSphereMesh(this, Shaders.unlit, 2), cloudMeshLoader = () -> null; @@ -265,6 +267,17 @@ public class Planet extends UnlockableContent{ updateBaseCoverage(); } + //make planet launch candidates mutual. + var candidates = launchCandidates.copy(); + + for(Planet planet : content.planets()){ + if(planet.launchCandidates.contains(this)){ + candidates.addUnique(planet); + } + } + + launchCandidates = candidates; + clipRadius = Math.max(clipRadius, radius + atmosphereRadOut + 0.5f); } diff --git a/core/src/mindustry/type/Sector.java b/core/src/mindustry/type/Sector.java index 8b28d8808b..de018bfafb 100644 --- a/core/src/mindustry/type/Sector.java +++ b/core/src/mindustry/type/Sector.java @@ -126,6 +126,10 @@ public class Sector{ public String name(){ if(preset != null && info.name == null) return preset.localizedName; + //single-sector "planets" use their own name for the sector name. + if(info.name == null && planet.sectors.size == 1){ + return planet.localizedName; + } return info.name == null ? id + "" : info.name; } diff --git a/core/src/mindustry/ui/dialogs/PlanetDialog.java b/core/src/mindustry/ui/dialogs/PlanetDialog.java index ce188c9d11..e57fb31e75 100644 --- a/core/src/mindustry/ui/dialogs/PlanetDialog.java +++ b/core/src/mindustry/ui/dialogs/PlanetDialog.java @@ -256,6 +256,13 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ this.listener = listener; launchSector = sector; + //automatically select next planets; TODO pan! + if(sector.planet.launchCandidates.size == 1){ + state.planet = sector.planet.launchCandidates.first(); + } + + //TODO pan over to correct planet + //update view to sector zoom = 1f; state.zoom = 1f; @@ -292,7 +299,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ boolean canSelect(Sector sector){ if(mode == select) return sector.hasBase(); - //cannot launch to existing sector w/ accelerator + //cannot launch to existing sector w/ accelerator TODO test if(mode == planetLaunch) return !sector.hasBase(); if(sector.hasBase() || sector.id == sector.planet.startSector) return true; //preset sectors can only be selected once unlocked @@ -452,7 +459,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ boolean selectable(Planet planet){ //TODO what if any sector is selectable? //TODO launch criteria - which planets can be launched to? Where should this be defined? Should planets even be selectable? - if(mode == planetLaunch) return launchSector != null && planet != launchSector.planet; + if(mode == planetLaunch) return launchSector != null && planet != launchSector.planet && launchSector.planet.launchCandidates.contains(planet); return planet == state.planet || (planet.alwaysUnlocked && planet.isLandable()) || planet.sectors.contains(Sector::hasBase); }