Rule & control for logic unit deconstruction (off by default)

This commit is contained in:
Anuken
2025-12-19 00:35:41 -05:00
parent f391126b5b
commit b84d12407f
6 changed files with 25 additions and 9 deletions

View File

@@ -92,6 +92,8 @@ public class Rules{
public boolean ghostBlocks = true;
/** Whether to allow units to build with logic. */
public boolean logicUnitBuild = true;
/** Whether to allow units to deconstruct blocks with logic. */
public boolean logicUnitDeconstruct = false;
/** If true, world processors can be edited and placed on this map. */
public boolean allowEditWorldProcessors = false;
/** If true, world processors no longer update. Used for testing. */

View File

@@ -430,6 +430,21 @@ public class LExecutor{
}
}
}
case deconstruct -> {
if((state.rules.logicUnitDeconstruct || exec.privileged) && unit.canBuild()){
ai.plan.x = World.toTile(x1);
ai.plan.y = World.toTile(y1);
ai.plan.breaking = true;
unit.clearBuilding();
Tile tile = ai.plan.tile();
if(tile != null && Build.validBreak(unit.team, ai.plan.x, ai.plan.y)){
unit.updateBuilding = true;
unit.addBuild(ai.plan);
}
}
}
case getBlock -> {
float range = Math.max(unit.range(), unit.type.buildRange);
if(!unit.within(x1, y1, range)){

View File

@@ -1128,12 +1128,12 @@ public class LStatements{
table.button(b -> {
b.label(() -> type.name());
b.clicked(() -> showSelect(b, LUnitControl.all, type, t -> {
if(t == LUnitControl.build && !Vars.state.rules.logicUnitBuild){
Vars.ui.showInfo("@logic.nounitbuild");
}else{
type = t;
}
b.clicked(() -> showSelect(b, Structs.filter(LUnitControl.class, LUnitControl.all, t ->
t == LUnitControl.build ? state.rules.logicUnitBuild :
t == LUnitControl.deconstruct ? state.rules.logicUnitDeconstruct :
true
), type, t -> {
type = t;
rebuild(table);
}, 2, cell -> cell.size(120, 50)));
}, Styles.logict, () -> {}).size(120, 40).color(table.color).left().padLeft(2);

View File

@@ -18,6 +18,7 @@ public enum LUnitControl{
mine("x", "y"),
flag("value"),
build("x", "y", "block", "rotation", "config"),
deconstruct("x", "y"),
getBlock("x", "y", "type", "building", "floor"),
within("x", "y", "radius", "result"),
unbind;

View File

@@ -1492,7 +1492,7 @@ public class Mods implements Loadable{
disabled,
}
public static class ModResolutionContext {
public static class ModResolutionContext{
public final ObjectMap<String, Seq<ModDependency>> dependencies = new ObjectMap<>();
public final ObjectSet<String> visited = new ObjectSet<>();
public final OrderedSet<String> ordered = new OrderedSet<>();