From 0579c9e6c957f56652b417a07e7853aed9fc3369 Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 28 Jan 2022 15:52:06 -0500 Subject: [PATCH] No erekir launch schems / Tech tree fix --- .../src/mindustry/content/ErekirTechTree.java | 8 ++-- core/src/mindustry/content/Planets.java | 1 + core/src/mindustry/game/Schematics.java | 14 +++++- .../maps/planet/ErekirPlanetGenerator.java | 4 +- core/src/mindustry/type/Planet.java | 2 + .../ui/dialogs/LaunchLoadoutDialog.java | 43 +++++++++++-------- 6 files changed, 46 insertions(+), 26 deletions(-) diff --git a/core/src/mindustry/content/ErekirTechTree.java b/core/src/mindustry/content/ErekirTechTree.java index aea0d11281..28ab787087 100644 --- a/core/src/mindustry/content/ErekirTechTree.java +++ b/core/src/mindustry/content/ErekirTechTree.java @@ -40,15 +40,15 @@ public class ErekirTechTree{ }); }); - node(reinforcedContainer, () -> { - node(overflowDuct, () -> { + node(overflowDuct, () -> { + node(reinforcedContainer, () -> { node(ductUnloader, () -> { }); - }); - node(reinforcedVault, () -> { + node(reinforcedVault, () -> { + }); }); }); }); diff --git a/core/src/mindustry/content/Planets.java b/core/src/mindustry/content/Planets.java index e286b82c94..0324fd80be 100644 --- a/core/src/mindustry/content/Planets.java +++ b/core/src/mindustry/content/Planets.java @@ -100,6 +100,7 @@ public class Planets{ new HexSkyMesh(this, 1, 0.6f, 0.16f, 5, Color.white.cpy().lerp(Pal.spore, 0.55f).a(0.75f), 2, 0.45f, 1f, 0.41f) ); + allowLaunchSchematics = true; atmosphereColor = Color.valueOf("3c1b8f"); atmosphereRadIn = 0.02f; atmosphereRadOut = 0.3f; diff --git a/core/src/mindustry/game/Schematics.java b/core/src/mindustry/game/Schematics.java index bf8c67ec70..88d6123233 100644 --- a/core/src/mindustry/game/Schematics.java +++ b/core/src/mindustry/game/Schematics.java @@ -58,6 +58,7 @@ public class Schematics implements Loadable{ private OrderedMap previews = new OrderedMap<>(); private ObjectSet errored = new ObjectSet<>(); private ObjectMap> loadouts = new ObjectMap<>(); + private ObjectMap defaultLoadouts = new ObjectMap<>(); private FrameBuffer shadowBuffer; private Texture errorTexture; private long lastClearTime; @@ -288,19 +289,28 @@ public class Schematics implements Loadable{ return loadouts; } + public @Nullable Schematic getDefaultLoadout(CoreBlock block){ + return defaultLoadouts.get(block); + } + /** Checks a schematic for deployment validity and adds it to the cache. */ - private void checkLoadout(Schematic s, boolean validate){ + private void checkLoadout(Schematic s, boolean customSchem){ Stile core = s.tiles.find(t -> t.block instanceof CoreBlock); if(core == null) return; int cores = s.tiles.count(t -> t.block instanceof CoreBlock); int maxSize = getMaxLaunchSize(core.block); //make sure a core exists, and that the schematic is small enough. - if((validate && (s.width > maxSize || s.height > maxSize + if((customSchem && (s.width > maxSize || s.height > maxSize || s.tiles.contains(t -> t.block.buildVisibility == BuildVisibility.sandboxOnly || !t.block.unlocked()) || cores > 1))) return; //place in the cache loadouts.get((CoreBlock)core.block, Seq::new).add(s); + + //save non-custom loadout + if(!customSchem){ + defaultLoadouts.put((CoreBlock)core.block, s); + } } public int getMaxLaunchSize(Block block){ diff --git a/core/src/mindustry/maps/planet/ErekirPlanetGenerator.java b/core/src/mindustry/maps/planet/ErekirPlanetGenerator.java index e8bf77dbcb..27f5a22f3d 100644 --- a/core/src/mindustry/maps/planet/ErekirPlanetGenerator.java +++ b/core/src/mindustry/maps/planet/ErekirPlanetGenerator.java @@ -17,7 +17,7 @@ import mindustry.world.meta.*; import static mindustry.Vars.*; public class ErekirPlanetGenerator extends PlanetGenerator{ - public float scl = 2f; + //public float scl = 2f; public float heightScl = 0.9f, octaves = 8, persistence = 0.7f, heightPow = 3f, heightMult = 1.6f; //TODO inline/remove @@ -71,7 +71,7 @@ public class ErekirPlanetGenerator extends PlanetGenerator{ float height = rawHeight(position); Tmp.v31.set(position); - position = Tmp.v33.set(position).scl(scl); + //position = Tmp.v33.set(position).scl(scl); //float temp = Simplex.noise3d(seed, 8, 0.6, 1f/2f, 10f + position.x, 10f + position.y + 99f, 10f + position.z); //Mathf.clamp((int)(temp * arr.length), 0, arr[0].length - 1) height *= 1.2f; diff --git a/core/src/mindustry/type/Planet.java b/core/src/mindustry/type/Planet.java index 183771839a..ae2d8de0db 100644 --- a/core/src/mindustry/type/Planet.java +++ b/core/src/mindustry/type/Planet.java @@ -88,6 +88,8 @@ public class Planet extends UnlockableContent{ public Color atmosphereColor = new Color(0.3f, 0.7f, 1.0f); /** Whether this planet has an atmosphere. */ public boolean hasAtmosphere = true; + /** Whether to allow users to specify a custom launch schematic for this map. */ + public boolean allowLaunchSchematics = false; /** Parent body that this planet orbits around. If null, this planet is considered to be in the middle of the solar system.*/ public @Nullable Planet parent; /** The root parent of the whole solar system this planet is in. */ diff --git a/core/src/mindustry/ui/dialogs/LaunchLoadoutDialog.java b/core/src/mindustry/ui/dialogs/LaunchLoadoutDialog.java index 7d6ff7e479..ded82fb471 100644 --- a/core/src/mindustry/ui/dialogs/LaunchLoadoutDialog.java +++ b/core/src/mindustry/ui/dialogs/LaunchLoadoutDialog.java @@ -115,31 +115,38 @@ public class LaunchLoadoutDialog extends BaseDialog{ cont.add(Core.bundle.format("launch.from", sector.name())).row(); cont.pane(t -> { - int i = 0; + int[] i = {0}; - for(var entry : schematics.getLoadouts()){ - if(entry.key.size <= core.size){ - for(Schematic s : entry.value){ - if(s.tiles.contains(tile -> !tile.block.supportsEnv(sector.planet.defaultEnv) || - //make sure block can be built here. - (!state.rules.hiddenBuildItems.isEmpty() && Structs.contains(tile.block.requirements, stack -> state.rules.hiddenBuildItems.contains(stack.item))))){ - continue; - } + Cons handler = s -> { + if(s.tiles.contains(tile -> !tile.block.supportsEnv(sector.planet.defaultEnv) || + //make sure block can be built here. + (!state.rules.hiddenBuildItems.isEmpty() && Structs.contains(tile.block.requirements, stack -> state.rules.hiddenBuildItems.contains(stack.item))))){ + return; + } - t.button(b -> b.add(new SchematicImage(s)), Styles.togglet, () -> { - selected = s; - update.run(); - rebuildItems.run(); - }).group(group).pad(4).checked(s == selected).size(200f); + t.button(b -> b.add(new SchematicImage(s)), Styles.togglet, () -> { + selected = s; + update.run(); + rebuildItems.run(); + }).group(group).pad(4).checked(s == selected).size(200f); - if(++i % cols == 0){ - t.row(); + if(++i[0] % cols == 0){ + t.row(); + } + }; + + if(sector.planet.allowLaunchSchematics || schematics.getDefaultLoadout(core) == null){ + for(var entry : schematics.getLoadouts()){ + if(entry.key.size <= core.size){ + for(Schematic s : entry.value){ + handler.get(s); } } } + }else{ + //only allow launching with the standard loadout schematic + handler.get(schematics.getDefaultLoadout(core)); } - - }).growX().scrollX(false); cont.row();