Wave versions
This commit is contained in:
@@ -187,7 +187,7 @@ public class Vars implements Loadable{
|
||||
public static ContentLoader content;
|
||||
public static GameState state;
|
||||
public static EntityCollisions collisions;
|
||||
public static DefaultWaves defaultWaves;
|
||||
public static Waves waves;
|
||||
public static LoopControl loops;
|
||||
public static Platform platform = new Platform(){};
|
||||
public static Mods mods;
|
||||
@@ -256,7 +256,7 @@ public class Vars implements Loadable{
|
||||
|
||||
content = new ContentLoader();
|
||||
loops = new LoopControl();
|
||||
defaultWaves = new DefaultWaves();
|
||||
waves = new Waves();
|
||||
collisions = new EntityCollisions();
|
||||
world = new World();
|
||||
universe = new Universe();
|
||||
|
||||
@@ -64,7 +64,7 @@ public class WaveInfoDialog extends BaseDialog{
|
||||
}).disabled(b -> Core.app.getClipboardText() == null || Core.app.getClipboardText().isEmpty());
|
||||
dialog.cont.row();
|
||||
dialog.cont.button("@settings.reset", () -> ui.showConfirm("@confirm", "@settings.clear.confirm", () -> {
|
||||
groups = JsonIO.copy(defaultWaves.get());
|
||||
groups = JsonIO.copy(waves.get());
|
||||
buildGroups();
|
||||
dialog.hide();
|
||||
}));
|
||||
@@ -98,7 +98,7 @@ public class WaveInfoDialog extends BaseDialog{
|
||||
if(experimental){
|
||||
buttons.button("Random", Icon.refresh, () -> {
|
||||
groups.clear();
|
||||
groups = DefaultWaves.generate(1f / 10f);
|
||||
groups = Waves.generate(1f / 10f);
|
||||
updateWaves();
|
||||
}).width(200f);
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public class WaveInfoDialog extends BaseDialog{
|
||||
}
|
||||
|
||||
void setup(){
|
||||
groups = JsonIO.copy(state.rules.spawns.isEmpty() ? defaultWaves.get() : state.rules.spawns);
|
||||
groups = JsonIO.copy(state.rules.spawns.isEmpty() ? waves.get() : state.rules.spawns);
|
||||
|
||||
cont.clear();
|
||||
cont.stack(new Table(Tex.clear, main -> {
|
||||
|
||||
@@ -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.meta.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.zip.*;
|
||||
@@ -297,7 +298,8 @@ public class Schematics implements Loadable{
|
||||
Stile core = s.tiles.find(t -> t.block instanceof CoreBlock);
|
||||
|
||||
//make sure a core exists, and that the schematic is small enough.
|
||||
if(core == null || (validate && (s.width > core.block.size + maxLoadoutSchematicPad *2 || s.height > core.block.size + maxLoadoutSchematicPad *2))) return;
|
||||
if(core == null || (validate && (s.width > core.block.size + maxLoadoutSchematicPad *2 || s.height > core.block.size + maxLoadoutSchematicPad *2
|
||||
|| s.tiles.contains(t -> t.block.buildVisibility == BuildVisibility.sandboxOnly)))) return;
|
||||
|
||||
//place in the cache
|
||||
loadouts.get((CoreBlock)core.block, Seq::new).add(s);
|
||||
|
||||
@@ -57,6 +57,8 @@ public class SectorInfo{
|
||||
public float secondsPassed;
|
||||
/** Display name. */
|
||||
public @Nullable String name;
|
||||
/** Version of generated waves. When it doesn't match, new waves are generated. */
|
||||
public int waveVersion = -1;
|
||||
|
||||
/** Special variables for simulation. */
|
||||
public float sumHealth, sumRps, sumDps, waveHealthBase, waveHealthSlope, waveDpsBase, waveDpsSlope;
|
||||
@@ -118,6 +120,11 @@ public class SectorInfo{
|
||||
state.rules.winWave = winWave;
|
||||
state.rules.attackMode = attack;
|
||||
|
||||
//assign new wave patterns when the version changes
|
||||
if(waveVersion != Waves.waveVersion && state.rules.sector.preset == null){
|
||||
state.rules.spawns = Waves.generate(state.rules.sector.baseCoverage);
|
||||
}
|
||||
|
||||
CoreBuild entity = state.rules.defaultTeam.core();
|
||||
if(entity != null){
|
||||
entity.items.clear();
|
||||
@@ -143,6 +150,7 @@ public class SectorInfo{
|
||||
spawnPosition = entity.pos();
|
||||
}
|
||||
|
||||
waveVersion = Waves.waveVersion;
|
||||
waveSpacing = state.rules.waveSpacing;
|
||||
wave = state.wave;
|
||||
winWave = state.rules.winWave;
|
||||
|
||||
@@ -9,7 +9,9 @@ import mindustry.type.*;
|
||||
|
||||
import static mindustry.content.UnitTypes.*;
|
||||
|
||||
public class DefaultWaves{
|
||||
public class Waves{
|
||||
public static final int waveVersion = 1;
|
||||
|
||||
private Seq<SpawnGroup> spawns;
|
||||
|
||||
public Seq<SpawnGroup> get(){
|
||||
@@ -337,7 +339,7 @@ public class DefaultWaves{
|
||||
step += (int)(rand.random(15, 30) * Mathf.lerp(1f, 0.5f, difficulty));
|
||||
}
|
||||
|
||||
int bossWave = (int)(rand.random(30, 60) * Mathf.lerp(1f, 0.7f, difficulty));
|
||||
int bossWave = (int)(rand.random(50, 70) * Mathf.lerp(1f, 0.6f, difficulty));
|
||||
int bossSpacing = (int)(rand.random(25, 40) * Mathf.lerp(1f, 0.6f, difficulty));
|
||||
|
||||
//main boss progression
|
||||
@@ -107,7 +107,7 @@ public abstract class SaveVersion extends SaveFileReader{
|
||||
state.wavetime = map.getFloat("wavetime", state.rules.waveSpacing);
|
||||
state.stats = JsonIO.read(GameStats.class, map.get("stats", "{}"));
|
||||
state.rules = JsonIO.read(Rules.class, map.get("rules", "{}"));
|
||||
if(state.rules.spawns.isEmpty()) state.rules.spawns = defaultWaves.get();
|
||||
if(state.rules.spawns.isEmpty()) state.rules.spawns = waves.get();
|
||||
lastReadBuild = map.getInt("build", -1);
|
||||
|
||||
if(!headless){
|
||||
|
||||
@@ -101,7 +101,7 @@ public class Map implements Comparable<Map>, Publishable{
|
||||
//this replacement is a MASSIVE hack but it fixes some incorrect overwriting of team-specific rules.
|
||||
//may need to be tweaked later
|
||||
Rules result = JsonIO.read(Rules.class, base, tags.get("rules", "{}").replace("teams:{2:{infiniteAmmo:true}},", ""));
|
||||
if(result.spawns.isEmpty()) result.spawns = Vars.defaultWaves.get();
|
||||
if(result.spawns.isEmpty()) result.spawns = Vars.waves.get();
|
||||
return result;
|
||||
}catch(Exception e){
|
||||
//error reading rules. ignore?
|
||||
|
||||
@@ -420,7 +420,7 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
|
||||
state.rules.waves = sector.info.waves = true;
|
||||
|
||||
//TODO better waves
|
||||
state.rules.spawns = DefaultWaves.generate(difficulty);
|
||||
state.rules.spawns = Waves.generate(difficulty);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -295,7 +295,7 @@ public class ContentParser{
|
||||
group.type = unit;
|
||||
}
|
||||
|
||||
Vars.defaultWaves.get().addAll(groups);
|
||||
Vars.waves.get().addAll(groups);
|
||||
}
|
||||
|
||||
readFields(unit, value, true);
|
||||
|
||||
Reference in New Issue
Block a user