diff --git a/core/assets-raw/sprites/blocks/campaign/interplanetary-accelerator-team_TODO_UNUSED.png b/core/assets-raw/sprites/blocks/campaign/interplanetary-accelerator-team_TODO_UNUSED.png deleted file mode 100644 index e141d97940..0000000000 Binary files a/core/assets-raw/sprites/blocks/campaign/interplanetary-accelerator-team_TODO_UNUSED.png and /dev/null differ diff --git a/core/assets-raw/sprites/blocks/campaign/interplanetary-accelerator.png b/core/assets-raw/sprites/blocks/campaign/interplanetary-accelerator.png index 41019a2c7d..9993af8ff7 100644 Binary files a/core/assets-raw/sprites/blocks/campaign/interplanetary-accelerator.png and b/core/assets-raw/sprites/blocks/campaign/interplanetary-accelerator.png differ diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index 79ea0b9daa..faec72cada 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -976,7 +976,8 @@ public class UnitTypes{ flying = true; health = 70; engineOffset = 5.75f; - targetAir = false; + //TODO balance + //targetAir = false; targetFlags = new BlockFlag[]{BlockFlag.generator, null}; hitSize = 7; itemCapacity = 10; diff --git a/core/src/mindustry/game/Teams.java b/core/src/mindustry/game/Teams.java index 1b3cfa61c9..50015e612b 100644 --- a/core/src/mindustry/game/Teams.java +++ b/core/src/mindustry/game/Teams.java @@ -150,6 +150,7 @@ public class Teams{ data.presentFlag = false; data.unitCount = 0; data.units.clear(); + data.players.clear(); if(data.tree != null){ data.tree.clear(); } @@ -195,6 +196,10 @@ public class Teams{ count(unit); } + for(var player : Groups.player){ + player.team().data().players.add(player); + } + //update presence of each team. for(Team team : Team.all){ TeamData data = team.data(); @@ -251,6 +256,8 @@ public class Teams{ public @Nullable QuadTree tree; /** Units of this team. Updated each frame. */ public Seq units = new Seq<>(); + /** Same as units, but players. */ + public Seq players = new Seq<>(); /** Units of this team by type. Updated each frame. */ public @Nullable Seq[] unitsByType; diff --git a/core/src/mindustry/logic/FetchType.java b/core/src/mindustry/logic/FetchType.java new file mode 100644 index 0000000000..6936fe3960 --- /dev/null +++ b/core/src/mindustry/logic/FetchType.java @@ -0,0 +1,12 @@ +package mindustry.logic; + +public enum FetchType{ + unit, + unitCount, + player, + playerCount, + core, + coreCount; + + public static final FetchType[] all = values(); +} diff --git a/core/src/mindustry/logic/LExecutor.java b/core/src/mindustry/logic/LExecutor.java index d52cfc5e65..a934971aa7 100644 --- a/core/src/mindustry/logic/LExecutor.java +++ b/core/src/mindustry/logic/LExecutor.java @@ -1164,6 +1164,37 @@ public class LExecutor{ } } + public static class FetchI implements LInstruction{ + public FetchType type = FetchType.unit; + public int result, team, index; + + public FetchI(FetchType type, int result, int team, int index){ + this.type = type; + this.result = result; + this.team = team; + this.index = index; + } + + public FetchI(){ + } + + @Override + public void run(LExecutor exec){ + int i = exec.numi(index); + if(!(exec.obj(team) instanceof Team t)) return; + TeamData data = t.data(); + + switch(type){ + case unit -> exec.setobj(result, i < 0 || i >= data.units.size ? null : data.units.get(i)); + case player -> exec.setobj(result, i < 0 || i >= data.players.size || data.players.get(i).unit().isNull() ? null : data.players.get(i).unit()); + case core -> exec.setobj(result, i < 0 || i >= data.cores.size ? null : data.cores.get(i)); + case unitCount -> exec.setnum(result, data.units.size); + case coreCount -> exec.setnum(result, data.cores.size); + case playerCount -> exec.setnum(result, data.players.size); + } + } + } + //endregion //region privileged / world instructions @@ -1225,14 +1256,16 @@ public class LExecutor{ //TODO this can be quite laggy... switch(layer){ case ore -> { - if(b instanceof OverlayFloor o) tile.setOverlayNet(o); + if(b instanceof OverlayFloor o && tile.overlay() != o) tile.setOverlayNet(o); } case floor -> { - if(b instanceof Floor f) tile.setFloorNet(f); + if(b instanceof Floor f && tile.floor() != f) tile.setFloorNet(f); } case block -> { Team t = exec.obj(team) instanceof Team steam ? steam : Team.derelict; - tile.setNet(b, t, Mathf.clamp(exec.numi(rotation), 0, 3)); + if(tile.block() != b || tile.team() != t){ + tile.setNet(b, t, Mathf.clamp(exec.numi(rotation), 0, 3)); + } } //building case not allowed } diff --git a/core/src/mindustry/logic/LStatements.java b/core/src/mindustry/logic/LStatements.java index 40809d7cdb..7fff92da7d 100644 --- a/core/src/mindustry/logic/LStatements.java +++ b/core/src/mindustry/logic/LStatements.java @@ -1460,4 +1460,58 @@ public class LStatements{ return new SetRateI(builder.var(amount)); } } + + @RegisterStatement("fetch") + public static class FetchStatement extends LStatement{ + public FetchType type = FetchType.unit; + public String result = "result", team = "@sharded", index = "0"; + + @Override + public void build(Table table){ + rebuild(table); + } + + void rebuild(Table table){ + table.clearChildren(); + + fields(table, result, r -> result = r); + + table.add(" = "); + + table.button(b -> { + b.label(() -> type.name()).growX().wrap().labelAlign(Align.center); + b.clicked(() -> showSelect(b, FetchType.all, type, o -> { + type = o; + rebuild(table); + }, 2, c -> c.width(150f))); + }, Styles.logict, () -> {}).size(160f, 40f).margin(5f).pad(4f).color(table.color); + + row(table); + + fields(table, "team", team, s -> team = s); + + if(type != FetchType.coreCount && type != FetchType.playerCount && type != FetchType.unitCount){ + table.add(" # "); + + row(table); + + fields(table, index, i -> index = i); + } + } + + @Override + public boolean privileged(){ + return true; + } + + @Override + public Color color(){ + return Pal.logicWorld; + } + + @Override + public LInstruction build(LAssembler builder){ + return new FetchI(type, builder.var(result), builder.var(team), builder.var(index)); + } + } } diff --git a/tools/build.gradle b/tools/build.gradle index f861ad27b6..244edc4133 100644 --- a/tools/build.gradle +++ b/tools/build.gradle @@ -164,7 +164,7 @@ task pack(dependsOn: [classes, configurations.runtimeClasspath]){ //antialias everything except UI elements fileTree(dir: new File(rootDir, 'core/assets-raw/sprites_out/').absolutePath, include: "**/*.png").visit{ file -> - if(file.isDirectory() || (file.toString().replace("\\", "/").contains("/ui/") && file.toString().startsWith("icon-")) || file.toString().contains(".9.png") || file.toString().contains("alphaaaa")) return + if(file.isDirectory() || (file.toString().replace("\\", "/").contains("/ui/") && file.toString().startsWith("icon-")) || file.toString().contains(".9.png") || file.toString().contains("aaaa")) return executor.submit{ antialias(file.file, doAntialias, useFastAA)