diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index f3ec661d70..ea984b2160 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -1260,6 +1260,7 @@ rules.invaliddata = Invalid clipboard data. rules.hidebannedblocks = Hide Banned Blocks rules.infiniteresources = Infinite Resources rules.onlydepositcore = Only Allow Core Depositing +rules.derelictrepair = Allow Derelict Block Repair rules.reactorexplosions = Reactor Explosions rules.coreincinerates = Core Incinerates Overflow rules.disableworldprocessors = Disable World Processors diff --git a/core/src/mindustry/game/Rules.java b/core/src/mindustry/game/Rules.java index ede6161f49..aea4dde5c5 100644 --- a/core/src/mindustry/game/Rules.java +++ b/core/src/mindustry/game/Rules.java @@ -39,6 +39,8 @@ public class Rules{ public boolean attackMode = false; /** Whether this is the editor gamemode. */ public boolean editor = false; + /** Whether blocks can be repaired by clicking them. */ + public boolean derelictRepair = true; /** Whether a gameover can happen at all. Set this to false to implement custom gameover conditions. */ public boolean canGameOver = true; /** Whether cores change teams when they are destroyed. */ diff --git a/core/src/mindustry/ui/dialogs/CustomRulesDialog.java b/core/src/mindustry/ui/dialogs/CustomRulesDialog.java index 4efed965d1..e3112cf3b6 100644 --- a/core/src/mindustry/ui/dialogs/CustomRulesDialog.java +++ b/core/src/mindustry/ui/dialogs/CustomRulesDialog.java @@ -208,6 +208,7 @@ public class CustomRulesDialog extends BaseDialog{ } }, () -> rules.infiniteResources); check("@rules.onlydepositcore", b -> rules.onlyDepositCore = b, () -> rules.onlyDepositCore); + check("@rules.derelictrepair", b -> rules.derelictRepair = b, () -> rules.derelictRepair); check("@rules.reactorexplosions", b -> rules.reactorExplosions = b, () -> rules.reactorExplosions); check("@rules.schematic", b -> rules.schematicsAllowed = b, () -> rules.schematicsAllowed); check("@rules.coreincinerates", b -> rules.coreIncinerates = b, () -> rules.coreIncinerates); diff --git a/core/src/mindustry/world/Build.java b/core/src/mindustry/world/Build.java index ebfa7300e3..95664f71f4 100644 --- a/core/src/mindustry/world/Build.java +++ b/core/src/mindustry/world/Build.java @@ -87,7 +87,7 @@ public class Build{ } //repair derelict tile - if(tile.team() == Team.derelict && tile.block == result && tile.build != null && tile.block.allowDerelictRepair){ + if(tile.team() == Team.derelict && tile.block == result && tile.build != null && tile.block.allowDerelictRepair && state.rules.derelictRepair){ float healthf = tile.build.healthf(); var config = tile.build.config(); @@ -222,7 +222,7 @@ public class Build{ !check.interactable(team) || //cannot interact !check.floor().placeableOn || //solid wall (!checkVisible && !check.block().alwaysReplace) || //replacing a block that should be replaced (e.g. payload placement) - !(((type.canReplace(check.block()) || (type == check.block && check.team() == Team.derelict)) || //can replace type OR can replace derelict block of same type + !(((type.canReplace(check.block()) || (type == check.block && state.rules.derelictRepair && check.team() == Team.derelict)) || //can replace type OR can replace derelict block of same type (check.build instanceof ConstructBuild build && build.current == type && check.centerX() == tile.x && check.centerY() == tile.y)) && //same type in construction type.bounds(tile.x, tile.y, Tmp.r1).grow(0.01f).contains(check.block.bounds(check.centerX(), check.centerY(), Tmp.r2))) || //no replacement (type.requiresWater && check.floor().liquidDrop != Liquids.water) //requires water but none found