mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-04 22:50:29 +07:00
Some simplification
This commit is contained in:
parent
5da0267df9
commit
de16c95dd6
@ -410,10 +410,7 @@ public class PlacementFragment extends Fragment{
|
|||||||
}
|
}
|
||||||
|
|
||||||
Seq<Category> getCategories(){
|
Seq<Category> getCategories(){
|
||||||
returnCatArray.clear();
|
return returnCatArray.clear().addAll(Category.all).sort((c1, c2) -> Boolean.compare(categoryEmpty[c1.ordinal()], categoryEmpty[c2.ordinal()]));
|
||||||
returnCatArray.addAll(Category.all);
|
|
||||||
returnCatArray.sort((c1, c2) -> Boolean.compare(categoryEmpty[c1.ordinal()], categoryEmpty[c2.ordinal()]));
|
|
||||||
return returnCatArray;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Seq<Block> getByCategory(Category cat){
|
Seq<Block> getByCategory(Category cat){
|
||||||
@ -421,18 +418,11 @@ public class PlacementFragment extends Fragment{
|
|||||||
}
|
}
|
||||||
|
|
||||||
Seq<Block> getUnlockedByCategory(Category cat){
|
Seq<Block> getUnlockedByCategory(Category cat){
|
||||||
return returnArray.selectFrom(content.blocks(), block -> block.category == cat && block.isVisible() && unlocked(block)).sort((b1, b2) -> {
|
return returnArray.selectFrom(content.blocks(), block -> block.category == cat && block.isVisible() && unlocked(block)).sort((b1, b2) -> Boolean.compare(!b1.isPlaceable(), !b2.isPlaceable()));
|
||||||
int locked = -Boolean.compare(unlocked(b1), unlocked(b2));
|
|
||||||
if(locked != 0) return locked;
|
|
||||||
return Boolean.compare(!b1.isPlaceable(), !b2.isPlaceable());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Block getSelectedBlock(Category cat){
|
Block getSelectedBlock(Category cat){
|
||||||
if(selectedBlocks.get(cat) == null){
|
return selectedBlocks.get(cat, () -> getByCategory(cat).find(this::unlocked));
|
||||||
selectedBlocks.put(cat, getByCategory(cat).find(this::unlocked));
|
|
||||||
}
|
|
||||||
return selectedBlocks.get(cat);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean unlocked(Block block){
|
boolean unlocked(Block block){
|
||||||
|
Loading…
Reference in New Issue
Block a user