mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-23 06:07:47 +07:00
Logic tweaks
This commit is contained in:
@ -57,8 +57,9 @@ public class EntityGroup<T extends Entityc> implements Iterable<T>{
|
||||
each(Entityc::update);
|
||||
}
|
||||
|
||||
public void copy(Seq<T> arr){
|
||||
public Seq<T> copy(Seq<T> arr){
|
||||
arr.addAll(array);
|
||||
return arr;
|
||||
}
|
||||
|
||||
public void each(Cons<T> cons){
|
||||
|
@ -1246,6 +1246,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
public Object senseObject(LAccess sensor){
|
||||
return switch(sensor){
|
||||
case type -> block;
|
||||
case firstItem -> items == null ? null : items.first();
|
||||
case name -> block.name;
|
||||
default -> noSensed;
|
||||
};
|
||||
|
||||
|
@ -99,7 +99,8 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||
public Object senseObject(LAccess sensor){
|
||||
return switch(sensor){
|
||||
case type -> type;
|
||||
case name -> controller instanceof Player p ? p.name : null;
|
||||
case name -> controller instanceof Player p ? p.name : type.name;
|
||||
case firstItem -> stack().amount == 0 ? null : item();
|
||||
default -> noSensed;
|
||||
};
|
||||
|
||||
|
@ -81,7 +81,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
public static void takeItems(Building build, Item item, int amount, Unit to){
|
||||
if(to == null || build == null) return;
|
||||
|
||||
int removed = build.removeStack(item, Math.min(player.unit().maxAccepted(item), amount));
|
||||
int removed = build.removeStack(item, Math.min(to.maxAccepted(item), amount));
|
||||
if(removed == 0) return;
|
||||
|
||||
to.addItem(item, removed);
|
||||
|
@ -5,6 +5,7 @@ import arc.struct.*;
|
||||
/** Setter/getter enum for logic-controlled objects. */
|
||||
public enum LAccess{
|
||||
totalItems,
|
||||
firstItem,
|
||||
totalLiquids,
|
||||
totalPower,
|
||||
itemCapacity,
|
||||
|
@ -194,6 +194,21 @@ public class LExecutor{
|
||||
}
|
||||
}
|
||||
|
||||
/** Binds the processor to a unit based on some filters. */
|
||||
public static class UnitLocateI implements LInstruction{
|
||||
|
||||
@Override
|
||||
public void run(LExecutor exec){
|
||||
Object unitObj = exec.obj(varUnit);
|
||||
LogicAI ai = UnitControlI.checkLogicAI(exec, unitObj);
|
||||
|
||||
if(unitObj instanceof Unit unit && ai != null){
|
||||
ai.controlTimer = LogicAI.logicControlTimeout;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Controls the unit based on some parameters. */
|
||||
public static class UnitControlI implements LInstruction{
|
||||
public LUnitControl type = LUnitControl.move;
|
||||
|
@ -709,7 +709,28 @@ public class LStatements{
|
||||
public void build(Table table){
|
||||
table.add(" type ");
|
||||
|
||||
field(table, type, str -> type = str);
|
||||
TextField field = field(table, type, str -> type = str).get();
|
||||
|
||||
table.button(b -> {
|
||||
b.image(Icon.pencilSmall);
|
||||
b.clicked(() -> showSelectTable(b, (t, hide) -> {
|
||||
t.row();
|
||||
t.table(i -> {
|
||||
i.left();
|
||||
int c = 0;
|
||||
for(UnitType item : Vars.content.units()){
|
||||
if(!item.unlockedNow() || item.isHidden()) continue;
|
||||
i.button(new TextureRegionDrawable(item.icon(Cicon.small)), Styles.cleari, () -> {
|
||||
type = "@" + item.name;
|
||||
field.setText(type);
|
||||
hide.run();
|
||||
}).size(40f);
|
||||
|
||||
if(++c % 6 == 0) i.row();
|
||||
}
|
||||
}).colspan(3).width(240f).left();
|
||||
}));
|
||||
}, Styles.logict, () -> {}).size(40f).padLeft(-2).color(table.color);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -100,10 +100,9 @@ public class MendProjector extends Block{
|
||||
Draw.color(baseColor, phaseColor, phaseHeat);
|
||||
Draw.alpha(heat * Mathf.absin(Time.time(), 10f, 1f) * 0.5f);
|
||||
Draw.rect(topRegion, x, y);
|
||||
|
||||
Draw.alpha(1f);
|
||||
Lines.stroke((2f * f + 0.2f) * heat);
|
||||
Lines.square(x, y, ((1f - f) * 8f) * size / 2f);
|
||||
Lines.square(x, y, Math.min(1f + (1f - f) * size * tilesize / 2f, size * tilesize/2f));
|
||||
|
||||
Draw.reset();
|
||||
}
|
||||
|
Reference in New Issue
Block a user