Sector wave spawning fixes
This commit is contained in:
@@ -21,6 +21,7 @@ import static mindustry.Vars.*;
|
||||
public class WaveSpawner{
|
||||
private static final float margin = 40f, coreMargin = tilesize * 2f, maxSteps = 30;
|
||||
|
||||
private int tmpCount;
|
||||
private Seq<Tile> spawns = new Seq<>();
|
||||
private boolean spawning = 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(){
|
||||
return spawning && !net.client();
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import mindustry.world.blocks.power.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.blocks.sandbox.*;
|
||||
import mindustry.world.blocks.storage.*;
|
||||
import mindustry.world.blocks.storage.CoreBlock.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import java.io.*;
|
||||
@@ -450,6 +451,10 @@ public class Schematics implements Loadable{
|
||||
if(st.block instanceof Drill){
|
||||
tile.getLinkedTiles(t -> t.setOverlay(resource));
|
||||
}
|
||||
|
||||
if(tile.build instanceof CoreBuild cb){
|
||||
state.teams.registerCore(cb);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -261,6 +261,10 @@ public class Waves{
|
||||
}
|
||||
|
||||
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 = {
|
||||
{dagger, mace, fortress, scepter, reign},
|
||||
{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}
|
||||
};
|
||||
|
||||
if(airOnly){
|
||||
species = Structs.filter(UnitType[].class, species, v -> v[0].flying);
|
||||
}
|
||||
|
||||
UnitType[][] fspec = species;
|
||||
|
||||
//required progression:
|
||||
//- extra periodic patterns
|
||||
|
||||
@@ -281,7 +291,7 @@ public class Waves{
|
||||
|
||||
Intc createProgression = start -> {
|
||||
//main sequence
|
||||
UnitType[] curSpecies = Structs.random(species);
|
||||
UnitType[] curSpecies = Structs.random(fspec);
|
||||
int curTier = 0;
|
||||
|
||||
for(int i = start; i < cap;){
|
||||
@@ -326,7 +336,7 @@ public class Waves{
|
||||
|
||||
//small chance to switch species
|
||||
if(rand.chance(0.3)){
|
||||
curSpecies = Structs.random(species);
|
||||
curSpecies = Structs.random(fspec);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -490,7 +490,8 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
|
||||
state.rules.waves = sector.info.waves = true;
|
||||
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
|
||||
|
||||
@@ -342,24 +342,9 @@ public class ArcNetProvider implements NetProvider{
|
||||
//for debugging total read/write speeds
|
||||
private static final boolean debug = false;
|
||||
|
||||
ThreadLocal<ByteBuffer> decompressBuffer = new ThreadLocal<>(){
|
||||
@Override
|
||||
protected ByteBuffer initialValue(){
|
||||
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()));
|
||||
}
|
||||
};
|
||||
ThreadLocal<ByteBuffer> decompressBuffer = Threads.local(() -> ByteBuffer.allocate(32768));
|
||||
ThreadLocal<Reads> reads = Threads.local(() -> new Reads(new ByteBufferInput(decompressBuffer.get())));
|
||||
ThreadLocal<Writes> writes = Threads.local(() -> new Writes(new ByteBufferOutput(decompressBuffer.get())));
|
||||
|
||||
//for debugging network write counts
|
||||
static WindowedMean upload = new WindowedMean(5), download = new WindowedMean(5);
|
||||
|
||||
@@ -274,6 +274,7 @@ public class Net{
|
||||
builder.add(c.data);
|
||||
|
||||
ui.loadfrag.setProgress(builder.progress());
|
||||
ui.loadfrag.snapProgress();
|
||||
netClient.resetTimeout();
|
||||
|
||||
if(builder.isDone()){
|
||||
|
||||
@@ -62,6 +62,10 @@ public class Bar extends Element{
|
||||
update(() -> this.name = name.get());
|
||||
}
|
||||
|
||||
public void snap(){
|
||||
lastValue = value = fraction.get();
|
||||
}
|
||||
|
||||
public Bar outline(Color color, float stroke){
|
||||
outlineColor.set(color);
|
||||
outlineRadius = Scl.scl(stroke);
|
||||
|
||||
@@ -56,11 +56,16 @@ public class LoadingFragment extends Fragment{
|
||||
bar.set(() -> ((int)(progress.get() * 100) + "%"), progress, Pal.accent);
|
||||
}
|
||||
|
||||
public void snapProgress(){
|
||||
bar.snap();
|
||||
}
|
||||
|
||||
public void setProgress(float progress){
|
||||
progValue = progress;
|
||||
if(!bar.visible){
|
||||
setProgress(() -> progValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setButton(Runnable listener){
|
||||
|
||||
Reference in New Issue
Block a user