Logic config replication / logicUnitBuild rule / Copy-able ConstructBlocks
This commit is contained in:
@@ -19,7 +19,7 @@ public class LogicAI extends AIController{
|
||||
/** Time after which the unit resets its controlled and reverts to a normal unit. */
|
||||
public static final float logicControlTimeout = 10f * 60f;
|
||||
|
||||
public LUnitControl control = LUnitControl.stop;
|
||||
public LUnitControl control = LUnitControl.idle;
|
||||
public float moveX, moveY, moveRad;
|
||||
public float itemTimer, payTimer, controlTimer = logicControlTimeout, targetTimer;
|
||||
@Nullable
|
||||
|
||||
@@ -962,8 +962,19 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
lastAccessed = builder.getPlayer().name;
|
||||
}
|
||||
|
||||
Log.info("@ configured @ with @", builder, this, value);
|
||||
|
||||
if(block.configurations.containsKey(type)){
|
||||
block.configurations.get(type).get(this, value);
|
||||
}else if(value instanceof Building build){
|
||||
Log.info("conf w build");
|
||||
//copy config of another building
|
||||
var conf = build.config();
|
||||
if(conf != null && !(conf instanceof Building)){
|
||||
configured(builder, conf);
|
||||
}else{
|
||||
Log.info("no build");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@ public class Rules{
|
||||
public float unitBuildSpeedMultiplier = 1f;
|
||||
/** How much damage any other units deal. */
|
||||
public float unitDamageMultiplier = 1f;
|
||||
/** Whether to allow units to build with logic. */
|
||||
public boolean logicUnitBuild = true;
|
||||
/** How much health blocks start with. */
|
||||
public float blockHealthMultiplier = 1f;
|
||||
/** How much damage blocks (turrets) deal. */
|
||||
|
||||
@@ -27,6 +27,7 @@ import mindustry.input.Placement.*;
|
||||
import mindustry.io.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.blocks.ConstructBlock.*;
|
||||
import mindustry.world.blocks.distribution.*;
|
||||
import mindustry.world.blocks.legacy.*;
|
||||
import mindustry.world.blocks.power.*;
|
||||
@@ -357,10 +358,11 @@ public class Schematics implements Loadable{
|
||||
for(int cx = x; cx <= x2; cx++){
|
||||
for(int cy = y; cy <= y2; cy++){
|
||||
Building linked = world.build(cx, cy);
|
||||
Block realBlock = linked == null ? null : linked instanceof ConstructBuild cons ? cons.cblock : linked.block;
|
||||
|
||||
if(linked != null && (linked.block.isVisible() || linked.block() instanceof CoreBlock) && !(linked.block instanceof ConstructBlock)){
|
||||
int top = linked.block.size/2;
|
||||
int bot = linked.block.size % 2 == 1 ? -linked.block.size/2 : -(linked.block.size - 1)/2;
|
||||
if(linked != null && (realBlock.isVisible() || realBlock instanceof CoreBlock)){
|
||||
int top = realBlock.size/2;
|
||||
int bot = realBlock.size % 2 == 1 ? -realBlock.size/2 : -(realBlock.size - 1)/2;
|
||||
minx = Math.min(linked.tileX() + bot, minx);
|
||||
miny = Math.min(linked.tileY() + bot, miny);
|
||||
maxx = Math.max(linked.tileX() + top, maxx);
|
||||
@@ -385,12 +387,13 @@ public class Schematics implements Loadable{
|
||||
for(int cx = ox; cx <= ox2; cx++){
|
||||
for(int cy = oy; cy <= oy2; cy++){
|
||||
Building tile = world.build(cx, cy);
|
||||
Block realBlock = tile == null ? null : tile instanceof ConstructBuild cons ? cons.cblock : tile.block;
|
||||
|
||||
if(tile != null && !counted.contains(tile.pos()) && !(tile.block instanceof ConstructBlock)
|
||||
&& (tile.block.isVisible() || tile.block instanceof CoreBlock)){
|
||||
if(tile != null && !counted.contains(tile.pos())
|
||||
&& (realBlock.isVisible() || realBlock instanceof CoreBlock)){
|
||||
Object config = tile.config();
|
||||
|
||||
tiles.add(new Stile(tile.block, tile.tileX() + offsetX, tile.tileY() + offsetY, config, (byte)tile.rotation));
|
||||
tiles.add(new Stile(realBlock, tile.tileX() + offsetX, tile.tileY() + offsetY, config, (byte)tile.rotation));
|
||||
counted.add(tile.pos());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -447,7 +447,7 @@ public class LExecutor{
|
||||
}
|
||||
}
|
||||
case build -> {
|
||||
if(unit.canBuild() && exec.obj(p3) instanceof Block block){
|
||||
if(state.rules.logicUnitBuild && unit.canBuild() && exec.obj(p3) instanceof Block block){
|
||||
int x = World.toTile(x1 - block.offset/tilesize), y = World.toTile(y1 - block.offset/tilesize);
|
||||
int rot = exec.numi(p4);
|
||||
|
||||
@@ -458,12 +458,14 @@ public class LExecutor{
|
||||
ai.plan.stuck = false;
|
||||
}
|
||||
|
||||
var conf = exec.obj(p5);
|
||||
ai.plan.set(x, y, rot, block);
|
||||
ai.plan.config = exec.obj(p5) instanceof Content c ? c : null;
|
||||
ai.plan.config = conf instanceof Content c ? c : conf instanceof Building b ? b : null;
|
||||
|
||||
unit.clearBuilding();
|
||||
Tile tile = ai.plan.tile();
|
||||
|
||||
if(ai.plan.tile() != null){
|
||||
if(tile != null && !(tile.block() == block && tile.build != null && tile.build.rotation == rot)){
|
||||
unit.updateBuilding = true;
|
||||
unit.addBuild(ai.plan);
|
||||
}
|
||||
|
||||
@@ -829,7 +829,11 @@ public class LStatements{
|
||||
table.button(b -> {
|
||||
b.label(() -> type.name());
|
||||
b.clicked(() -> showSelect(b, LUnitControl.all, type, t -> {
|
||||
type = t;
|
||||
if(t == LUnitControl.build && !Vars.state.rules.logicUnitBuild){
|
||||
Vars.ui.showInfo("@logic.nounitbuild");
|
||||
}else{
|
||||
type = t;
|
||||
}
|
||||
rebuild(table);
|
||||
}, 2, cell -> cell.size(120, 50)));
|
||||
}, Styles.logict, () -> {}).size(120, 40).color(table.color).left().padLeft(2);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mindustry.logic;
|
||||
|
||||
public enum LUnitControl{
|
||||
idle,
|
||||
stop,
|
||||
move("x", "y"),
|
||||
approach("x", "y", "radius"),
|
||||
|
||||
Reference in New Issue
Block a user