Sector wave spawning fixes

This commit is contained in:
Anuken
2021-08-16 11:42:59 -04:00
parent ff5c48a2a0
commit 0c5f781702
9 changed files with 46 additions and 22 deletions

View File

@@ -21,6 +21,7 @@ import static mindustry.Vars.*;
public class WaveSpawner{ public class WaveSpawner{
private static final float margin = 40f, coreMargin = tilesize * 2f, maxSteps = 30; private static final float margin = 40f, coreMargin = tilesize * 2f, maxSteps = 30;
private int tmpCount;
private Seq<Tile> spawns = new Seq<>(); private Seq<Tile> spawns = new Seq<>();
private boolean spawning = false; private boolean spawning = false;
private boolean any = false; private boolean any = false;
@@ -162,6 +163,18 @@ public class WaveSpawner{
} }
} }
public int countGroundSpawns(){
tmpCount = 0;
eachGroundSpawn((x, y) -> tmpCount ++);
return tmpCount;
}
public int countFlyerSpawns(){
tmpCount = 0;
eachFlyerSpawn((x, y) -> tmpCount ++);
return tmpCount;
}
public boolean isSpawning(){ public boolean isSpawning(){
return spawning && !net.client(); return spawning && !net.client();
} }

View File

@@ -33,6 +33,7 @@ import mindustry.world.blocks.power.*;
import mindustry.world.blocks.production.*; import mindustry.world.blocks.production.*;
import mindustry.world.blocks.sandbox.*; import mindustry.world.blocks.sandbox.*;
import mindustry.world.blocks.storage.*; import mindustry.world.blocks.storage.*;
import mindustry.world.blocks.storage.CoreBlock.*;
import mindustry.world.meta.*; import mindustry.world.meta.*;
import java.io.*; import java.io.*;
@@ -450,6 +451,10 @@ public class Schematics implements Loadable{
if(st.block instanceof Drill){ if(st.block instanceof Drill){
tile.getLinkedTiles(t -> t.setOverlay(resource)); tile.getLinkedTiles(t -> t.setOverlay(resource));
} }
if(tile.build instanceof CoreBuild cb){
state.teams.registerCore(cb);
}
}); });
} }

View File

