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

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

View File

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

View File

@@ -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