Whitelist Option + Hiding Banned Blocks Rules (#7553)
* Whitelist Option * Hide banned blocks rule
This commit is contained in:
@@ -644,6 +644,7 @@ resources.max = Max
|
|||||||
bannedblocks = Banned Blocks
|
bannedblocks = Banned Blocks
|
||||||
objectives = Objectives
|
objectives = Objectives
|
||||||
bannedunits = Banned Units
|
bannedunits = Banned Units
|
||||||
|
whitelist = Whitelist
|
||||||
addall = Add All
|
addall = Add All
|
||||||
launch.from = Launching From: [accent]{0}
|
launch.from = Launching From: [accent]{0}
|
||||||
launch.capacity = Launching Item Capacity: [accent]{0}
|
launch.capacity = Launching Item Capacity: [accent]{0}
|
||||||
@@ -1172,6 +1173,7 @@ rules.placerangecheck = Placement Range Check
|
|||||||
rules.enemyCheat = Infinite Enemy Team Resources
|
rules.enemyCheat = Infinite Enemy Team Resources
|
||||||
rules.blockhealthmultiplier = Block Health Multiplier
|
rules.blockhealthmultiplier = Block Health Multiplier
|
||||||
rules.blockdamagemultiplier = Block Damage Multiplier
|
rules.blockdamagemultiplier = Block Damage Multiplier
|
||||||
|
rules.hideBannedBlocks = Hide Banned Blocks
|
||||||
rules.unitbuildspeedmultiplier = Unit Production Speed Multiplier
|
rules.unitbuildspeedmultiplier = Unit Production Speed Multiplier
|
||||||
rules.unitcostmultiplier = Unit Cost Multiplier
|
rules.unitcostmultiplier = Unit Cost Multiplier
|
||||||
rules.unithealthmultiplier = Unit Health Multiplier
|
rules.unithealthmultiplier = Unit Health Multiplier
|
||||||
|
|||||||
@@ -95,6 +95,12 @@ public class Rules{
|
|||||||
public boolean onlyDepositCore = false;
|
public boolean onlyDepositCore = false;
|
||||||
/** If true, every enemy block in the radius of the (enemy) core is destroyed upon death. Used for campaign maps. */
|
/** If true, every enemy block in the radius of the (enemy) core is destroyed upon death. Used for campaign maps. */
|
||||||
public boolean coreDestroyClear = false;
|
public boolean coreDestroyClear = false;
|
||||||
|
/** If true, banned blocks are hidden from the build menu. */
|
||||||
|
public boolean hideBannedBlocks = false;
|
||||||
|
/** If true, bannedBlocks becomes a whitelist. */
|
||||||
|
public boolean blockWhitelist = false;
|
||||||
|
/** If true, bannedUnits becomes a whitelist. */
|
||||||
|
public boolean unitWhitelist = false;
|
||||||
/** Radius around enemy wave drop zones.*/
|
/** Radius around enemy wave drop zones.*/
|
||||||
public float dropZoneRadius = 300f;
|
public float dropZoneRadius = 300f;
|
||||||
/** Time between waves in ticks. */
|
/** Time between waves in ticks. */
|
||||||
@@ -228,6 +234,14 @@ public class Rules{
|
|||||||
return buildSpeedMultiplier * teams.get(team).buildSpeedMultiplier;
|
return buildSpeedMultiplier * teams.get(team).buildSpeedMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isBanned(Block block){
|
||||||
|
return blockWhitelist != bannedBlocks.contains(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBanned(UnitType unit){
|
||||||
|
return unitWhitelist != bannedUnits.contains(unit);
|
||||||
|
}
|
||||||
|
|
||||||
/** A team-specific ruleset. */
|
/** A team-specific ruleset. */
|
||||||
public static class TeamRule{
|
public static class TeamRule{
|
||||||
/** Whether, when AI is enabled, ships should be spawned from the core. TODO remove / unnecessary? */
|
/** Whether, when AI is enabled, ships should be spawned from the core. TODO remove / unnecessary? */
|
||||||
|
|||||||
@@ -557,7 +557,7 @@ public class UnitType extends UnlockableContent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBanned(){
|
public boolean isBanned(){
|
||||||
return state.rules.bannedUnits.contains(this);
|
return state.rules.isBanned(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -180,7 +180,9 @@ public class CustomRulesDialog extends BaseDialog{
|
|||||||
() -> {}, () -> {}
|
() -> {}, () -> {}
|
||||||
)).left().width(300f).row();
|
)).left().width(300f).row();
|
||||||
|
|
||||||
|
check("@rules.hidebannedblocks", b -> rules.hideBannedBlocks = b, () -> rules.hideBannedBlocks);
|
||||||
main.button("@bannedblocks", () -> showBanned("@bannedblocks", ContentType.block, rules.bannedBlocks, Block::canBeBuilt)).left().width(300f).row();
|
main.button("@bannedblocks", () -> showBanned("@bannedblocks", ContentType.block, rules.bannedBlocks, Block::canBeBuilt)).left().width(300f).row();
|
||||||
|
check("@whitelist", b -> rules.blockWhitelist = b, () -> rules.blockWhitelist);
|
||||||
|
|
||||||
//TODO objectives would be nice
|
//TODO objectives would be nice
|
||||||
if(experimental && false){
|
if(experimental && false){
|
||||||
@@ -198,6 +200,7 @@ public class CustomRulesDialog extends BaseDialog{
|
|||||||
number("@rules.unitcostmultiplier", f -> rules.unitCostMultiplier = f, () -> rules.unitCostMultiplier);
|
number("@rules.unitcostmultiplier", f -> rules.unitCostMultiplier = f, () -> rules.unitCostMultiplier);
|
||||||
|
|
||||||
main.button("@bannedunits", () -> showBanned("@bannedunits", ContentType.unit, rules.bannedUnits, u -> !u.isHidden())).left().width(300f).row();
|
main.button("@bannedunits", () -> showBanned("@bannedunits", ContentType.unit, rules.bannedUnits, u -> !u.isHidden())).left().width(300f).row();
|
||||||
|
check("@whitelist", b -> rules.unitWhitelist = b, () -> rules.unitWhitelist);
|
||||||
|
|
||||||
title("@rules.title.enemy");
|
title("@rules.title.enemy");
|
||||||
check("@rules.attack", b -> rules.attackMode = b, () -> rules.attackMode);
|
check("@rules.attack", b -> rules.attackMode = b, () -> rules.attackMode);
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class DatabaseDialog extends BaseDialog{
|
|||||||
Image image = unlocked(unlock) ? new Image(unlock.uiIcon).setScaling(Scaling.fit) : new Image(Icon.lock, Pal.gray);
|
Image image = unlocked(unlock) ? new Image(unlock.uiIcon).setScaling(Scaling.fit) : new Image(Icon.lock, Pal.gray);
|
||||||
|
|
||||||
//banned cross
|
//banned cross
|
||||||
if(state.isGame() && (unlock instanceof UnitType u && u.isBanned() || unlock instanceof Block b && state.rules.bannedBlocks.contains(b))){
|
if(state.isGame() && (unlock instanceof UnitType u && u.isBanned() || unlock instanceof Block b && state.rules.isBanned(b))){
|
||||||
list.stack(image, new Image(Icon.cancel){{
|
list.stack(image, new Image(Icon.cancel){{
|
||||||
setColor(Color.scarlet);
|
setColor(Color.scarlet);
|
||||||
touchable = Touchable.disabled;
|
touchable = Touchable.disabled;
|
||||||
|
|||||||
@@ -853,11 +853,11 @@ public class Block extends UnlockableContent implements Senseable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVisible(){
|
public boolean isVisible(){
|
||||||
return !isHidden();
|
return !isHidden() && (state.rules.editor || (!state.rules.hideBannedBlocks || !state.rules.isBanned(this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlaceable(){
|
public boolean isPlaceable(){
|
||||||
return isVisible() && (!state.rules.bannedBlocks.contains(this) || state.rules.editor) && supportsEnv(state.rules.env);
|
return isVisible() && (!state.rules.isBanned(this) || state.rules.editor) && supportsEnv(state.rules.env);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return whether this block supports a specific environment. */
|
/** @return whether this block supports a specific environment. */
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class Constructor extends BlockProducer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canProduce(Block b){
|
public boolean canProduce(Block b){
|
||||||
return b.isVisible() && b.size >= minBlockSize && b.size <= maxBlockSize && !(b instanceof CoreBlock) && !state.rules.bannedBlocks.contains(b) && b.environmentBuildable() && (filter.isEmpty() || filter.contains(b));
|
return b.isVisible() && b.size >= minBlockSize && b.size <= maxBlockSize && !(b instanceof CoreBlock) && !state.rules.isBanned(b) && b.environmentBuildable() && (filter.isEmpty() || filter.contains(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ConstructorBuild extends BlockProducerBuild{
|
public class ConstructorBuild extends BlockProducerBuild{
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class PayloadRouter extends PayloadConveyor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSort(Block b){
|
public boolean canSort(Block b){
|
||||||
return b.isVisible() && b.size <= size && !(b instanceof CoreBlock) && !state.rules.bannedBlocks.contains(b) && b.environmentBuildable();
|
return b.isVisible() && b.size <= size && !(b instanceof CoreBlock) && !state.rules.isBanned(b) && b.environmentBuildable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSort(UnitType t){
|
public boolean canSort(UnitType t){
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class PayloadSource extends PayloadBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canProduce(Block b){
|
public boolean canProduce(Block b){
|
||||||
return b.isVisible() && b.size < size && !(b instanceof CoreBlock) && !state.rules.bannedBlocks.contains(b) && b.environmentBuildable();
|
return b.isVisible() && b.size < size && !(b instanceof CoreBlock) && !state.rules.isBanned(b) && b.environmentBuildable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canProduce(UnitType t){
|
public boolean canProduce(UnitType t){
|
||||||
|
|||||||
Reference in New Issue
Block a user