Config banned blocks
This commit is contained in:
@@ -404,6 +404,8 @@ launch.confirm = This will launch all resources in your core.\nYou will not be a
|
|||||||
launch.skip.confirm = If you skip now, you will not be able to launch until later waves.
|
launch.skip.confirm = If you skip now, you will not be able to launch until later waves.
|
||||||
uncover = Uncover
|
uncover = Uncover
|
||||||
configure = Configure Loadout
|
configure = Configure Loadout
|
||||||
|
bannedblocks = Banned Blocks
|
||||||
|
addall = Add All
|
||||||
configure.locked = [lightgray]Unlock configuring loadout: Wave {0}.
|
configure.locked = [lightgray]Unlock configuring loadout: Wave {0}.
|
||||||
configure.invalid = Amount must be a number between 0 and {0}.
|
configure.invalid = Amount must be a number between 0 and {0}.
|
||||||
zone.unlocked = [lightgray]{0} unlocked.
|
zone.unlocked = [lightgray]{0} unlocked.
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package io.anuke.mindustry.game;
|
package io.anuke.mindustry.game;
|
||||||
|
|
||||||
import io.anuke.annotations.Annotations.Serialize;
|
import io.anuke.annotations.Annotations.*;
|
||||||
import io.anuke.arc.collection.Array;
|
import io.anuke.arc.collection.*;
|
||||||
import io.anuke.mindustry.content.Items;
|
import io.anuke.mindustry.content.*;
|
||||||
import io.anuke.mindustry.io.JsonIO;
|
import io.anuke.mindustry.io.*;
|
||||||
import io.anuke.mindustry.type.ItemStack;
|
import io.anuke.mindustry.type.*;
|
||||||
import io.anuke.mindustry.type.Zone;
|
import io.anuke.mindustry.world.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines current rules on how the game should function.
|
* Defines current rules on how the game should function.
|
||||||
@@ -69,6 +69,8 @@ public class Rules{
|
|||||||
public boolean tutorial = false;
|
public boolean tutorial = false;
|
||||||
/** Starting items put in cores */
|
/** Starting items put in cores */
|
||||||
public Array<ItemStack> loadout = Array.with(ItemStack.with(Items.copper, 100));
|
public Array<ItemStack> loadout = Array.with(ItemStack.with(Items.copper, 100));
|
||||||
|
/** Blocks that cannot be placed. */
|
||||||
|
public ObjectSet<Block> bannedBlocks = new ObjectSet<>();
|
||||||
|
|
||||||
/** Copies this ruleset exactly. Not very efficient at all, do not use often. */
|
/** Copies this ruleset exactly. Not very efficient at all, do not use often. */
|
||||||
public Rules copy(){
|
public Rules copy(){
|
||||||
|
|||||||
@@ -19,13 +19,14 @@ import static io.anuke.mindustry.Vars.*;
|
|||||||
|
|
||||||
public class Zone extends UnlockableContent{
|
public class Zone extends UnlockableContent{
|
||||||
public @NonNull Generator generator;
|
public @NonNull Generator generator;
|
||||||
public Block[] blockRequirements = {};
|
//public Block[] blockRequirements = {};
|
||||||
public ZoneRequirement[] zoneRequirements = {};
|
public Objective[] requirements = {};
|
||||||
|
public Objective configureObjective; //TODO
|
||||||
public Item[] resources = {};
|
public Item[] resources = {};
|
||||||
|
|
||||||
public Consumer<Rules> rules = rules -> {};
|
public Consumer<Rules> rules = rules -> {};
|
||||||
public boolean alwaysUnlocked;
|
public boolean alwaysUnlocked;
|
||||||
public int conditionWave = Integer.MAX_VALUE;
|
public int conditionWave = Integer.MAX_VALUE;
|
||||||
public int configureWave = 15;
|
|
||||||
public int launchPeriod = 10;
|
public int launchPeriod = 10;
|
||||||
public Loadout loadout = Loadouts.basicShard;
|
public Loadout loadout = Loadouts.basicShard;
|
||||||
public TextureRegion preview;
|
public TextureRegion preview;
|
||||||
|
|||||||
@@ -1,32 +1,88 @@
|
|||||||
package io.anuke.mindustry.ui.dialogs;
|
package io.anuke.mindustry.ui.dialogs;
|
||||||
|
|
||||||
|
import io.anuke.arc.*;
|
||||||
import io.anuke.arc.function.*;
|
import io.anuke.arc.function.*;
|
||||||
import io.anuke.arc.graphics.*;
|
import io.anuke.arc.graphics.*;
|
||||||
|
import io.anuke.arc.scene.style.*;
|
||||||
|
import io.anuke.arc.scene.ui.*;
|
||||||
import io.anuke.arc.scene.ui.layout.*;
|
import io.anuke.arc.scene.ui.layout.*;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.mindustry.*;
|
import io.anuke.mindustry.*;
|
||||||
import io.anuke.mindustry.content.*;
|
import io.anuke.mindustry.content.*;
|
||||||
import io.anuke.mindustry.game.*;
|
import io.anuke.mindustry.game.*;
|
||||||
|
import io.anuke.mindustry.gen.*;
|
||||||
import io.anuke.mindustry.graphics.*;
|
import io.anuke.mindustry.graphics.*;
|
||||||
import io.anuke.mindustry.type.*;
|
import io.anuke.mindustry.type.*;
|
||||||
|
import io.anuke.mindustry.ui.*;
|
||||||
|
import io.anuke.mindustry.world.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class CustomRulesDialog extends FloatingDialog{
|
public class CustomRulesDialog extends FloatingDialog{
|
||||||
private Table main;
|
private Table main;
|
||||||
private Rules rules;
|
private Rules rules;
|
||||||
private Supplier<Rules> resetter;
|
private Supplier<Rules> resetter;
|
||||||
private LoadoutDialog loadoutDialog;
|
private LoadoutDialog loadoutDialog;
|
||||||
|
private FloatingDialog banDialog;
|
||||||
|
|
||||||
public CustomRulesDialog(){
|
public CustomRulesDialog(){
|
||||||
super("$mode.custom");
|
super("$mode.custom");
|
||||||
|
|
||||||
loadoutDialog = new LoadoutDialog();
|
loadoutDialog = new LoadoutDialog();
|
||||||
|
banDialog = new FloatingDialog("$bannedblocks");
|
||||||
|
banDialog.addCloseButton();
|
||||||
|
|
||||||
|
banDialog.shown(this::rebuildBanned);
|
||||||
|
banDialog.buttons.addImageTextButton("$addall", Icon.arrow16Small, () -> {
|
||||||
|
rules.bannedBlocks.addAll(content.blocks());
|
||||||
|
rebuildBanned();
|
||||||
|
}).size(210f, 64f);
|
||||||
|
|
||||||
setFillParent(true);
|
setFillParent(true);
|
||||||
shown(this::setup);
|
shown(this::setup);
|
||||||
addCloseButton();
|
addCloseButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void rebuildBanned(){
|
||||||
|
float previousScroll = banDialog.getChildren().isEmpty() ? 0f : ((ScrollPane)banDialog.getChildren().first()).getScrollY();
|
||||||
|
banDialog.cont.clear();
|
||||||
|
banDialog.cont.pane(t -> {
|
||||||
|
t.margin(10f);
|
||||||
|
for(Block block : rules.bannedBlocks){
|
||||||
|
t.table(Styles.flatOver, b -> {
|
||||||
|
b.left().margin(4f);
|
||||||
|
b.addImage(block.icon(Cicon.medium));
|
||||||
|
b.add(block.localizedName).padLeft(3).growX().left().wrap();
|
||||||
|
|
||||||
|
b.addImageButton(Icon.cancelSmall, () -> {
|
||||||
|
rules.bannedBlocks.remove(block);
|
||||||
|
rebuildBanned();
|
||||||
|
}).size(70f).pad(-4f).padLeft(0f);
|
||||||
|
}).size(300f, 70f);
|
||||||
|
t.row();
|
||||||
|
}
|
||||||
|
}).get().setScrollYForce(previousScroll);
|
||||||
|
banDialog.cont.row();
|
||||||
|
banDialog.cont.addImageTextButton("$add", Icon.addSmall, () -> {
|
||||||
|
FloatingDialog dialog = new FloatingDialog("$add");
|
||||||
|
content.blocks().each(b -> !rules.bannedBlocks.contains(b), b -> {
|
||||||
|
int cols = mobile && Core.graphics.isPortrait() ? 4 : 8;
|
||||||
|
int i = 0;
|
||||||
|
dialog.cont.addImageButton(new TextureRegionDrawable(b.icon(Cicon.medium)), Styles.cleari, () -> {
|
||||||
|
rules.bannedBlocks.add(b);
|
||||||
|
rebuildBanned();
|
||||||
|
dialog.hide();
|
||||||
|
}).size(80f);
|
||||||
|
|
||||||
|
if(++i % cols == 0){
|
||||||
|
dialog.cont.row();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.addCloseButton();
|
||||||
|
dialog.show();
|
||||||
|
}).size(300f, 64f);
|
||||||
|
}
|
||||||
|
|
||||||
public void show(Rules rules, Supplier<Rules> resetter){
|
public void show(Rules rules, Supplier<Rules> resetter){
|
||||||
this.rules = rules;
|
this.rules = rules;
|
||||||
this.resetter = resetter;
|
this.resetter = resetter;
|
||||||
@@ -65,16 +121,17 @@ public class CustomRulesDialog extends FloatingDialog{
|
|||||||
number("$rules.buildspeedmultiplier", f -> rules.buildSpeedMultiplier = f, () -> rules.buildSpeedMultiplier);
|
number("$rules.buildspeedmultiplier", f -> rules.buildSpeedMultiplier = f, () -> rules.buildSpeedMultiplier);
|
||||||
|
|
||||||
main.addButton("$configure",
|
main.addButton("$configure",
|
||||||
() -> loadoutDialog.show(
|
() -> loadoutDialog.show(Blocks.coreShard.itemCapacity, rules.loadout,
|
||||||
Blocks.coreShard.itemCapacity,
|
() -> {
|
||||||
rules.loadout,
|
rules.loadout.clear();
|
||||||
() -> {
|
rules.loadout.add(new ItemStack(Items.copper, 100));
|
||||||
rules.loadout.clear();
|
}, () -> {}, () -> {}
|
||||||
rules.loadout.add(new ItemStack(Items.copper, 100));
|
|
||||||
}, () -> {}, () -> {}
|
|
||||||
)).left().width(300f);
|
)).left().width(300f);
|
||||||
main.row();
|
main.row();
|
||||||
|
|
||||||
|
main.addButton("$bannedblocks", banDialog::show).left().width(300f);
|
||||||
|
main.row();
|
||||||
|
|
||||||
title("$rules.title.player");
|
title("$rules.title.player");
|
||||||
number("$rules.playerdamagemultiplier", f -> rules.playerDamageMultiplier = f, () -> rules.playerDamageMultiplier);
|
number("$rules.playerdamagemultiplier", f -> rules.playerDamageMultiplier = f, () -> rules.playerDamageMultiplier);
|
||||||
number("$rules.playerhealthmultiplier", f -> rules.playerHealthMultiplier = f, () -> rules.playerHealthMultiplier);
|
number("$rules.playerhealthmultiplier", f -> rules.playerHealthMultiplier = f, () -> rules.playerHealthMultiplier);
|
||||||
|
|||||||
@@ -151,6 +151,11 @@ public class PlacementFragment extends Fragment{
|
|||||||
Color color = state.rules.infiniteResources || (core != null && (core.items.has(block.requirements, state.rules.buildCostMultiplier) || state.rules.infiniteResources)) ? Color.white : Color.gray;
|
Color color = state.rules.infiniteResources || (core != null && (core.items.has(block.requirements, state.rules.buildCostMultiplier) || state.rules.infiniteResources)) ? Color.white : Color.gray;
|
||||||
button.forEach(elem -> elem.setColor(color));
|
button.forEach(elem -> elem.setColor(color));
|
||||||
button.setChecked(control.input.block == block);
|
button.setChecked(control.input.block == block);
|
||||||
|
|
||||||
|
if(state.rules.bannedBlocks.contains(block)){
|
||||||
|
button.getStyle().imageUp = Icon.cancelSmall;
|
||||||
|
button.forEach(elem -> elem.setColor(Color.gray));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
button.hovered(() -> hovered = block);
|
button.hovered(() -> hovered = block);
|
||||||
@@ -301,7 +306,11 @@ public class PlacementFragment extends Fragment{
|
|||||||
returnArray.add(block);
|
returnArray.add(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
returnArray.sort((b1, b2) -> -Boolean.compare(unlocked(b1), unlocked(b2)));
|
returnArray.sort((b1, b2) -> {
|
||||||
|
int locked = -Boolean.compare(unlocked(b1), unlocked(b2));
|
||||||
|
if(locked != 0) return locked;
|
||||||
|
return -Boolean.compare(state.rules.bannedBlocks.contains(b1), state.rules.bannedBlocks.contains(b2));
|
||||||
|
});
|
||||||
return returnArray;
|
return returnArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ public class Build{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(state.rules.bannedBlocks.contains(type) && !(state.rules.waves && team == waveTeam)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if((type.solid || type.solidifes) && Units.anyEntities(x * tilesize + type.offset() - type.size*tilesize/2f, y * tilesize + type.offset() - type.size*tilesize/2f, type.size * tilesize, type.size*tilesize)){
|
if((type.solid || type.solidifes) && Units.anyEntities(x * tilesize + type.offset() - type.size*tilesize/2f, y * tilesize + type.offset() - type.size*tilesize/2f, type.size * tilesize, type.size*tilesize)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user