Derelict repair rule

This commit is contained in:
Anuken
2023-10-30 21:01:04 -04:00
parent 9f88d895ad
commit 968fa2f9b1
4 changed files with 6 additions and 2 deletions

View File

@@ -1260,6 +1260,7 @@ rules.invaliddata = Invalid clipboard data.
rules.hidebannedblocks = Hide Banned Blocks rules.hidebannedblocks = Hide Banned Blocks
rules.infiniteresources = Infinite Resources rules.infiniteresources = Infinite Resources
rules.onlydepositcore = Only Allow Core Depositing rules.onlydepositcore = Only Allow Core Depositing
rules.derelictrepair = Allow Derelict Block Repair
rules.reactorexplosions = Reactor Explosions rules.reactorexplosions = Reactor Explosions
rules.coreincinerates = Core Incinerates Overflow rules.coreincinerates = Core Incinerates Overflow
rules.disableworldprocessors = Disable World Processors rules.disableworldprocessors = Disable World Processors

View File

@@ -39,6 +39,8 @@ public class Rules{
public boolean attackMode = false; public boolean attackMode = false;
/** Whether this is the editor gamemode. */ /** Whether this is the editor gamemode. */
public boolean editor = false; 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. */ /** Whether a gameover can happen at all. Set this to false to implement custom gameover conditions. */
public boolean canGameOver = true; public boolean canGameOver = true;
/** Whether cores change teams when they are destroyed. */ /** Whether cores change teams when they are destroyed. */

View File

@@ -208,6 +208,7 @@ public class CustomRulesDialog extends BaseDialog{
} }
}, () -> rules.infiniteResources); }, () -> rules.infiniteResources);
check("@rules.onlydepositcore", b -> rules.onlyDepositCore = b, () -> rules.onlyDepositCore); 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.reactorexplosions", b -> rules.reactorExplosions = b, () -> rules.reactorExplosions);
check("@rules.schematic", b -> rules.schematicsAllowed = b, () -> rules.schematicsAllowed); check("@rules.schematic", b -> rules.schematicsAllowed = b, () -> rules.schematicsAllowed);
check("@rules.coreincinerates", b -> rules.coreIncinerates = b, () -> rules.coreIncinerates); check("@rules.coreincinerates", b -> rules.coreIncinerates = b, () -> rules.coreIncinerates);

View File

@@ -87,7 +87,7 @@ public class Build{
} }
//repair derelict tile //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(); float healthf = tile.build.healthf();
var config = tile.build.config(); var config = tile.build.config();
@@ -222,7 +222,7 @@ public class Build{
!check.interactable(team) || //cannot interact !check.interactable(team) || //cannot interact
!check.floor().placeableOn || //solid wall !check.floor().placeableOn || //solid wall
(!checkVisible && !check.block().alwaysReplace) || //replacing a block that should be replaced (e.g. payload placement) (!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 (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.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 (type.requiresWater && check.floor().liquidDrop != Liquids.water) //requires water but none found