From c3ad3a98238b237454796daefb1103dca85274eb Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 18 May 2020 20:17:02 -0400 Subject: [PATCH] Lock state implementation --- core/src/mindustry/io/SaveIO.java | 2 +- .../maps/planet/TODOPlanetGenerator.java | 4 +- core/src/mindustry/type/Sector.java | 13 ++++++- core/src/mindustry/type/SectorPreset.java | 7 ---- .../mindustry/ui/dialogs/PlanetDialog.java | 38 ++++++++++--------- gradle.properties | 2 +- 6 files changed, 37 insertions(+), 29 deletions(-) diff --git a/core/src/mindustry/io/SaveIO.java b/core/src/mindustry/io/SaveIO.java index 9f637224d9..d6ff052f12 100644 --- a/core/src/mindustry/io/SaveIO.java +++ b/core/src/mindustry/io/SaveIO.java @@ -143,7 +143,7 @@ public class SaveIO{ } } - /** Loads from a deflated (!) input stream.*/ + /** Loads from a deflated (!) input stream. */ public static void load(InputStream is, WorldContext context) throws SaveException{ try(CounterInputStream counter = new CounterInputStream(is); DataInputStream stream = new DataInputStream(counter)){ logic.reset(); diff --git a/core/src/mindustry/maps/planet/TODOPlanetGenerator.java b/core/src/mindustry/maps/planet/TODOPlanetGenerator.java index 074c4331ea..d5b9bd4d87 100644 --- a/core/src/mindustry/maps/planet/TODOPlanetGenerator.java +++ b/core/src/mindustry/maps/planet/TODOPlanetGenerator.java @@ -38,7 +38,9 @@ public class TODOPlanetGenerator extends PlanetGenerator{ ObjectMap dec = ObjectMap.of( Blocks.sporeMoss, Blocks.sporeCluster, - Blocks.moss, Blocks.sporeCluster + Blocks.moss, Blocks.sporeCluster, + Blocks.taintedWater, Blocks.water, + Blocks.darksandTaintedWater, Blocks.darksandWater ); ObjectMap tars = ObjectMap.of( diff --git a/core/src/mindustry/type/Sector.java b/core/src/mindustry/type/Sector.java index 33a64256c6..ca5b4dd183 100644 --- a/core/src/mindustry/type/Sector.java +++ b/core/src/mindustry/type/Sector.java @@ -43,6 +43,13 @@ public class Sector{ this.data = data; } + /** @return whether this sector can be landed on at all. + * Only sectors adjacent to non-wave sectors can be landed on. + * TODO also preset sectors*/ + public boolean unlocked(){ + return Structs.contains(tile.tiles, p -> planet.getSector(p).isCaptured()) || (preset != null && preset.unlocked()); + } + /** @return whether the player has a base here. */ public boolean hasBase(){ return save != null && !save.meta.tags.getBool("nocores"); @@ -58,6 +65,10 @@ public class Sector{ return Vars.state.isGame() && Vars.state.rules.sector == this && !Vars.state.launched && !Vars.state.gameOver; } + public boolean isCaptured(){ + return save != null && !save.meta.rules.waves; + } + /** @return whether waves are present - if true, any bases here will be attacked. */ public boolean hasWaves(){ return save != null && save.meta.rules.waves; @@ -73,7 +84,7 @@ public class Sector{ } public boolean locked(){ - return !unlocked; + return !unlocked(); } /** @return light dot product in the range [0, 1]. */ diff --git a/core/src/mindustry/type/SectorPreset.java b/core/src/mindustry/type/SectorPreset.java index aa118e5009..7ac342e121 100644 --- a/core/src/mindustry/type/SectorPreset.java +++ b/core/src/mindustry/type/SectorPreset.java @@ -14,7 +14,6 @@ import mindustry.maps.generators.*; import static mindustry.Vars.*; -//TODO ? remove ? public class SectorPreset extends UnlockableContent{ public @NonNull FileMapGenerator generator; public @NonNull Planet planet; @@ -41,12 +40,6 @@ public class SectorPreset extends UnlockableContent{ planet.preset(sector, this); } - //TODO - /* - public SectorPreset(String name){ - this(name, Planets.starter); - }*/ - public Rules getRules(){ return generator.map.rules(); } diff --git a/core/src/mindustry/ui/dialogs/PlanetDialog.java b/core/src/mindustry/ui/dialogs/PlanetDialog.java index 9a3a727360..111562cac5 100644 --- a/core/src/mindustry/ui/dialogs/PlanetDialog.java +++ b/core/src/mindustry/ui/dialogs/PlanetDialog.java @@ -280,18 +280,19 @@ public class PlanetDialog extends FloatingDialog{ batch.proj().mul(planet.getTransform(mat)); for(Sector sec : planet.sectors){ - if(sec.locked()){ - draw(sec, shadowColor, -0.001f); - } if(selectAlpha > 0.01f){ - float stroke = 0.026f; - if(sec.hasBase()){ - drawSelection(sec, Tmp.c1.set(Team.sharded.color).mul(0.8f).a(selectAlpha), stroke, -0.01f); - }else if(sec.preset != null){ - drawSelection(sec, Tmp.c1.set(Team.derelict.color).mul(0.8f).a(selectAlpha), stroke, -0.02f); - }else if(sec.hasEnemyBase()){ - drawSelection(sec, Tmp.c1.set(Team.crux.color).mul(0.8f).a(selectAlpha), stroke, -0.02f); + if(sec.unlocked()){ + float stroke = 0.026f; + if(sec.hasBase()){ + drawSelection(sec, Tmp.c1.set(Team.sharded.color).mul(0.8f).a(selectAlpha), stroke, -0.005f); + }else if(sec.preset != null){ + drawSelection(sec, Tmp.c1.set(Team.derelict.color).mul(0.8f).a(selectAlpha), stroke, -0.005f); + }else if(sec.hasEnemyBase()){ + drawSelection(sec, Tmp.c1.set(Team.crux.color).mul(0.8f).a(selectAlpha), stroke, -0.005f); + } + }else{ + draw(sec, Tmp.c1.set(shadowColor).mul(1, 1, 1, selectAlpha), -0.001f); } } } @@ -309,13 +310,13 @@ public class PlanetDialog extends FloatingDialog{ batch.flush(Gl.triangles); //render arcs - for(Sector sec : planet.sectors){ - if(sec.preset != null){ - for(Objective o : sec.preset.requirements){ - if(o instanceof ZoneObjective){ - SectorPreset preset = ((ZoneObjective)o).preset; + if(selected != null && selected.preset != null){ + for(Objective o : selected.preset.requirements){ + if(o instanceof ZoneObjective){ + SectorPreset preset = ((ZoneObjective)o).preset; - drawArc(planet, sec.tile.v, preset.sector.tile.v); + if(true){ + drawArc(planet, selected.tile.v, preset.sector.tile.v); } } } @@ -341,11 +342,12 @@ public class PlanetDialog extends FloatingDialog{ points.clear(); points.addAll(Tmp.v33.set(a).setLength(outlineRad), Tmp.v31, Tmp.v34.set(b).setLength(outlineRad)); Tmp.bz3.set(points); - float points = 20; + float points = 25; for(int i = 0; i < points + 1; i++){ float f = i / points; - batch.color(Pal.accent); + Tmp.c1.set(Pal.accent).lerp(Color.clear, (f+Time.globalTime()/80f)%1f); + batch.color(Tmp.c1); batch.vertex(Tmp.bz3.valueAt(Tmp.v32, f)); } diff --git a/gradle.properties b/gradle.properties index 69581981c7..2271444fad 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=41fc7758d3853b18fdeb2e4c657a99895f44e721 +archash=1cfb465e0113f6eeb17a831d561885ca0b34fa68