Fetch instruction
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 3.7 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 5.3 KiB |
@@ -976,7 +976,8 @@ public class UnitTypes{
|
|||||||
flying = true;
|
flying = true;
|
||||||
health = 70;
|
health = 70;
|
||||||
engineOffset = 5.75f;
|
engineOffset = 5.75f;
|
||||||
targetAir = false;
|
//TODO balance
|
||||||
|
//targetAir = false;
|
||||||
targetFlags = new BlockFlag[]{BlockFlag.generator, null};
|
targetFlags = new BlockFlag[]{BlockFlag.generator, null};
|
||||||
hitSize = 7;
|
hitSize = 7;
|
||||||
itemCapacity = 10;
|
itemCapacity = 10;
|
||||||
|
|||||||
@@ -150,6 +150,7 @@ public class Teams{
|
|||||||
data.presentFlag = false;
|
data.presentFlag = false;
|
||||||
data.unitCount = 0;
|
data.unitCount = 0;
|
||||||
data.units.clear();
|
data.units.clear();
|
||||||
|
data.players.clear();
|
||||||
if(data.tree != null){
|
if(data.tree != null){
|
||||||
data.tree.clear();
|
data.tree.clear();
|
||||||
}
|
}
|
||||||
@@ -195,6 +196,10 @@ public class Teams{
|
|||||||
count(unit);
|
count(unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(var player : Groups.player){
|
||||||
|
player.team().data().players.add(player);
|
||||||
|
}
|
||||||
|
|
||||||
//update presence of each team.
|
//update presence of each team.
|
||||||
for(Team team : Team.all){
|
for(Team team : Team.all){
|
||||||
TeamData data = team.data();
|
TeamData data = team.data();
|
||||||
@@ -251,6 +256,8 @@ public class Teams{
|
|||||||
public @Nullable QuadTree<Unit> tree;
|
public @Nullable QuadTree<Unit> tree;
|
||||||
/** Units of this team. Updated each frame. */
|
/** Units of this team. Updated each frame. */
|
||||||
public Seq<Unit> units = new Seq<>();
|
public Seq<Unit> units = new Seq<>();
|
||||||
|
/** Same as units, but players. */
|
||||||
|
public Seq<Player> players = new Seq<>();
|
||||||
/** Units of this team by type. Updated each frame. */
|
/** Units of this team by type. Updated each frame. */
|
||||||
public @Nullable Seq<Unit>[] unitsByType;
|
public @Nullable Seq<Unit>[] unitsByType;
|
||||||
|
|
||||||
|
|||||||
12
core/src/mindustry/logic/FetchType.java
Normal file
12
core/src/mindustry/logic/FetchType.java
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package mindustry.logic;
|
||||||
|
|
||||||
|
public enum FetchType{
|
||||||
|
unit,
|
||||||
|
unitCount,
|
||||||
|
player,
|
||||||
|
playerCount,
|
||||||
|
core,
|
||||||
|
coreCount;
|
||||||
|
|
||||||
|
public static final FetchType[] all = values();
|
||||||
|
}
|
||||||
@@ -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
|
//endregion
|
||||||
//region privileged / world instructions
|
//region privileged / world instructions
|
||||||
|
|
||||||
@@ -1225,14 +1256,16 @@ public class LExecutor{
|
|||||||
//TODO this can be quite laggy...
|
//TODO this can be quite laggy...
|
||||||
switch(layer){
|
switch(layer){
|
||||||
case ore -> {
|
case ore -> {
|
||||||
if(b instanceof OverlayFloor o) tile.setOverlayNet(o);
|
if(b instanceof OverlayFloor o && tile.overlay() != o) tile.setOverlayNet(o);
|
||||||
}
|
}
|
||||||
case floor -> {
|
case floor -> {
|
||||||
if(b instanceof Floor f) tile.setFloorNet(f);
|
if(b instanceof Floor f && tile.floor() != f) tile.setFloorNet(f);
|
||||||
}
|
}
|
||||||
case block -> {
|
case block -> {
|
||||||
Team t = exec.obj(team) instanceof Team steam ? steam : Team.derelict;
|
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
|
//building case not allowed
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1460,4 +1460,58 @@ public class LStatements{
|
|||||||
return new SetRateI(builder.var(amount));
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ task pack(dependsOn: [classes, configurations.runtimeClasspath]){
|
|||||||
|
|
||||||
//antialias everything except UI elements
|
//antialias everything except UI elements
|
||||||
fileTree(dir: new File(rootDir, 'core/assets-raw/sprites_out/').absolutePath, include: "**/*.png").visit{ file ->
|
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{
|
executor.submit{
|
||||||
antialias(file.file, doAntialias, useFastAA)
|
antialias(file.file, doAntialias, useFastAA)
|
||||||
|
|||||||
Reference in New Issue
Block a user