Merge remote-tracking branch 'origin/master'

This commit is contained in:
Anuken
2022-09-09 14:28:45 -04:00
45 changed files with 70 additions and 14 deletions

View File

@@ -5,6 +5,7 @@ import arc.util.*;
import mindustry.annotations.Annotations.*;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.type.*;
import static mindustry.Vars.*;
@@ -12,11 +13,14 @@ import static mindustry.Vars.*;
abstract class BoundedComp implements Velc, Posc, Healthc, Flyingc{
static final float warpDst = 30f;
@Import UnitType type;
@Import float x, y;
@Import Team team;
@Override
public void update(){
if(!type.bounded) return;
float bot = 0f, left = 0f, top = world.unitHeight(), right = world.unitWidth();
//TODO hidden map rules only apply to player teams? should they?

View File

@@ -380,7 +380,7 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
@Override
public String text(){
return Core.bundle.format("objective.build", count, block.emoji(), block.localizedName);
return Core.bundle.format("objective.build", count - state.stats.placedBlockCount.get(block, 0), block.emoji(), block.localizedName);
}
}
@@ -403,7 +403,7 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
@Override
public String text(){
return Core.bundle.format("objective.buildunit", count, unit.emoji(), unit.localizedName);
return Core.bundle.format("objective.buildunit", count - state.rules.defaultTeam.data().countType(unit), unit.emoji(), unit.localizedName);
}
}
@@ -424,7 +424,7 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
@Override
public String text(){
return Core.bundle.format("objective.destroyunits", count);
return Core.bundle.format("objective.destroyunits", count - state.stats.enemyUnitsDestroyed);
}
}

View File

@@ -25,6 +25,8 @@ public class Rules{
public TeamRules teams = new TeamRules();
/** Whether the waves come automatically on a timer. If not, waves come when the play button is pressed. */
public boolean waveTimer = true;
/** Whether the waves can be manually summoned with the play button. */
public boolean waveSending = true;
/** Whether waves are spawnable at all. */
public boolean waves;
/** Whether the game objective is PvP. Note that this enables automatic hosting. */

View File

@@ -1409,6 +1409,7 @@ public class LExecutor{
case wave -> state.wave = exec.numi(value);
case currentWaveTime -> state.wavetime = exec.numf(value) * 60f;
case waves -> state.rules.waves = exec.bool(value);
case waveSending -> state.rules.waveSending = exec.bool(value);
case attackMode -> state.rules.attackMode = exec.bool(value);
case waveSpacing -> state.rules.waveSpacing = exec.numf(value) * 60f;
case enemyCoreBuildRadius -> state.rules.enemyCoreBuildRadius = exec.numf(value) * 8f;
@@ -1641,12 +1642,14 @@ public class LExecutor{
}
public static class SpawnWaveI implements LInstruction{
public int natural;
public int x, y;
public SpawnWaveI(){
}
public SpawnWaveI(int x, int y){
public SpawnWaveI(int natural, int x, int y){
this.natural = natural;
this.x = x;
this.y = y;
}
@@ -1655,9 +1658,14 @@ public class LExecutor{
public void run(LExecutor exec){
if(net.client()) return;
if(exec.bool(natural)){
logic.skipWave();
return;
}
float
spawnX = World.unconv(exec.numf(x)),
spawnY = World.unconv(exec.numf(y));
spawnX = World.unconv(exec.numf(x)),
spawnY = World.unconv(exec.numf(y));
int packed = Point2.pack(exec.numi(x), exec.numi(y));
for(SpawnGroup group : state.rules.spawns){

View File

@@ -1309,16 +1309,18 @@ public class LStatements{
@RegisterStatement("spawnwave")
public static class SpawnWaveStatement extends LStatement{
public String x = "10", y = "10";
public String x = "10", y = "10", natural = "false";
@Override
public void build(Table table){
table.add("natural ");
fields(table, natural, str -> natural = str);
table.add("x ");
fields(table, x, str -> x = str);
table.add("x ").visible(() -> natural.equals("false"));
fields(table, x, str -> x = str).visible(() -> natural.equals("false"));
table.add(" y ");
fields(table, y, str -> y = str);
table.add(" y ").visible(() -> natural.equals("false"));
fields(table, y, str -> y = str).visible(() -> natural.equals("false"));
}
@Override
@@ -1328,7 +1330,7 @@ public class LStatements{
@Override
public LInstruction build(LAssembler builder){
return new SpawnWaveI(builder.var(x), builder.var(y));
return new SpawnWaveI(builder.var(natural), builder.var(x), builder.var(y));
}
@Override

View File

@@ -6,6 +6,7 @@ public enum LogicRule{
waves,
wave,
waveSpacing,
waveSending,
attackMode,
enemyCoreBuildRadius,
dropZoneRadius,

View File

@@ -208,6 +208,8 @@ public class UnitType extends UnlockableContent{
hidden = false,
/** if true, this unit is for internal use only and does not have a sprite generated. */
internal = false,
/** If false, this unit is not pushed away from map edges. */
bounded = true,
/** if true, this unit is detected as naval - do NOT assign this manually! Initialized in init() */
naval = false,

View File

@@ -25,6 +25,7 @@ public class MissileUnitType extends UnitType{
envEnabled = Env.any;
envDisabled = Env.none;
physics = false;
bounded = false;
trailLength = 7;
hidden = true;
speed = 4f;

View File

@@ -139,6 +139,7 @@ public class CustomRulesDialog extends BaseDialog{
title("@rules.title.waves");
check("@rules.waves", b -> rules.waves = b, () -> rules.waves);
check("@rules.wavetimer", b -> rules.waveTimer = b, () -> rules.waveTimer);
check("@rules.wavesending", b -> rules.waveSending = b, () -> rules.waveSending);
check("@rules.waitForWaveToEnd", b -> rules.waitEnemies = b, () -> rules.waitEnemies);
number("@rules.wavespacing", false, f -> rules.waveSpacing = f * 60f, () -> rules.waveSpacing / 60f, () -> rules.waveTimer, 1, Float.MAX_VALUE);
//this is experimental, because it's not clear that 0 makes it default.

View File

@@ -908,7 +908,7 @@ public class HudFragment{
}
private boolean canSkipWave(){
return state.rules.waves && ((net.server() || player.admin) || !net.active()) && state.enemies == 0 && !spawner.isSpawning();
return state.rules.waves && state.rules.waveSending && ((net.server() || player.admin) || !net.active()) && state.enemies == 0 && !spawner.isSpawning();
}
}