diff --git a/core/src/mindustry/ai/WaveSpawner.java b/core/src/mindustry/ai/WaveSpawner.java index a895af863f..40be2defad 100644 --- a/core/src/mindustry/ai/WaveSpawner.java +++ b/core/src/mindustry/ai/WaveSpawner.java @@ -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 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(); } diff --git a/core/src/mindustry/game/Schematics.java b/core/src/mindustry/game/Schematics.java index 0a91c9d1b3..011d289f05 100644 --- a/core/src/mindustry/game/Schematics.java +++ b/core/src/mindustry/game/Schematics.java @@ -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); + } }); } diff --git a/core/src/mindustry/game/Waves.java b/core/src/mindustry/game/Waves.java index bdd95abedf..415ccea8fc 100644 --- a/core/src/mindustry/game/Waves.java +++ b/core/src/mindustry/game/Waves.java @@ -261,6 +261,10 @@ public class Waves{ } public static Seq generate(float difficulty, Rand rand, boolean attack){ + return generate(difficulty, rand, attack, false); + } + + public static Seq 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); } } }; diff --git a/core/src/mindustry/maps/planet/SerpuloPlanetGenerator.java b/core/src/mindustry/maps/planet/SerpuloPlanetGenerator.java index 0effbc80f2..112838d405 100644 --- a/core/src/mindustry/maps/planet/SerpuloPlanetGenerator.java +++ b/core/src/mindustry/maps/planet/SerpuloPlanetGenerator.java @@ -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 diff --git a/core/src/mindustry/net/ArcNetProvider.java b/core/src/mindustry/net/ArcNetProvider.java index ba8ff4cfa0..4cc05ecccb 100644 --- a/core/src/mindustry/net/ArcNetProvider.java +++ b/core/src/mindustry/net/ArcNetProvider.java @@ -342,24 +342,9 @@ public class ArcNetProvider implements NetProvider{ //for debugging total read/write speeds private static final boolean debug = false; - ThreadLocal decompressBuffer = new ThreadLocal<>(){ - @Override - protected ByteBuffer initialValue(){ - return ByteBuffer.allocate(32768); - } - }; - ThreadLocal reads = new ThreadLocal<>(){ - @Override - protected Reads initialValue(){ - return new Reads(new ByteBufferInput(decompressBuffer.get())); - } - }; - ThreadLocal writes = new ThreadLocal<>(){ - @Override - protected Writes initialValue(){ - return new Writes(new ByteBufferOutput(decompressBuffer.get())); - } - }; + ThreadLocal decompressBuffer = Threads.local(() -> ByteBuffer.allocate(32768)); + ThreadLocal reads = Threads.local(() -> new Reads(new ByteBufferInput(decompressBuffer.get()))); + ThreadLocal writes = Threads.local(() -> new Writes(new ByteBufferOutput(decompressBuffer.get()))); //for debugging network write counts static WindowedMean upload = new WindowedMean(5), download = new WindowedMean(5); diff --git a/core/src/mindustry/net/Net.java b/core/src/mindustry/net/Net.java index 9081b194f4..2463c8fed9 100644 --- a/core/src/mindustry/net/Net.java +++ b/core/src/mindustry/net/Net.java @@ -274,6 +274,7 @@ public class Net{ builder.add(c.data); ui.loadfrag.setProgress(builder.progress()); + ui.loadfrag.snapProgress(); netClient.resetTimeout(); if(builder.isDone()){ diff --git a/core/src/mindustry/ui/Bar.java b/core/src/mindustry/ui/Bar.java index d8e2b4b6da..eb4fcf9a54 100644 --- a/core/src/mindustry/ui/Bar.java +++ b/core/src/mindustry/ui/Bar.java @@ -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); diff --git a/core/src/mindustry/ui/fragments/LoadingFragment.java b/core/src/mindustry/ui/fragments/LoadingFragment.java index fcd18dfcbe..4f977fa644 100644 --- a/core/src/mindustry/ui/fragments/LoadingFragment.java +++ b/core/src/mindustry/ui/fragments/LoadingFragment.java @@ -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){ diff --git a/gradle.properties b/gradle.properties index 52e61753e2..5eb904834f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,4 +11,4 @@ android.useAndroidX=true #used for slow jitpack builds; TODO see if this actually works http.socketTimeout=80000 http.connectionTimeout=80000 -archash=4582339cd9052be86141fbacf2f2180b09eb585c +archash=0d9a003fc8f70b58f739bfacc3817b4c2522a8af