Logic config replication / logicUnitBuild rule / Copy-able ConstructBlocks

This commit is contained in:
Anuken
2021-02-21 10:23:46 -05:00
parent 02d8f679b5
commit 61d9dea487
8 changed files with 37 additions and 11 deletions

View File

@@ -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. */

View File

@@ -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());
}
}