mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-12-15 15:20:57 -08:00
Merge f4168e5877 into a01e4be75d
This commit is contained in:
commit
64ae72de47
8 changed files with 105 additions and 1 deletions
|
|
@ -2525,6 +2525,7 @@ lst.draw = Add an operation to the drawing buffer.\nDoes not display anything un
|
|||
lst.drawflush = Flush queued [accent]Draw[] operations to a display.
|
||||
lst.printflush = Flush queued [accent]Print[] operations to a message block.
|
||||
lst.getlink = Get a processor link by index. Starts at 0.
|
||||
lst.getnode = Get a power or bridge node using index. \nFor power blocks: Starts at 0. \nFor bridges: index -1 indicated the output bridge. Incoming bridges start at index 0.
|
||||
lst.control = Control a building.
|
||||
lst.radar = Locate units around a building with range.
|
||||
lst.sensor = Get data from a building or unit.
|
||||
|
|
|
|||
|
|
@ -2044,6 +2044,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||
//totalLiquids is inherently bad design, but unfortunately it is useful for conduits/tanks
|
||||
case totalLiquids -> liquids == null ? 0 : liquids.currentAmount();
|
||||
case totalPower -> power == null || block.consPower == null ? 0 : power.status * (block.consPower.buffered ? block.consPower.capacity : 1f);
|
||||
case totalPowerNodes -> power == null ? 0 : power.links.size;
|
||||
case itemCapacity -> block.hasItems ? block.itemCapacity : 0;
|
||||
case liquidCapacity -> block.hasLiquids ? block.liquidCapacity : 0;
|
||||
case powerCapacity -> block.consPower != null ? block.consPower.capacity : 0f;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ public enum LAccess{
|
|||
firstItem,
|
||||
totalLiquids,
|
||||
totalPower,
|
||||
totalPowerNodes,
|
||||
totalBridgeNodes,
|
||||
itemCapacity,
|
||||
liquidCapacity,
|
||||
powerCapacity,
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import mindustry.logic.LogicFx.*;
|
|||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.distribution.ItemBridge.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
import mindustry.world.blocks.logic.*;
|
||||
import mindustry.world.blocks.logic.LogicBlock.*;
|
||||
|
|
@ -552,6 +553,53 @@ public class LExecutor{
|
|||
}
|
||||
}
|
||||
|
||||
public static class GetNodeI implements LInstruction{
|
||||
public LNode type = LNode.power;
|
||||
public LVar building, node, index;
|
||||
|
||||
public GetNodeI(LNode type, LVar building, LVar node, LVar index){
|
||||
this.type = type;
|
||||
this.building = building;
|
||||
this.node = node;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public GetNodeI(){}
|
||||
|
||||
@Override
|
||||
public void run(LExecutor exec){
|
||||
Building n;
|
||||
int i = index.numi();
|
||||
if((n = node.building()) != null){
|
||||
switch(type){
|
||||
case power -> {
|
||||
if(i < 0 || n.power == null) break;
|
||||
IntSeq links = n.power.links;
|
||||
if(i < links.size){
|
||||
building.setobj(world.build(links.get(i)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
case bridge -> {
|
||||
if((i < -1) || !(n instanceof ItemBridgeBuild ib)) break;
|
||||
|
||||
if(i == -1) {
|
||||
building.setobj(world.build(ib.link));
|
||||
return;
|
||||
}
|
||||
|
||||
if(i < ib.incoming.size){
|
||||
building.setobj(world.build(ib.incoming.get(i)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
building.setobj(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ReadI implements LInstruction{
|
||||
public LVar target, position, output;
|
||||
|
||||
|
|
|
|||
6
core/src/mindustry/logic/LNode.java
Normal file
6
core/src/mindustry/logic/LNode.java
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
package mindustry.logic;
|
||||
|
||||
public enum LNode{
|
||||
power,
|
||||
bridge;
|
||||
}
|
||||
|
|
@ -427,6 +427,46 @@ public class LStatements{
|
|||
}
|
||||
}
|
||||
|
||||
@RegisterStatement("getnode")
|
||||
public static class GetNodeStatement extends LStatement{
|
||||
public LNode type = LNode.power;
|
||||
public String building = "building", node = "node", index = "0";
|
||||
|
||||
@Override
|
||||
public void build(Table table){
|
||||
field(table, building, str -> building = str);
|
||||
|
||||
table.add(" = ");
|
||||
|
||||
table.button(b -> {
|
||||
b.label(() -> type.name());
|
||||
b.clicked(() -> showSelect(b, LNode.values(), type, o -> {
|
||||
type = o;
|
||||
}));
|
||||
}, Styles.logict, () -> {}).size(64f, 40f).pad(4f).color(table.color);
|
||||
|
||||
row(table);
|
||||
|
||||
table.add(" node of ");
|
||||
|
||||
field(table, node, str -> node = str);
|
||||
|
||||
table.add(" at # ");
|
||||
|
||||
field(table, index, str -> index = str);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LInstruction build(LAssembler builder) {
|
||||
return new GetNodeI(type, builder.var(building), builder.var(node), builder.var(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LCategory category() {
|
||||
return LCategory.block;
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterStatement("control")
|
||||
public static class ControlStatement extends LStatement{
|
||||
public LAccess type = LAccess.enabled;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ public enum LogicOp{
|
|||
asin("asin", d -> Math.asin(d) * Mathf.doubleRadDeg),
|
||||
acos("acos", d -> Math.acos(d) * Mathf.doubleRadDeg),
|
||||
atan("atan", d -> Math.atan(d) * Mathf.doubleRadDeg),
|
||||
|
||||
;
|
||||
|
||||
public static final LogicOp[] all = values();
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import mindustry.entities.units.*;
|
|||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.input.*;
|
||||
import mindustry.logic.LAccess;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
|
@ -492,6 +493,12 @@ public class ItemBridge extends Block{
|
|||
return Point2.unpack(link).sub(tile.x, tile.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double sense(LAccess sensor){
|
||||
if(sensor == LAccess.totalBridgeNodes) return incoming.size + (link > -1 ? 1 : 0);
|
||||
return super.sense(sensor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte version(){
|
||||
return 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue