Bugfixes
This commit is contained in:
@@ -19,6 +19,7 @@ import io.anuke.mindustry.entities.type.Player;
|
|||||||
import io.anuke.mindustry.game.Content;
|
import io.anuke.mindustry.game.Content;
|
||||||
import io.anuke.mindustry.game.EventType.*;
|
import io.anuke.mindustry.game.EventType.*;
|
||||||
import io.anuke.mindustry.game.GlobalData;
|
import io.anuke.mindustry.game.GlobalData;
|
||||||
|
import io.anuke.mindustry.game.Rules;
|
||||||
import io.anuke.mindustry.game.Saves;
|
import io.anuke.mindustry.game.Saves;
|
||||||
import io.anuke.mindustry.gen.Call;
|
import io.anuke.mindustry.gen.Call;
|
||||||
import io.anuke.mindustry.input.Binding;
|
import io.anuke.mindustry.input.Binding;
|
||||||
@@ -227,9 +228,10 @@ public class Control implements ApplicationListener{
|
|||||||
return inputs[index];
|
return inputs[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playMap(Map map){
|
public void playMap(Map map, Rules rules){
|
||||||
ui.loadAnd(() -> {
|
ui.loadAnd(() -> {
|
||||||
logic.reset();
|
logic.reset();
|
||||||
|
state.rules = rules;
|
||||||
world.loadMap(map);
|
world.loadMap(map);
|
||||||
logic.play();
|
logic.play();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -207,13 +207,13 @@ public class World implements ApplicationListener{
|
|||||||
ui.loadAnd(() -> {
|
ui.loadAnd(() -> {
|
||||||
logic.reset();
|
logic.reset();
|
||||||
state.rules = zone.rules.get();
|
state.rules = zone.rules.get();
|
||||||
|
state.rules.zone = zone.id;
|
||||||
loadGenerator(zone.generator);
|
loadGenerator(zone.generator);
|
||||||
for(Tile core : state.teams.get(defaultTeam).cores){
|
for(Tile core : state.teams.get(defaultTeam).cores){
|
||||||
for(ItemStack stack : zone.startingItems){
|
for(ItemStack stack : zone.startingItems){
|
||||||
core.entity.items.add(stack.item, stack.amount);
|
core.entity.items.add(stack.item, stack.amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state.rules.zone = zone.id;
|
|
||||||
state.set(State.playing);
|
state.set(State.playing);
|
||||||
control.saves.zoneSave();
|
control.saves.zoneSave();
|
||||||
logic.play();
|
logic.play();
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import io.anuke.arc.collection.ObjectMap;
|
|||||||
import io.anuke.arc.collection.ObjectSet;
|
import io.anuke.arc.collection.ObjectSet;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.content.Items;
|
import io.anuke.mindustry.content.Items;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
|
||||||
import io.anuke.mindustry.game.EventType.UnlockEvent;
|
import io.anuke.mindustry.game.EventType.UnlockEvent;
|
||||||
import io.anuke.mindustry.type.ContentType;
|
import io.anuke.mindustry.type.ContentType;
|
||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
@@ -79,7 +78,7 @@ public class GlobalData{
|
|||||||
|
|
||||||
/** Returns whether or not this piece of content is unlocked yet.*/
|
/** Returns whether or not this piece of content is unlocked yet.*/
|
||||||
public boolean isUnlocked(UnlockableContent content){
|
public boolean isUnlocked(UnlockableContent content){
|
||||||
return (!state.is(State.menu) && !world.isZone()) || content.alwaysUnlocked() || unlocked.getOr(content.getContentType(), ObjectSet::new).contains(content.getContentName());
|
return content.alwaysUnlocked() || unlocked.getOr(content.getContentType(), ObjectSet::new).contains(content.getContentName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ public class CustomGameDialog extends FloatingDialog{
|
|||||||
|
|
||||||
image.clicked(() -> {
|
image.clicked(() -> {
|
||||||
hide();
|
hide();
|
||||||
control.playMap(map);
|
control.playMap(map, lastPreset.get());
|
||||||
});
|
});
|
||||||
|
|
||||||
maps.add(image);
|
maps.add(image);
|
||||||
@@ -122,14 +122,6 @@ public class CustomGameDialog extends FloatingDialog{
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
ImageButton gen = maps.addImageButton("icon-editor", "clear", 16*4, () -> {
|
|
||||||
hide();
|
|
||||||
world.generator.playRandomMap();
|
|
||||||
}).growY().get();
|
|
||||||
gen.row();
|
|
||||||
gen.add("$map.random");*/
|
|
||||||
|
|
||||||
if(world.maps.all().size == 0){
|
if(world.maps.all().size == 0){
|
||||||
maps.add("$maps.none").pad(50);
|
maps.add("$maps.none").pad(50);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import io.anuke.arc.scene.ui.ImageButton;
|
|||||||
import io.anuke.arc.scene.ui.layout.Table;
|
import io.anuke.arc.scene.ui.layout.Table;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.entities.type.TileEntity;
|
import io.anuke.mindustry.entities.type.TileEntity;
|
||||||
|
import io.anuke.mindustry.game.EventType.UnlockEvent;
|
||||||
import io.anuke.mindustry.game.EventType.WorldLoadEvent;
|
import io.anuke.mindustry.game.EventType.WorldLoadEvent;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.mindustry.input.Binding;
|
import io.anuke.mindustry.input.Binding;
|
||||||
@@ -61,6 +62,12 @@ public class PlacementFragment extends Fragment{
|
|||||||
control.input(0).block = null;
|
control.input(0).block = null;
|
||||||
rebuild();
|
rebuild();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Events.on(UnlockEvent.class, event -> {
|
||||||
|
if(event.content instanceof Block){
|
||||||
|
rebuild();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void rebuild(){
|
void rebuild(){
|
||||||
@@ -77,7 +84,7 @@ public class PlacementFragment extends Fragment{
|
|||||||
if(tile != null){
|
if(tile != null){
|
||||||
tile = tile.target();
|
tile = tile.target();
|
||||||
Block tryRecipe = tile.block();
|
Block tryRecipe = tile.block();
|
||||||
if(tryRecipe.isVisible() && data.isUnlocked(tryRecipe)){
|
if(tryRecipe.isVisible() && unlocked(tryRecipe)){
|
||||||
input.block = tryRecipe;
|
input.block = tryRecipe;
|
||||||
currentCategory = input.block.buildCategory;
|
currentCategory = input.block.buildCategory;
|
||||||
return true;
|
return true;
|
||||||
@@ -101,7 +108,7 @@ public class PlacementFragment extends Fragment{
|
|||||||
Array<Block> recipes = getByCategory(currentCategory);
|
Array<Block> recipes = getByCategory(currentCategory);
|
||||||
for(KeyCode key : inputGrid){
|
for(KeyCode key : inputGrid){
|
||||||
if(Core.input.keyDown(key))
|
if(Core.input.keyDown(key))
|
||||||
input.block = (i < recipes.size && data.isUnlocked(recipes.get(i))) ? recipes.get(i) : null;
|
input.block = (i < recipes.size && unlocked(recipes.get(i))) ? recipes.get(i) : null;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,13 +139,13 @@ public class PlacementFragment extends Fragment{
|
|||||||
blockTable.row();
|
blockTable.row();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!data.isUnlocked(block)){
|
if(!unlocked(block)){
|
||||||
blockTable.add().size(46);
|
blockTable.add().size(46);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageButton button = blockTable.addImageButton("icon-locked", "select", 8 * 4, () -> {
|
ImageButton button = blockTable.addImageButton("icon-locked", "select", 8 * 4, () -> {
|
||||||
if(data.isUnlocked(block)){
|
if(unlocked(block)){
|
||||||
input.block = input.block == block ? null : block;
|
input.block = input.block == block ? null : block;
|
||||||
}
|
}
|
||||||
}).size(46f).group(group).get();
|
}).size(46f).group(group).get();
|
||||||
@@ -146,9 +153,8 @@ public class PlacementFragment extends Fragment{
|
|||||||
button.replaceImage(new Image(block.icon(Icon.medium)));
|
button.replaceImage(new Image(block.icon(Icon.medium)));
|
||||||
|
|
||||||
button.update(() -> { //color unplacable things gray
|
button.update(() -> { //color unplacable things gray
|
||||||
boolean ulock = data.isUnlocked(block);
|
|
||||||
TileEntity core = players[0].getClosestCore();
|
TileEntity core = players[0].getClosestCore();
|
||||||
Color color = core != null && (core.items.has(block.buildRequirements) || state.rules.infiniteResources) ? Color.WHITE : ulock ? Color.GRAY : Color.WHITE;
|
Color color = core != null && (core.items.has(block.buildRequirements) || state.rules.infiniteResources) ? Color.WHITE : Color.GRAY;
|
||||||
button.forEach(elem -> elem.setColor(color));
|
button.forEach(elem -> elem.setColor(color));
|
||||||
button.setChecked(input.block == block);
|
button.setChecked(input.block == block);
|
||||||
});
|
});
|
||||||
@@ -185,10 +191,10 @@ public class PlacementFragment extends Fragment{
|
|||||||
topTable.table(header -> {
|
topTable.table(header -> {
|
||||||
header.left();
|
header.left();
|
||||||
header.add(new Image(lastDisplay.icon(Icon.medium))).size(8 * 4);
|
header.add(new Image(lastDisplay.icon(Icon.medium))).size(8 * 4);
|
||||||
header.labelWrap(() -> !data.isUnlocked(lastDisplay) ? Core.bundle.get("blocks.unknown") : lastDisplay.formalName)
|
header.labelWrap(() -> !unlocked(lastDisplay) ? Core.bundle.get("blocks.unknown") : lastDisplay.formalName)
|
||||||
.left().width(190f).padLeft(5);
|
.left().width(190f).padLeft(5);
|
||||||
header.add().growX();
|
header.add().growX();
|
||||||
if(data.isUnlocked(lastDisplay)){
|
if(unlocked(lastDisplay)){
|
||||||
header.addButton("?", "clear-partial", () -> ui.content.show(lastDisplay))
|
header.addButton("?", "clear-partial", () -> ui.content.show(lastDisplay))
|
||||||
.size(8 * 5).padTop(-5).padRight(-5).right().grow();
|
.size(8 * 5).padTop(-5).padRight(-5).right().grow();
|
||||||
}
|
}
|
||||||
@@ -251,7 +257,7 @@ public class PlacementFragment extends Fragment{
|
|||||||
//update category empty values
|
//update category empty values
|
||||||
for(Category cat : Category.values()){
|
for(Category cat : Category.values()){
|
||||||
Array<Block> blocks = getByCategory(cat);
|
Array<Block> blocks = getByCategory(cat);
|
||||||
categoryEmpty[cat.ordinal()] = blocks.isEmpty() || !blocks.first().unlocked();
|
categoryEmpty[cat.ordinal()] = blocks.isEmpty() || !unlocked(blocks.first());
|
||||||
}
|
}
|
||||||
|
|
||||||
int f = 0;
|
int f = 0;
|
||||||
@@ -292,10 +298,14 @@ public class PlacementFragment extends Fragment{
|
|||||||
returnArray.add(block);
|
returnArray.add(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
returnArray.sort((b1, b2) -> -Boolean.compare(b1.unlocked(), b2.unlocked()));
|
returnArray.sort((b1, b2) -> -Boolean.compare(unlocked(b1), unlocked(b2)));
|
||||||
return returnArray;
|
return returnArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean unlocked(Block block){
|
||||||
|
return !world.isZone() || data.isUnlocked(block);
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns the currently displayed block in the top box. */
|
/** Returns the currently displayed block in the top box. */
|
||||||
Block getSelected(){
|
Block getSelected(){
|
||||||
Block toDisplay = null;
|
Block toDisplay = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user