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

 Conflicts:
	core/src/mindustry/content/Blocks.java
	core/src/mindustry/net/CrashSender.java
	core/src/mindustry/ui/Links.java
	core/src/mindustry/ui/dialogs/SchematicsDialog.java
	core/src/mindustry/world/blocks/power/LightBlock.java
	gradle.properties
This commit is contained in:
Anuken
2021-07-23 17:58:02 -04:00
90 changed files with 690 additions and 389 deletions

View File

@@ -70,6 +70,8 @@ public class Rules{
public float enemyCoreBuildRadius = 400f;
/** If true, no-build zones are calculated based on the closest core. */
public boolean polygonCoreProtection = false;
/** If true, dead teams in PvP automatically have their blocks & units converted to derelict upon death. */
public boolean cleanupDeadTeams = true;
/** Radius around enemy wave drop zones.*/
public float dropZoneRadius = 300f;
/** Time between waves in ticks. */

View File

@@ -55,7 +55,7 @@ public class SectorInfo{
/** Waves this sector can survive if under attack. Based on wave in info. <0 means uncalculated. */
public int wavesSurvived = -1;
/** Time between waves. */
public float waveSpacing = 60 * 60 * 2;
public float waveSpacing = 2 * Time.toMinutes;
/** Damage dealt to sector. */
public float damage;
/** How many waves have passed while the player was away. */
@@ -117,11 +117,6 @@ public class SectorInfo{
export.get(item, ExportStat::new).counter += amount;
}
/** Subtracts from export statistics. */
public void handleItemImport(Item item, int amount){
export.get(item, ExportStat::new).counter -= amount;
}
public float getExport(Item item){
return export.get(item, ExportStat::new).mean;
}
@@ -270,6 +265,25 @@ public class SectorInfo{
return map;
}
/** @return a newly allocated map with import statistics. Use sparingly. */
//TODO this can be a float map
public ObjectMap<Item, ExportStat> importStats(){
ObjectMap<Item, ExportStat> imports = new ObjectMap<>();
//for all sectors on all planets that have bases and export to this sector
for(Planet planet : content.planets()){
for(Sector sector : planet.sectors){
Sector dest = sector.info.getRealDestination();
if(sector.hasBase() && sector.info != this && dest != null && dest.info == this){
//add their exports to our imports
sector.info.export.each((item, stat) -> {
imports.get(item, ExportStat::new).mean += stat.mean;
});
}
}
}
return imports;
}
public static class ExportStat{
public transient float counter;
public transient WindowedMean means = new WindowedMean(valueWindow);

View File

@@ -1,5 +1,6 @@
package mindustry.game;
import arc.struct.*;
import arc.util.*;
import arc.util.serialization.*;
import arc.util.serialization.Json.*;
@@ -39,12 +40,12 @@ public class SpawnGroup implements JsonSerializable{
public float shieldScaling = 0f;
/** Amount of enemies spawned initially, with no scaling */
public int unitAmount = 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. */
@Nullable
public StatusEffect effect;
public @Nullable StatusEffect effect;
/** Items this unit spawns with. Null to disable. */
@Nullable
public ItemStack items;
public @Nullable ItemStack items;
public SpawnGroup(UnitType type){
this.type = type;
@@ -85,6 +86,15 @@ public class SpawnGroup implements JsonSerializable{
unit.shield = getShield(wave);
//load up spawn payloads
if(payloads != null && unit instanceof Payloadc pay){
for(var type : payloads){
if(type == null) continue;
Unit payload = type.create(unit.team);
pay.pickup(payload);
}
}
return unit;
}
@@ -101,6 +111,9 @@ 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(payloads != null && payloads.size > 0){
json.writeValue("payloads", payloads.map(u -> u.name).toArray(String.class));
}
}
@Override
@@ -117,6 +130,9 @@ public class SpawnGroup implements JsonSerializable{
shields = data.getFloat("shields", 0);
shieldScaling = data.getFloat("shieldScaling", 0);
unitAmount = data.getInt("amount", 1);
if(data.has("payloads")){
payloads = Seq.with(json.readValue(String[].class, data.get("payloads"))).map(s -> content.getByName(ContentType.unit, s));
}
//old boss effect ID
if(data.has("effect") && data.get("effect").isNumber() && data.getInt("effect", -1) == 8){

View File

@@ -1,6 +1,7 @@
package mindustry.game;
import arc.func.*;
import arc.math.*;
import arc.math.geom.*;
import arc.struct.Queue;
import arc.struct.*;
@@ -260,6 +261,34 @@ public class Teams{
this.ai = new BaseAI(this);
}
/** Destroys this team's presence on the map, killing part of its buildings and converting everything to 'derelict'. */
public void destroyToDerelict(){
//grab all buildings from quadtree.
var builds = new Seq<Building>();
if(buildings != null){
buildings.getObjects(builds);
}
//convert all team tiles to neutral, randomly killing them
for(var b : builds){
//TODO this may cause a lot of packet spam, optimize?
Call.setTeam(b, Team.derelict);
if(Mathf.chance(0.25)){
Time.run(Mathf.random(0f, 60f * 6f), b::kill);
}
}
//kill all units randomly
units.each(u -> Time.run(Mathf.random(0f, 60f * 5f), () -> {
//ensure unit hasn't switched teams for whatever reason
if(u.team == team){
u.kill();
}
}));
}
@Nullable
public Seq<Unit> unitCache(UnitType type){
if(unitsByType == null || unitsByType.length <= type.id || unitsByType[type.id] == null) return null;
@@ -320,6 +349,7 @@ public class Teams{
public static class BlockPlan{
public final short x, y, rotation, block;
public final Object config;
public boolean removed;
public BlockPlan(int x, int y, short rotation, short block, Object config){
this.x = (short)x;