Improved drillable stat display

This commit is contained in:
Anuken 2022-07-23 13:08:51 -04:00
parent d98f26d35b
commit 50530e7534
2 changed files with 14 additions and 4 deletions

View File

@ -160,7 +160,8 @@ public class Drill extends Block{
public void setStats(){
super.setStats();
stats.add(Stat.drillTier, StatValues.blocks(b -> b instanceof Floor f && !f.wallOre && f.itemDrop != null && f.itemDrop.hardness <= tier && f.itemDrop != blockedItem));
stats.add(Stat.drillTier, StatValues.blocks(b -> b instanceof Floor f && !f.wallOre && f.itemDrop != null &&
f.itemDrop.hardness <= tier && f.itemDrop != blockedItem && (indexer.isBlockPresent(f) || state.isMenu())));
stats.add(Stat.drillSpeed, 60f / drillTime * size * size, StatUnit.itemsSecond);
if(liquidBoostIntensity != 1){

View File

@ -196,15 +196,20 @@ public class StatValues{
});
});
}
public static StatValue content(Seq<UnlockableContent> list){
return content(list, i -> true);
}
public static <T extends UnlockableContent> StatValue content(Seq<T> list, Boolf<T> check){
return table -> table.table(l -> {
l.left();
boolean any = false;
for(int i = 0; i < list.size; i++){
var item = list.get(i);
if(item instanceof Block block && block.itemDrop != null && !block.itemDrop.unlockedNow()) continue;
if(!check.get(item)) continue;
any = true;
if(item.uiIcon.found()) l.image(item.uiIcon).size(iconSmall).padRight(2).padLeft(2).padTop(3).padBottom(3);
l.add(item.localizedName).left().padLeft(1).padRight(4).colspan(item.uiIcon.found() ? 1 : 2);
@ -212,11 +217,15 @@ public class StatValues{
l.row();
}
}
if(!any){
l.add("@none.inmap");
}
});
}
public static StatValue blocks(Boolf<Block> pred){
return blocks(content.blocks().select(pred));
return content(content.blocks(), pred);
}
public static StatValue blocks(Seq<Block> list){