Lock state implementation

This commit is contained in:
Anuken 2020-05-18 20:17:02 -04:00
parent a9ece49c0d
commit c3ad3a9823
6 changed files with 37 additions and 29 deletions

View File

@ -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();

View File

@ -38,7 +38,9 @@ public class TODOPlanetGenerator extends PlanetGenerator{
ObjectMap<Block, Block> dec = ObjectMap.of(
Blocks.sporeMoss, Blocks.sporeCluster,
Blocks.moss, Blocks.sporeCluster
Blocks.moss, Blocks.sporeCluster,
Blocks.taintedWater, Blocks.water,
Blocks.darksandTaintedWater, Blocks.darksandWater
);
ObjectMap<Block, Block> tars = ObjectMap.of(

View File

@ -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]. */

View File

@ -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();
}

View File

@ -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));
}

View File

@ -1,3 +1,3 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=41fc7758d3853b18fdeb2e4c657a99895f44e721
archash=1cfb465e0113f6eeb17a831d561885ca0b34fa68