@@ -261,6 +261,10 @@ public class Waves{
} }
public static Seq<SpawnGroup> generate(float difficulty, Rand rand, boolean attack){ public static Seq<SpawnGroup> generate(float difficulty, Rand rand, boolean attack){
return generate(difficulty, rand, attack, false);
}
public static Seq<SpawnGroup> generate(float difficulty, Rand rand, boolean attack, boolean airOnly){
UnitType[][] species = { UnitType[][] species = {
{dagger, mace, fortress, scepter, reign}, {dagger, mace, fortress, scepter, reign},
{nova, pulsar, quasar, vela, corvus}, {nova, pulsar, quasar, vela, corvus},
@@ -268,6 +272,12 @@ public class Waves{
{flare, horizon, zenith, rand.chance(0.5) ? quad : antumbra, rand.chance(0.1) ? quad : eclipse} {flare, horizon, zenith, rand.chance(0.5) ? quad : antumbra, rand.chance(0.1) ? quad : eclipse}
}; };
if(airOnly){
species = Structs.filter(UnitType[].class, species, v -> v[0].flying);
}
UnitType[][] fspec = species;
//required progression: //required progression:
//- extra periodic patterns //- extra periodic patterns
@@ -281,7 +291,7 @@ public class Waves{
Intc createProgression = start -> { Intc createProgression = start -> {
//main sequence //main sequence
UnitType[] curSpecies = Structs.random(species); UnitType[] curSpecies = Structs.random(fspec);
int curTier = 0; int curTier = 0;
for(int i = start; i < cap;){ for(int i = start; i < cap;){
@@ -326,7 +336,7 @@ public class Waves{
//small chance to switch species //small chance to switch species
if(rand.chance(0.3)){ if(rand.chance(0.3)){
curSpecies = Structs.random(species); curSpecies = Structs.random(fspec);
} }
} }
}; };

View File

@@ -490,7 +490,8 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
state.rules.waves = sector.info.waves = true; state.rules.waves = sector.info.waves = true;
state.rules.enemyCoreBuildRadius = 600f; state.rules.enemyCoreBuildRadius = 600f;
state.rules.spawns = Waves.generate(difficulty, new Rand(), state.rules.attackMode); //spawn air only when spawn is blocked
state.rules.spawns = Waves.generate(difficulty, new Rand(sector.id), state.rules.attackMode, state.rules.attackMode && spawner.countGroundSpawns() == 0);
} }
@Override @Override

View File

@@ -342,24 +342,9 @@ public class ArcNetProvider implements NetProvider{
//for debugging total read/write speeds //for debugging total read/write speeds
private static final boolean debug = false; private static final boolean debug = false;
ThreadLocal<ByteBuffer> decompressBuffer = new ThreadLocal<>(){ ThreadLocal<ByteBuffer> decompressBuffer = Threads.local(() -> ByteBuffer.allocate(32768));
@Override ThreadLocal<Reads> reads = Threads.local(() -> new Reads(new ByteBufferInput(decompressBuffer.get())));
protected ByteBuffer initialValue(){ ThreadLocal<Writes> writes = Threads.local(() -> new Writes(new ByteBufferOutput(decompressBuffer.get())));
return ByteBuffer.allocate(32768);
}
};
ThreadLocal<Reads> reads = new ThreadLocal<>(){
@Override
protected Reads initialValue(){
return new Reads(new ByteBufferInput(decompressBuffer.get()));
}
};
ThreadLocal<Writes> writes = new ThreadLocal<>(){
@Override
protected Writes initialValue(){
return new Writes(new ByteBufferOutput(decompressBuffer.get()));
}
};
//for debugging network write counts //for debugging network write counts
static WindowedMean upload = new WindowedMean(5), download = new WindowedMean(5); static WindowedMean upload = new WindowedMean(5), download = new WindowedMean(5);

View File

@@ -274,6 +274,7 @@ public class Net{
builder.add(c.data); builder.add(c.data);
ui.loadfrag.setProgress(builder.progress()); ui.loadfrag.setProgress(builder.progress());
ui.loadfrag.snapProgress();
netClient.resetTimeout(); netClient.resetTimeout();
if(builder.isDone()){ if(builder.isDone()){

View File

@@ -62,6 +62,10 @@ public class Bar extends Element{
update(() -> this.name = name.get()); update(() -> this.name = name.get());
} }
public void snap(){
lastValue = value = fraction.get();
}
public Bar outline(Color color, float stroke){ public Bar outline(Color color, float stroke){
outlineColor.set(color); outlineColor.set(color);
outlineRadius = Scl.scl(stroke); outlineRadius = Scl.scl(stroke);

View File

@@ -56,11 +56,16 @@ public class LoadingFragment extends Fragment{
bar.set(() -> ((int)(progress.get() * 100) + "%"), progress, Pal.accent); bar.set(() -> ((int)(progress.get() * 100) + "%"), progress, Pal.accent);
} }
public void snapProgress(){
bar.snap();
}
public void setProgress(float progress){ public void setProgress(float progress){
progValue = progress; progValue = progress;
if(!bar.visible){ if(!bar.visible){
setProgress(() -> progValue); setProgress(() -> progValue);
} }
} }
public void setButton(Runnable listener){ public void setButton(Runnable listener){

View File

@@ -11,4 +11,4 @@ android.useAndroidX=true
#used for slow jitpack builds; TODO see if this actually works #used for slow jitpack builds; TODO see if this actually works
http.socketTimeout=80000 http.socketTimeout=80000
http.connectionTimeout=80000 http.connectionTimeout=80000
archash=4582339cd9052be86141fbacf2f2180b09eb585c archash=0d9a003fc8f70b58f739bfacc3817b4c2522a8af