Recipe class removed completely
This commit is contained in:
@@ -24,10 +24,9 @@ import io.anuke.mindustry.content.TechTree;
|
||||
import io.anuke.mindustry.content.TechTree.TechNode;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.type.Recipe.RecipeVisibility;
|
||||
import io.anuke.mindustry.ui.TreeLayout;
|
||||
import io.anuke.mindustry.ui.TreeLayout.TreeNode;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Block.Icon;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
@@ -50,15 +49,15 @@ public class TechTreeDialog extends FloatingDialog{
|
||||
cont.add(new View()).grow();
|
||||
|
||||
{ //debug code; TODO remove
|
||||
ObjectSet<Recipe> used = new ObjectSet<Recipe>().select(t -> true);
|
||||
ObjectSet<Block> used = new ObjectSet<Block>().select(t -> true);
|
||||
for(TechTreeNode node : nodes){
|
||||
used.add(node.node.recipe());
|
||||
used.add(node.node.block);
|
||||
}
|
||||
Array<Recipe> recipes = content.recipes().select(r -> r.visibility == RecipeVisibility.all && !used.contains(r));
|
||||
recipes.sort(Structs.comparing(r -> r.cost));
|
||||
Array<Block> recipes = content.blocks().select(r -> r.isVisible() && !used.contains(r));
|
||||
recipes.sort(Structs.comparing(r -> r.buildCost));
|
||||
|
||||
if(recipes.size > 0){
|
||||
Log.info("Recipe tree coverage: {0}%", (int)((float)nodes.size / content.recipes().select(r -> r.visibility == RecipeVisibility.all).size * 100));
|
||||
Log.info("Recipe tree coverage: {0}%", (int)((float)nodes.size / content.blocks().select(Block::isVisible).size * 100));
|
||||
Log.info("Missing items: ");
|
||||
recipes.forEach(r -> Log.info(" {0}", r));
|
||||
}
|
||||
@@ -111,7 +110,7 @@ public class TechTreeDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
boolean locked(TechNode node){
|
||||
return !data.isUnlocked(node.recipe());
|
||||
return !data.isUnlocked(node.block);
|
||||
}
|
||||
|
||||
class TechTreeNode extends TreeNode{
|
||||
@@ -199,7 +198,7 @@ public class TechTreeDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
void unlock(TechNode node){
|
||||
data.unlockContent(node.recipe());
|
||||
data.unlockContent(node.block);
|
||||
data.removeItems(node.requirements);
|
||||
showToast(Core.bundle.format("researched", node.block.formalName));
|
||||
checkNodes(root);
|
||||
@@ -230,7 +229,7 @@ public class TechTreeDialog extends FloatingDialog{
|
||||
|
||||
infoTable.margin(0).left().defaults().left();
|
||||
|
||||
infoTable.addImageButton("icon-info", "node", 14*2, () -> ui.content.show(node.recipe())).growY().width(50f);
|
||||
infoTable.addImageButton("icon-info", "node", 14*2, () -> ui.content.show(node.block)).growY().width(50f);
|
||||
|
||||
infoTable.add().grow();
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import io.anuke.mindustry.input.Binding;
|
||||
import io.anuke.mindustry.input.InputHandler;
|
||||
import io.anuke.mindustry.type.Category;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Block.Icon;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
@@ -33,6 +32,7 @@ import static io.anuke.mindustry.Vars.*;
|
||||
public class PlacementFragment extends Fragment{
|
||||
final int rowWidth = 4;
|
||||
|
||||
Array<Block> returnArray = new Array<>();
|
||||
Category currentCategory = Category.turret;
|
||||
Block hovered, lastDisplay;
|
||||
Tile hoverTile;
|
||||
@@ -68,8 +68,8 @@ public class PlacementFragment extends Fragment{
|
||||
int i = 0;
|
||||
for(KeyCode key : inputCatGrid){
|
||||
if(Core.input.keyDown(key)){
|
||||
input.recipe = Recipe.getByCategory(Category.values()[i]).first();
|
||||
currentCategory = input.recipe.category;
|
||||
input.block = getByCategory(Category.values()[i]).first();
|
||||
currentCategory = input.block.buildCategory;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
@@ -79,19 +79,19 @@ public class PlacementFragment extends Fragment{
|
||||
|
||||
if(tile != null){
|
||||
tile = tile.target();
|
||||
Recipe tryRecipe = Recipe.getByResult(tile.block());
|
||||
if(tryRecipe != null && data.isUnlocked(tryRecipe)){
|
||||
input.recipe = tryRecipe;
|
||||
currentCategory = input.recipe.category;
|
||||
Block tryRecipe = tile.block();
|
||||
if(tryRecipe.isVisible() && data.isUnlocked(tryRecipe)){
|
||||
input.block = tryRecipe;
|
||||
currentCategory = input.block.buildCategory;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}else{ //select block
|
||||
int i = 0;
|
||||
Array<Recipe> recipes = Recipe.getByCategory(currentCategory);
|
||||
Array<Block> recipes = getByCategory(currentCategory);
|
||||
for(KeyCode key : inputGrid){
|
||||
if(Core.input.keyDown(key))
|
||||
input.recipe = (i < recipes.size && data.isUnlocked(recipes.get(i))) ? recipes.get(i) : null;
|
||||
input.block = (i < recipes.size && data.isUnlocked(recipes.get(i))) ? recipes.get(i) : null;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class PlacementFragment extends Fragment{
|
||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||
group.setMinCheckCount(0);
|
||||
|
||||
for(Recipe recipe : Recipe.getByCategory(currentCategory)){
|
||||
for(Block block : getByCategory(currentCategory)){
|
||||
|
||||
if(index++ % rowWidth == 0){
|
||||
blockTable.row();
|
||||
@@ -126,17 +126,17 @@ public class PlacementFragment extends Fragment{
|
||||
boolean[] unlocked = {false};
|
||||
|
||||
ImageButton button = blockTable.addImageButton("icon-locked", "select", 8 * 4, () -> {
|
||||
if(data.isUnlocked(recipe)){
|
||||
input.recipe = input.recipe == recipe ? null : recipe;
|
||||
if(data.isUnlocked(block)){
|
||||
input.block = input.block == block ? null : block;
|
||||
}
|
||||
}).size(46f).group(group).get();
|
||||
|
||||
button.update(() -> { //color unplacable things gray
|
||||
boolean ulock = data.isUnlocked(recipe);
|
||||
boolean ulock = data.isUnlocked(block);
|
||||
TileEntity core = players[0].getClosestCore();
|
||||
Color color = core != null && (core.items.has(recipe.requirements) || state.rules.infiniteResources) ? Color.WHITE : ulock ? Color.GRAY : Color.WHITE;
|
||||
Color color = core != null && (core.items.has(block.buildRequirements) || state.rules.infiniteResources) ? Color.WHITE : ulock ? Color.GRAY : Color.WHITE;
|
||||
button.forEach(elem -> elem.setColor(color));
|
||||
button.setChecked(input.recipe == recipe);
|
||||
button.setChecked(input.block == block);
|
||||
|
||||
if(ulock == unlocked[0]) return;
|
||||
unlocked[0] = ulock;
|
||||
@@ -144,13 +144,13 @@ public class PlacementFragment extends Fragment{
|
||||
if(!ulock){
|
||||
button.replaceImage(new Image("icon-locked"));
|
||||
}else{
|
||||
button.replaceImage(new Image(recipe.result.icon(Icon.medium)));
|
||||
button.replaceImage(new Image(block.icon(Icon.medium)));
|
||||
}
|
||||
});
|
||||
|
||||
button.hovered(() -> hovered = recipe.result);
|
||||
button.hovered(() -> hovered = block);
|
||||
button.exited(() -> {
|
||||
if(hovered == recipe.result){
|
||||
if(hovered == block){
|
||||
hovered = null;
|
||||
}
|
||||
});
|
||||
@@ -176,11 +176,11 @@ public class PlacementFragment extends Fragment{
|
||||
header.left();
|
||||
header.add(new Image(lastDisplay.icon(Icon.medium))).size(8 * 4);
|
||||
header.labelWrap(() ->
|
||||
!data.isUnlocked(Recipe.getByResult(lastDisplay)) ? Core.bundle.get("blocks.unknown") : lastDisplay.formalName)
|
||||
!data.isUnlocked(lastDisplay) ? Core.bundle.get("blocks.unknown") : lastDisplay.formalName)
|
||||
.left().width(190f).padLeft(5);
|
||||
header.add().growX();
|
||||
if(data.isUnlocked(Recipe.getByResult(lastDisplay))){
|
||||
header.addButton("?", "clear-partial", () -> ui.content.show(Recipe.getByResult(lastDisplay)))
|
||||
if(data.isUnlocked(lastDisplay)){
|
||||
header.addButton("?", "clear-partial", () -> ui.content.show(lastDisplay))
|
||||
.size(8 * 5).padTop(-5).padRight(-5).right().grow();
|
||||
}
|
||||
}).growX().left();
|
||||
@@ -189,7 +189,7 @@ public class PlacementFragment extends Fragment{
|
||||
topTable.table(req -> {
|
||||
req.top().left();
|
||||
|
||||
for(ItemStack stack : Recipe.getByResult(lastDisplay).requirements){
|
||||
for(ItemStack stack : lastDisplay.buildRequirements){
|
||||
req.table(line -> {
|
||||
line.left();
|
||||
line.addImage(stack.item.region).size(8 * 2);
|
||||
@@ -230,7 +230,7 @@ public class PlacementFragment extends Fragment{
|
||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||
|
||||
for(Category cat : Category.values()){
|
||||
if(Recipe.getByCategory(cat).isEmpty()) continue;
|
||||
if(getByCategory(cat).isEmpty()) continue;
|
||||
|
||||
categories.addImageButton("icon-" + cat.name(), "clear-toggle", 16 * 2, () -> {
|
||||
currentCategory = cat;
|
||||
@@ -248,6 +248,16 @@ public class PlacementFragment extends Fragment{
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Array<Block> getByCategory(Category cat){
|
||||
returnArray.clear();
|
||||
for(Block block : content.blocks()){
|
||||
if(block.buildCategory == cat && block.isVisible()){
|
||||
returnArray.add(block);
|
||||
}
|
||||
}
|
||||
return returnArray;
|
||||
}
|
||||
|
||||
/** Returns the currently displayed block in the top box. */
|
||||
Block getSelected(){
|
||||
@@ -268,8 +278,8 @@ public class PlacementFragment extends Fragment{
|
||||
}
|
||||
|
||||
//block currently selected
|
||||
if(control.input(0).recipe != null){
|
||||
toDisplay = control.input(0).recipe.result;
|
||||
if(control.input(0).block != null){
|
||||
toDisplay = control.input(0).block;
|
||||
}
|
||||
|
||||
//block hovered on in build menu
|
||||
|
||||
Reference in New Issue
Block a user