Optional display section
This commit is contained in:
@@ -181,7 +181,7 @@ public class Floor extends Block{
|
||||
|
||||
Floor floor = other.floor();
|
||||
|
||||
if((floor.id <= this.id && !(tile.getElevation() != -1 && other.getElevation() > tile.getElevation())) || (!blends.test(floor) && !tileBlends.test(tile, other)) || (floor.cacheLayer.ordinal() > this.cacheLayer.ordinal() && !sameLayer) ||
|
||||
if(floor.edgeRegions == null || (floor.id <= this.id && !(tile.getElevation() != -1 && other.getElevation() > tile.getElevation())) || (!blends.test(floor) && !tileBlends.test(tile, other)) || (floor.cacheLayer.ordinal() > this.cacheLayer.ordinal() && !sameLayer) ||
|
||||
(sameLayer && floor.cacheLayer == this.cacheLayer)) continue;
|
||||
|
||||
TextureRegion region = floor.edgeRegions[i];
|
||||
|
||||
@@ -5,7 +5,6 @@ import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.consumers.ConsumeLiquidFilter;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
@@ -30,7 +29,6 @@ public abstract class ItemLiquidGenerator extends ItemGenerator{
|
||||
@Override
|
||||
public void init(){
|
||||
super.init();
|
||||
stats.remove(BlockStat.liquidFuelUse);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,7 +4,6 @@ import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.consumers.ConsumeLiquid;
|
||||
|
||||
//TODO
|
||||
public class TurbineGenerator extends BurnerGenerator{
|
||||
|
||||
public TurbineGenerator(String name){
|
||||
|
||||
@@ -11,8 +11,8 @@ import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import static io.anuke.mindustry.Vars.mobile;
|
||||
|
||||
public abstract class Consume{
|
||||
private boolean optional;
|
||||
private boolean update = true;
|
||||
protected boolean optional;
|
||||
protected boolean update = true;
|
||||
|
||||
public Consume optional(boolean optional){
|
||||
this.optional = optional;
|
||||
|
||||
@@ -53,6 +53,6 @@ public class ConsumeItem extends Consume{
|
||||
|
||||
@Override
|
||||
public void display(BlockStats stats){
|
||||
stats.add(BlockStat.inputItem, item);
|
||||
stats.add(optional ? BlockStat.boostItem : BlockStat.inputItem, item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,6 @@ public class ConsumeItemFilter extends Consume{
|
||||
|
||||
@Override
|
||||
public void display(BlockStats stats){
|
||||
stats.add(BlockStat.inputItems, new ItemFilterValue(filter));
|
||||
stats.add(optional ? BlockStat.boostItem : BlockStat.inputItem, new ItemFilterValue(filter));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,6 @@ public class ConsumeItems extends Consume{
|
||||
|
||||
@Override
|
||||
public void display(BlockStats stats){
|
||||
stats.add(BlockStat.inputItems, new ItemListValue(items));
|
||||
stats.add(optional ? BlockStat.boostItem : BlockStat.inputItems, new ItemListValue(items));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +47,12 @@ public class ConsumeLiquid extends Consume{
|
||||
|
||||
@Override
|
||||
public void display(BlockStats stats){
|
||||
stats.add(BlockStat.liquidUse, use * 60f, StatUnit.liquidSecond);
|
||||
stats.add(BlockStat.inputLiquid, liquid);
|
||||
if(!optional){
|
||||
stats.add(BlockStat.liquidUse, use * 60f, StatUnit.liquidSecond);
|
||||
stats.add(BlockStat.inputLiquid, liquid);
|
||||
}else{
|
||||
stats.add(BlockStat.boostLiquid, liquid);
|
||||
}
|
||||
}
|
||||
|
||||
float use(Block block, TileEntity entity){
|
||||
|
||||
@@ -62,10 +62,12 @@ public class ConsumeLiquidFilter extends Consume{
|
||||
|
||||
@Override
|
||||
public void display(BlockStats stats){
|
||||
if(isFuel){
|
||||
if(optional){
|
||||
stats.add(BlockStat.boostLiquid, new LiquidFilterValue(filter));
|
||||
}else if(isFuel){
|
||||
stats.add(BlockStat.inputLiquidFuel, new LiquidFilterValue(filter));
|
||||
stats.add(BlockStat.liquidFuelUse, 60f * use, StatUnit.liquidSecond);
|
||||
}else{
|
||||
}else {
|
||||
stats.add(BlockStat.inputLiquid, new LiquidFilterValue(filter));
|
||||
stats.add(BlockStat.liquidUse, 60f * use, StatUnit.liquidSecond);
|
||||
}
|
||||
|
||||
@@ -45,8 +45,10 @@ public enum BlockStat{
|
||||
shots(StatCategory.shooting),
|
||||
reload(StatCategory.shooting),
|
||||
powerShot(StatCategory.shooting),
|
||||
targetsAir(StatCategory.shooting),;
|
||||
targetsAir(StatCategory.shooting),
|
||||
|
||||
boostItem(StatCategory.optional),
|
||||
boostLiquid(StatCategory.optional),;
|
||||
|
||||
public final StatCategory category;
|
||||
|
||||
|
||||
@@ -12,9 +12,7 @@ import io.anuke.ucore.util.Log;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Hold and organizes a list of block stats.
|
||||
*/
|
||||
/**Hold and organizes a list of block stats.*/
|
||||
public class BlockStats{
|
||||
private static final boolean errorWhenMissing = false;
|
||||
|
||||
@@ -26,52 +24,37 @@ public class BlockStats{
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a single float value with this stat, formatted to 2 decimal places.
|
||||
*/
|
||||
/**Adds a single float value with this stat, formatted to 2 decimal places.*/
|
||||
public void add(BlockStat stat, float value, StatUnit unit){
|
||||
add(stat, new NumberValue(value, unit));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a single y/n boolean value.
|
||||
*/
|
||||
/**Adds a single y/n boolean value.*/
|
||||
public void add(BlockStat stat, boolean value){
|
||||
add(stat, new BooleanValue(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an item value.
|
||||
*/
|
||||
/**Adds an item value.*/
|
||||
public void add(BlockStat stat, Item item){
|
||||
add(stat, new ItemValue(new ItemStack(item, 1)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a liquid value.
|
||||
*/
|
||||
/**Adds a liquid value.*/
|
||||
public void add(BlockStat stat, Liquid liquid){
|
||||
add(stat, new LiquidValue(liquid));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds an item value.
|
||||
*/
|
||||
/**Adds an item value.*/
|
||||
public void add(BlockStat stat, ItemStack item){
|
||||
add(stat, new ItemValue(item));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a single string value with this stat.
|
||||
*/
|
||||
/**Adds a single string value with this stat.*/
|
||||
public void add(BlockStat stat, String format, Object... args){
|
||||
add(stat, new StringValue(format, args));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a stat value.
|
||||
*/
|
||||
/**Adds a stat value.*/
|
||||
public void add(BlockStat stat, StatValue value){
|
||||
if(!Bundles.has("text.blocks." + stat.name().toLowerCase(Locale.ROOT))){
|
||||
if(!errorWhenMissing){
|
||||
@@ -102,6 +85,7 @@ public class BlockStats{
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
/**Removes a stat, if it exists.*/
|
||||
public void remove(BlockStat stat){
|
||||
if(!map.containsKey(stat.category) || !map.get(stat.category).containsKey(stat)){
|
||||
throw new RuntimeException("No stat entry found: \"" + stat + "\" in block '" + block.name + "'!");
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package io.anuke.mindustry.world.meta;
|
||||
|
||||
/**
|
||||
* A specific category for a stat.
|
||||
*/
|
||||
/**A specific category for a stat.*/
|
||||
public enum StatCategory{
|
||||
general,
|
||||
power,
|
||||
liquids,
|
||||
items,
|
||||
crafting,
|
||||
shooting
|
||||
shooting,
|
||||
optional,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user