Merge branch 'master' of https://github.com/Anuken/Mindustry into 7.0-features

This commit is contained in:
Anuken
2021-09-13 20:52:41 -04:00
82 changed files with 1517 additions and 1114 deletions

View File

@@ -291,16 +291,22 @@ public class Schematics implements Loadable{
/** Checks a schematic for deployment validity and adds it to the cache. */
private void checkLoadout(Schematic s, boolean validate){
Stile core = s.tiles.find(t -> t.block instanceof CoreBlock);
if(core == null) return;
int cores = s.tiles.count(t -> t.block instanceof CoreBlock);
int maxSize = getMaxLaunchSize(core.block);
//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
if((validate && (s.width > maxSize || s.height > maxSize
|| s.tiles.contains(t -> t.block.buildVisibility == BuildVisibility.sandboxOnly || !t.block.unlocked()) || cores > 1))) return;
//place in the cache
loadouts.get((CoreBlock)core.block, Seq::new).add(s);
}
public int getMaxLaunchSize(Block block){
return block.size + maxLoadoutSchematicPad*2;
}
/** Adds a schematic to the list, also copying it into the files.*/
public void add(Schematic schematic){
all.add(schematic);

View File

@@ -19,7 +19,7 @@ import static mindustry.Vars.*;
* weapon equipped, ammo used, and status effects.
* Each spawn group can have multiple sub-groups spawned in different areas of the map.
*/
public class SpawnGroup implements JsonSerializable{
public class SpawnGroup implements JsonSerializable, Cloneable{
public static final int never = Integer.MAX_VALUE;
/** The unit type spawned */
@@ -36,10 +36,12 @@ public class SpawnGroup implements JsonSerializable{
public float unitScaling = never;
/** Shield points that this unit has. */
public float shields = 0f;
/** How much shields get increased per wave. */
/** How much shields get increased by per wave. */
public float shieldScaling = 0f;
/** Amount of enemies spawned initially, with no scaling */
public int unitAmount = 1;
/** If not -1, the unit will only spawn in spawnpoints with these packed coordinates. */
public int spawn = -1;
/** Seq of payloads that this unit will spawn with. */
public @Nullable Seq<UnitType> payloads;
/** Status effect applied to the spawned unit. Null to disable. */
@@ -55,6 +57,10 @@ public class SpawnGroup implements JsonSerializable{
//serialization use only
}
public boolean canSpawn(int position){
return spawn == -1 || spawn == position;
}
/** @return amount of units spawned on a specific wave. */
public int getSpawned(int wave){
if(spacing == 0) spacing = 1;
@@ -111,6 +117,7 @@ public class SpawnGroup implements JsonSerializable{
if(shieldScaling != 0) json.writeValue("shieldScaling", shieldScaling);
if(unitAmount != 1) json.writeValue("amount", unitAmount);
if(effect != null) json.writeValue("effect", effect.name);
if(spawn != -1) json.writeValue("spawn", spawn);
if(payloads != null && payloads.size > 0){
json.writeValue("payloads", payloads.map(u -> u.name).toArray(String.class));
}
@@ -130,6 +137,7 @@ public class SpawnGroup implements JsonSerializable{
shields = data.getFloat("shields", 0);
shieldScaling = data.getFloat("shieldScaling", 0);
unitAmount = data.getInt("amount", 1);
spawn = data.getInt("spawn", -1);
if(data.has("payloads")){
payloads = Seq.with(json.readValue(String[].class, data.get("payloads"))).map(s -> content.getByName(ContentType.unit, s));
}
@@ -157,6 +165,14 @@ public class SpawnGroup implements JsonSerializable{
'}';
}
public SpawnGroup copy(){
try{
return (SpawnGroup)clone();
}catch(CloneNotSupportedException how){
throw new RuntimeException("If you see this, what did you even do?", how);
}
}
@Override
public boolean equals(Object o){
if(this == o) return true;

View File

@@ -350,8 +350,8 @@ public class Waves{
step += (int)(rand.random(15, 30) * Mathf.lerp(1f, 0.5f, difficulty));
}
int bossWave = (int)(rand.random(50, 70) * Mathf.lerp(1f, 0.7f, difficulty));
int bossSpacing = (int)(rand.random(25, 40) * Mathf.lerp(1f, 0.6f, difficulty));
int bossWave = (int)(rand.random(50, 70) * Mathf.lerp(1f, 0.5f, difficulty));
int bossSpacing = (int)(rand.random(25, 40) * Mathf.lerp(1f, 0.5f, difficulty));
int bossTier = difficulty < 0.6 ? 3 : 4;