Fixed many crashes, refactored block bars
This commit is contained in:
+1385
-1238
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
|||||||
#Autogenerated file. Do not modify.
|
#Autogenerated file. Do not modify.
|
||||||
#Fri Mar 09 23:07:56 EST 2018
|
#Sat Mar 10 12:12:41 EST 2018
|
||||||
version=release
|
version=release
|
||||||
androidBuildCode=420
|
androidBuildCode=424
|
||||||
name=Mindustry
|
name=Mindustry
|
||||||
code=3.4
|
code=3.4
|
||||||
build=custom build
|
build=custom build
|
||||||
|
|||||||
@@ -478,7 +478,7 @@ public class Renderer extends RendererModule{
|
|||||||
|
|
||||||
if(target.entity != null) {
|
if(target.entity != null) {
|
||||||
int bot = 0, top = 0;
|
int bot = 0, top = 0;
|
||||||
for (BlockBar bar : target.block().bars) {
|
for (BlockBar bar : target.block().bars.list()) {
|
||||||
float offset = Mathf.sign(bar.top) * (target.block().size / 2f * tilesize + 3f + 4f * ((bar.top ? top : bot))) +
|
float offset = Mathf.sign(bar.top) * (target.block().size / 2f * tilesize + 3f + 4f * ((bar.top ? top : bot))) +
|
||||||
(bar.top ? -1f : 0f);
|
(bar.top ? -1f : 0f);
|
||||||
|
|
||||||
@@ -486,7 +486,7 @@ public class Renderer extends RendererModule{
|
|||||||
|
|
||||||
if(MathUtils.isEqual(value, -1f)) continue;
|
if(MathUtils.isEqual(value, -1f)) continue;
|
||||||
|
|
||||||
drawBar(bar.color, target.drawx(), target.drawy() + offset, value);
|
drawBar(bar.type.color, target.drawx(), target.drawy() + offset, value);
|
||||||
|
|
||||||
if (bar.top)
|
if (bar.top)
|
||||||
top++;
|
top++;
|
||||||
|
|||||||
@@ -200,7 +200,6 @@ public class Save16 extends SaveFileVersion {
|
|||||||
if(tile.entity != null){
|
if(tile.entity != null){
|
||||||
byte rotation = stream.readByte();
|
byte rotation = stream.readByte();
|
||||||
short health = stream.readShort();
|
short health = stream.readShort();
|
||||||
int items = stream.readByte();
|
|
||||||
|
|
||||||
tile.entity.health = health;
|
tile.entity.health = health;
|
||||||
tile.setRotation(rotation);
|
tile.setRotation(rotation);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import io.anuke.mindustry.input.InputHandler;
|
|||||||
import io.anuke.mindustry.resource.*;
|
import io.anuke.mindustry.resource.*;
|
||||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.blocks.types.BlockStats;
|
import io.anuke.mindustry.world.BlockStats;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.graphics.Hue;
|
import io.anuke.ucore.graphics.Hue;
|
||||||
import io.anuke.ucore.scene.Element;
|
import io.anuke.ucore.scene.Element;
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package io.anuke.mindustry.world;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
|
||||||
|
public enum BarType {
|
||||||
|
health(Color.RED),
|
||||||
|
inventory(Color.GREEN),
|
||||||
|
power(Color.YELLOW),
|
||||||
|
liquid(Color.ROYAL),
|
||||||
|
heat(Color.CORAL);
|
||||||
|
|
||||||
|
public final Color color;
|
||||||
|
|
||||||
|
BarType(Color color){
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package io.anuke.mindustry.world;
|
package io.anuke.mindustry.world;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
@@ -14,7 +13,6 @@ import io.anuke.mindustry.net.NetEvents;
|
|||||||
import io.anuke.mindustry.resource.ItemStack;
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
import io.anuke.mindustry.resource.Liquid;
|
import io.anuke.mindustry.resource.Liquid;
|
||||||
import io.anuke.mindustry.world.blocks.BaseBlock;
|
import io.anuke.mindustry.world.blocks.BaseBlock;
|
||||||
import io.anuke.mindustry.world.blocks.types.BlockStats;
|
|
||||||
import io.anuke.ucore.core.Effects;
|
import io.anuke.ucore.core.Effects;
|
||||||
import io.anuke.ucore.core.Effects.Effect;
|
import io.anuke.ucore.core.Effects.Effect;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
@@ -87,13 +85,13 @@ public class Block extends BaseBlock {
|
|||||||
public Layer layer = null;
|
public Layer layer = null;
|
||||||
/**Extra layer to draw extra extra stuff on.*/
|
/**Extra layer to draw extra extra stuff on.*/
|
||||||
public Layer layer2 = null;
|
public Layer layer2 = null;
|
||||||
/**list of displayed block status bars. Defaults to health bar.*/
|
|
||||||
public Array<BlockBar> bars = Array.with(new BlockBar(Color.RED, false, tile -> tile.entity.health / (float)tile.block().health));
|
|
||||||
/**whether this block can be replaced in all cases*/
|
/**whether this block can be replaced in all cases*/
|
||||||
public boolean alwaysReplace = false;
|
public boolean alwaysReplace = false;
|
||||||
/**whether this block has instant transfer checking. used for calculations to prevent infinite loops.*/
|
/**whether this block has instant transfer checking. used for calculations to prevent infinite loops.*/
|
||||||
public boolean instantTransfer = false;
|
public boolean instantTransfer = false;
|
||||||
|
/**list of displayed block status bars. Defaults to health bar.*/
|
||||||
|
public BlockBars bars = new BlockBars();
|
||||||
|
/**List of block stats.*/
|
||||||
public BlockStats stats = new BlockStats();
|
public BlockStats stats = new BlockStats();
|
||||||
|
|
||||||
public Block(String name) {
|
public Block(String name) {
|
||||||
@@ -148,9 +146,9 @@ public class Block extends BaseBlock {
|
|||||||
|
|
||||||
//TODO make this easier to config.
|
//TODO make this easier to config.
|
||||||
public void setBars(){
|
public void setBars(){
|
||||||
if(hasPower) bars.add(new BlockBar(Color.YELLOW, true, tile -> tile.entity.power.amount / powerCapacity));
|
if(hasPower) bars.add(new BlockBar(BarType.power, true, tile -> tile.entity.power.amount / powerCapacity));
|
||||||
if(hasLiquids) bars.add(new BlockBar(Color.ROYAL, true, tile -> tile.entity.liquid.amount / liquidCapacity));
|
if(hasLiquids) bars.add(new BlockBar(BarType.liquid, true, tile -> tile.entity.liquid.amount / liquidCapacity));
|
||||||
if(hasInventory) bars.add(new BlockBar(Color.GREEN, true, tile -> (float)tile.entity.inventory.totalItems() / itemCapacity));
|
if(hasInventory) bars.add(new BlockBar(BarType.inventory, true, tile -> (float)tile.entity.inventory.totalItems() / itemCapacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String name(){
|
public String name(){
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
package io.anuke.mindustry.world;
|
package io.anuke.mindustry.world;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
|
||||||
|
|
||||||
public class BlockBar {
|
public class BlockBar {
|
||||||
public final ValueSupplier value;
|
public final ValueSupplier value;
|
||||||
public final Color color;
|
public final BarType type;
|
||||||
public final boolean top;
|
public final boolean top;
|
||||||
|
|
||||||
public BlockBar(Color color, boolean top, ValueSupplier value) {
|
public BlockBar(BarType type, boolean top, ValueSupplier value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.color = color;
|
this.type = type;
|
||||||
this.top = top;
|
this.top = top;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package io.anuke.mindustry.world;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
|
||||||
|
public class BlockBars {
|
||||||
|
private Array<BlockBar> list = Array.with(new BlockBar(BarType.health, false, tile -> tile.entity.health / (float)tile.block().health));
|
||||||
|
|
||||||
|
public void add(BlockBar bar){
|
||||||
|
list.add(bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void replace(BlockBar bar){
|
||||||
|
remove(bar.type);
|
||||||
|
list.add(bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(BarType type){
|
||||||
|
for(BlockBar bar : list){
|
||||||
|
if(bar.type == type){
|
||||||
|
list.removeValue(bar, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAll(BarType type){
|
||||||
|
Array<BlockBar> removals = new Array<>(4);
|
||||||
|
|
||||||
|
for(BlockBar bar : list){
|
||||||
|
if(bar.type == type){
|
||||||
|
removals.add(bar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
list.removeAll(removals, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Array<BlockBar> list() {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package io.anuke.mindustry.world.blocks.types;
|
package io.anuke.mindustry.world;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.OrderedMap;
|
import com.badlogic.gdx.utils.OrderedMap;
|
||||||
import io.anuke.ucore.util.Bundles;
|
import io.anuke.ucore.util.Bundles;
|
||||||
@@ -147,7 +147,7 @@ public class ProductionBlocks{
|
|||||||
{
|
{
|
||||||
resource = Blocks.stone;
|
resource = Blocks.stone;
|
||||||
result = Item.stone;
|
result = Item.stone;
|
||||||
drillTime = 40;
|
drillTime = 240;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ public class ProductionBlocks{
|
|||||||
{
|
{
|
||||||
resource = Blocks.iron;
|
resource = Blocks.iron;
|
||||||
result = Item.iron;
|
result = Item.iron;
|
||||||
drillTime = 60;
|
drillTime = 360;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ public class ProductionBlocks{
|
|||||||
{
|
{
|
||||||
resource = Blocks.coal;
|
resource = Blocks.coal;
|
||||||
result = Item.coal;
|
result = Item.coal;
|
||||||
drillTime = 60;
|
drillTime = 360;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ public class ProductionBlocks{
|
|||||||
{
|
{
|
||||||
resource = Blocks.uranium;
|
resource = Blocks.uranium;
|
||||||
result = Item.uranium;
|
result = Item.uranium;
|
||||||
drillTime = 70;
|
drillTime = 540;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -179,13 +179,13 @@ public class ProductionBlocks{
|
|||||||
{
|
{
|
||||||
resource = Blocks.titanium;
|
resource = Blocks.titanium;
|
||||||
result = Item.titanium;
|
result = Item.titanium;
|
||||||
drillTime = 70;
|
drillTime = 540;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
laserdrill = new GenericDrill("laserdrill"){
|
laserdrill = new GenericDrill("laserdrill"){
|
||||||
{
|
{
|
||||||
drillTime = 40;
|
drillTime = 240;
|
||||||
size = 2;
|
size = 2;
|
||||||
powerUse = 0.08f;
|
powerUse = 0.08f;
|
||||||
}
|
}
|
||||||
@@ -193,7 +193,7 @@ public class ProductionBlocks{
|
|||||||
|
|
||||||
nucleardrill = new GenericDrill("nucleardrill"){
|
nucleardrill = new GenericDrill("nucleardrill"){
|
||||||
{
|
{
|
||||||
drillTime = 40;
|
drillTime = 240;
|
||||||
size = 3;
|
size = 3;
|
||||||
powerUse = 0.32f;
|
powerUse = 0.32f;
|
||||||
}
|
}
|
||||||
@@ -202,7 +202,7 @@ public class ProductionBlocks{
|
|||||||
plasmadrill = new GenericDrill("plasmadrill"){
|
plasmadrill = new GenericDrill("plasmadrill"){
|
||||||
{
|
{
|
||||||
inputLiquid = Liquid.plasma;
|
inputLiquid = Liquid.plasma;
|
||||||
drillTime = 40;
|
drillTime = 240;
|
||||||
size = 4;
|
size = 4;
|
||||||
powerUse = 0.16f;
|
powerUse = 0.16f;
|
||||||
}
|
}
|
||||||
@@ -212,7 +212,7 @@ public class ProductionBlocks{
|
|||||||
{
|
{
|
||||||
resource = Blocks.sand;
|
resource = Blocks.sand;
|
||||||
result = Item.quartz;
|
result = Item.quartz;
|
||||||
drillTime = 50;
|
drillTime = 300;
|
||||||
size = 2;
|
size = 2;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ public abstract class PowerBlock extends Block{
|
|||||||
super(name);
|
super(name);
|
||||||
update = true;
|
update = true;
|
||||||
solid = true;
|
solid = true;
|
||||||
|
hasPower = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ public class RepairTurret extends PowerTurret{
|
|||||||
public void setStats(){
|
public void setStats(){
|
||||||
super.setStats();
|
super.setStats();
|
||||||
|
|
||||||
//TODO remove extra crap
|
|
||||||
stats.add("repairssecond", Strings.toFixed(60f/reload * repairFrac * 100, 1) + "%");
|
stats.add("repairssecond", Strings.toFixed(60f/reload * repairFrac * 100, 1) + "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,7 @@ import io.anuke.mindustry.entities.TileEntity;
|
|||||||
import io.anuke.mindustry.entities.enemies.Enemy;
|
import io.anuke.mindustry.entities.enemies.Enemy;
|
||||||
import io.anuke.mindustry.graphics.Fx;
|
import io.anuke.mindustry.graphics.Fx;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.*;
|
||||||
import io.anuke.mindustry.world.BlockBar;
|
|
||||||
import io.anuke.mindustry.world.Layer;
|
|
||||||
import io.anuke.mindustry.world.Tile;
|
|
||||||
import io.anuke.ucore.core.Effects;
|
import io.anuke.ucore.core.Effects;
|
||||||
import io.anuke.ucore.core.Effects.Effect;
|
import io.anuke.ucore.core.Effects.Effect;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
@@ -59,8 +56,11 @@ public class Turret extends Block{
|
|||||||
update = true;
|
update = true;
|
||||||
solid = true;
|
solid = true;
|
||||||
layer = Layer.turret;
|
layer = Layer.turret;
|
||||||
|
}
|
||||||
|
|
||||||
bars.add(new BlockBar(Color.GREEN, true, tile -> (float)tile.<TurretEntity>entity().ammo / maxammo));
|
@Override
|
||||||
|
public void setBars(){
|
||||||
|
bars.replace(new BlockBar(BarType.inventory, true, tile -> (float)tile.<TurretEntity>entity().ammo / maxammo));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import io.anuke.ucore.util.Translator;
|
|||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class Generator extends PowerBlock{
|
public class Generator extends PowerBlock{
|
||||||
public static final int powerTime = 2;
|
|
||||||
public static boolean drawRangeOverlay = false;
|
public static boolean drawRangeOverlay = false;
|
||||||
|
|
||||||
protected Translator t1 = new Translator();
|
protected Translator t1 = new Translator();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.anuke.mindustry.world.blocks.types.generation;
|
|||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import io.anuke.mindustry.graphics.Fx;
|
import io.anuke.mindustry.graphics.Fx;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
|
import io.anuke.mindustry.world.BarType;
|
||||||
import io.anuke.mindustry.world.BlockBar;
|
import io.anuke.mindustry.world.BlockBar;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.core.Effects;
|
import io.anuke.ucore.core.Effects;
|
||||||
@@ -23,8 +24,12 @@ public class ItemPowerGenerator extends Generator{
|
|||||||
public ItemPowerGenerator(String name) {
|
public ItemPowerGenerator(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
outputOnly = true;
|
outputOnly = true;
|
||||||
|
}
|
||||||
|
|
||||||
bars.add(new BlockBar(Color.GREEN, true, tile -> (float)tile.entity.inventory.getItem(generateItem) / itemCapacity));
|
@Override
|
||||||
|
public void setBars(){
|
||||||
|
super.setBars();
|
||||||
|
bars.replace(new BlockBar(BarType.inventory, true, tile -> (float)tile.entity.inventory.getItem(generateItem) / itemCapacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -23,12 +23,12 @@ public class LiquidPowerGenerator extends Generator{
|
|||||||
super(name);
|
super(name);
|
||||||
outputOnly = true;
|
outputOnly = true;
|
||||||
liquidCapacity = 30f;
|
liquidCapacity = 30f;
|
||||||
|
hasLiquids = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setStats(){
|
public void setStats(){
|
||||||
super.setStats();
|
super.setStats();
|
||||||
stats.add("liquidcapacity", (int)liquidCapacity);
|
|
||||||
stats.add("powerliquid", Strings.toFixed(powerPerLiquid, 2) + " power/liquid");
|
stats.add("powerliquid", Strings.toFixed(powerPerLiquid, 2) + " power/liquid");
|
||||||
stats.add("maxliquidsecond", Strings.toFixed(maxLiquidGenerate*60f, 2) + " liquid/s");
|
stats.add("maxliquidsecond", Strings.toFixed(maxLiquidGenerate*60f, 2) + " liquid/s");
|
||||||
stats.add("input", generateLiquid);
|
stats.add("input", generateLiquid);
|
||||||
@@ -40,8 +40,6 @@ public class LiquidPowerGenerator extends Generator{
|
|||||||
|
|
||||||
TileEntity entity = tile.entity();
|
TileEntity entity = tile.entity();
|
||||||
|
|
||||||
if(entity.liquid.liquid == null) return;
|
|
||||||
|
|
||||||
Draw.color(entity.liquid.liquid.color);
|
Draw.color(entity.liquid.liquid.color);
|
||||||
Draw.alpha(entity.liquid.amount / liquidCapacity);
|
Draw.alpha(entity.liquid.amount / liquidCapacity);
|
||||||
drawLiquidCenter(tile);
|
drawLiquidCenter(tile);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import io.anuke.mindustry.entities.effect.DamageArea;
|
|||||||
import io.anuke.mindustry.graphics.Fx;
|
import io.anuke.mindustry.graphics.Fx;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.resource.Liquid;
|
import io.anuke.mindustry.resource.Liquid;
|
||||||
|
import io.anuke.mindustry.world.BarType;
|
||||||
import io.anuke.mindustry.world.BlockBar;
|
import io.anuke.mindustry.world.BlockBar;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.core.Effects;
|
import io.anuke.ucore.core.Effects;
|
||||||
@@ -48,9 +49,13 @@ public class NuclearReactor extends LiquidPowerGenerator{
|
|||||||
explosive = true;
|
explosive = true;
|
||||||
powerCapacity = 80f;
|
powerCapacity = 80f;
|
||||||
powerSpeed = 0.5f;
|
powerSpeed = 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
bars.add(new BlockBar(Color.GREEN, true, tile -> (float)tile.entity.inventory.getItem(generateItem) / itemCapacity));
|
@Override
|
||||||
bars.add(new BlockBar(Color.ORANGE, true, tile -> tile.<NuclearReactorEntity>entity().heat));
|
public void setBars(){
|
||||||
|
super.setBars();
|
||||||
|
bars.replace(new BlockBar(BarType.inventory, true, tile -> (float)tile.entity.inventory.getItem(generateItem) / itemCapacity));
|
||||||
|
bars.add(new BlockBar(BarType.heat, true, tile -> tile.<NuclearReactorEntity>entity().heat));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -183,7 +188,7 @@ public class NuclearReactor extends LiquidPowerGenerator{
|
|||||||
return new NuclearReactorEntity();
|
return new NuclearReactorEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class NuclearReactorEntity extends PowerEntity{
|
public static class NuclearReactorEntity extends GeneratorEntity{
|
||||||
public float heat;
|
public float heat;
|
||||||
public float flash;
|
public float flash;
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public class Drill extends Block{
|
|||||||
|
|
||||||
protected Block resource;
|
protected Block resource;
|
||||||
protected Item result;
|
protected Item result;
|
||||||
protected float drillTime = 5;
|
protected float drillTime = 300;
|
||||||
protected Effect drillEffect = Fx.spark;
|
protected Effect drillEffect = Fx.spark;
|
||||||
|
|
||||||
public Drill(String name) {
|
public Drill(String name) {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class GenericDrill extends Drill{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(toAdd.size > 0 && entity.power.amount > powerUse && entity.time >= drillTime
|
if(toAdd.size > 0 && entity.time >= drillTime
|
||||||
&& tile.entity.inventory.totalItems() < itemCapacity){
|
&& tile.entity.inventory.totalItems() < itemCapacity){
|
||||||
for(Item item : toAdd) offloadNear(tile, item);
|
for(Item item : toAdd) offloadNear(tile, item);
|
||||||
Effects.effect(drillEffect, tile.drawx(), tile.drawy());
|
Effects.effect(drillEffect, tile.drawx(), tile.drawy());
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package io.anuke.mindustry.world.blocks.types.production;
|
package io.anuke.mindustry.world.blocks.types.production;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.graphics.Fx;
|
import io.anuke.mindustry.graphics.Fx;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.resource.Liquid;
|
import io.anuke.mindustry.resource.Liquid;
|
||||||
|
import io.anuke.mindustry.world.BarType;
|
||||||
import io.anuke.mindustry.world.BlockBar;
|
import io.anuke.mindustry.world.BlockBar;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.types.LiquidBlock;
|
import io.anuke.mindustry.world.blocks.types.LiquidBlock;
|
||||||
@@ -34,8 +34,15 @@ public class LiquidCrafter extends LiquidBlock{
|
|||||||
solid = true;
|
solid = true;
|
||||||
health = 60;
|
health = 60;
|
||||||
liquidCapacity = 21f;
|
liquidCapacity = 21f;
|
||||||
|
}
|
||||||
|
|
||||||
bars.add(new BlockBar(Color.GREEN, true, tile -> input == null ? -1f : (float)tile.entity.inventory.getItem(input) / itemCapacity));
|
@Override
|
||||||
|
public void setBars(){
|
||||||
|
super.setBars();
|
||||||
|
bars.remove(BarType.inventory);
|
||||||
|
|
||||||
|
bars.add(new BlockBar(BarType.inventory, true,
|
||||||
|
tile -> input == null ? -1f : (float)tile.entity.inventory.getItem(input) / itemCapacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package io.anuke.mindustry.world.blocks.types.production;
|
package io.anuke.mindustry.world.blocks.types.production;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.graphics.Fx;
|
import io.anuke.mindustry.graphics.Fx;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.resource.ItemStack;
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
|
import io.anuke.mindustry.world.BarType;
|
||||||
import io.anuke.mindustry.world.BlockBar;
|
import io.anuke.mindustry.world.BlockBar;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.types.PowerBlock;
|
import io.anuke.mindustry.world.blocks.types.PowerBlock;
|
||||||
@@ -42,9 +42,12 @@ public class PowerSmelter extends PowerBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(){
|
public void setBars(){
|
||||||
|
super.setBars();
|
||||||
|
bars.remove(BarType.inventory);
|
||||||
|
|
||||||
for(ItemStack item : inputs){
|
for(ItemStack item : inputs){
|
||||||
bars.add(new BlockBar(Color.GREEN, true, tile -> (float)tile.entity.inventory.getItem(item.item)/capacity));
|
bars.add(new BlockBar(BarType.inventory, true, tile -> (float)tile.entity.inventory.getItem(item.item)/capacity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +55,7 @@ public class PowerSmelter extends PowerBlock {
|
|||||||
public void setStats(){
|
public void setStats(){
|
||||||
super.setStats();
|
super.setStats();
|
||||||
stats.add("input", Arrays.toString(inputs));
|
stats.add("input", Arrays.toString(inputs));
|
||||||
stats.add("powerdrainsecond", Strings.toFixed(powerDrain*60f, 2));
|
stats.add("powersecond", Strings.toFixed(powerDrain*60f, 2));
|
||||||
stats.add("output", result);
|
stats.add("output", result);
|
||||||
stats.add("fuelduration", Strings.toFixed(burnDuration/60f, 1));
|
stats.add("fuelduration", Strings.toFixed(burnDuration/60f, 1));
|
||||||
stats.add("maxoutputsecond", Strings.toFixed(60f/craftTime, 1));
|
stats.add("maxoutputsecond", Strings.toFixed(60f/craftTime, 1));
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package io.anuke.mindustry.world.blocks.types.production;
|
package io.anuke.mindustry.world.blocks.types.production;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.graphics.Fx;
|
import io.anuke.mindustry.graphics.Fx;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
|
import io.anuke.mindustry.world.BarType;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.BlockBar;
|
import io.anuke.mindustry.world.BlockBar;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
@@ -37,9 +37,9 @@ public class Smelter extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(){
|
public void setBars(){
|
||||||
for(Item item : inputs){
|
for(Item item : inputs){
|
||||||
bars.add(new BlockBar(Color.GREEN, true, tile -> (float)tile.entity.inventory.getItem(item)/capacity));
|
bars.add(new BlockBar(BarType.inventory, true, tile -> (float)tile.entity.inventory.getItem(item)/capacity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ public class Smelter extends Block{
|
|||||||
stats.add("output", result);
|
stats.add("output", result);
|
||||||
stats.add("fuelduration", Strings.toFixed(burnDuration/60f, 1));
|
stats.add("fuelduration", Strings.toFixed(burnDuration/60f, 1));
|
||||||
stats.add("maxoutputsecond", Strings.toFixed(60f/craftTime, 1));
|
stats.add("maxoutputsecond", Strings.toFixed(60f/craftTime, 1));
|
||||||
stats.add("input capacity", capacity);
|
stats.add("inputcapacity", capacity);
|
||||||
stats.add("outputcapacity", capacity);
|
stats.add("outputcapacity", capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.anuke.mindustry.world.blocks.types.storage;
|
package io.anuke.mindustry.world.blocks.types.storage;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
@@ -17,6 +18,7 @@ public class CoreBlock extends StorageBlock {
|
|||||||
solid = true;
|
solid = true;
|
||||||
destructible = true;
|
destructible = true;
|
||||||
size = 3;
|
size = 3;
|
||||||
|
hasInventory = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -31,6 +33,28 @@ public class CoreBlock extends StorageBlock {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||||
return item.material && tile.entity.inventory.getItem(item) < capacity;
|
return item.material && state.inventory.getAmount(item) < capacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Item removeItem(Tile tile){
|
||||||
|
for(int i = 0; i < state.inventory.getItems().length; i ++){
|
||||||
|
if(state.inventory.getItems()[i] > 0){
|
||||||
|
if(Net.server() || !Net.active()) state.inventory.getItems()[i] --;
|
||||||
|
return Item.getByID(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasItem(Tile tile){
|
||||||
|
TileEntity entity = tile.entity;
|
||||||
|
for(int i = 0; i < state.inventory.getItems().length; i ++){
|
||||||
|
if(state.inventory.getItems()[i] > 0){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,4 +22,14 @@ public abstract class StorageBlock extends Block {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasItem(Tile tile){
|
||||||
|
TileEntity entity = tile.entity;
|
||||||
|
for(int i = 0; i < entity.inventory.items.length; i ++){
|
||||||
|
if(entity.inventory.items[i] > 0){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class Unloader extends Block {
|
|||||||
if(tile.entity.inventory.totalItems() == 0 && tile.entity.timer.get(timerUnload, 5)){
|
if(tile.entity.inventory.totalItems() == 0 && tile.entity.timer.get(timerUnload, 5)){
|
||||||
tile.allNearby(other -> {
|
tile.allNearby(other -> {
|
||||||
if(other.block() instanceof StorageBlock && tile.entity.inventory.totalItems() == 0 &&
|
if(other.block() instanceof StorageBlock && tile.entity.inventory.totalItems() == 0 &&
|
||||||
other.entity.inventory.totalItems() > 0){
|
((StorageBlock)other.block()).hasItem(other)){
|
||||||
offloadNear(tile, ((StorageBlock)other.block()).removeItem(other));
|
offloadNear(tile, ((StorageBlock)other.block()).removeItem(other));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -35,4 +35,7 @@ public class Unloader extends Block {
|
|||||||
Block block = to.target().block();
|
Block block = to.target().block();
|
||||||
return !(block instanceof StorageBlock);
|
return !(block instanceof StorageBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBars(){}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,16 @@
|
|||||||
package io.anuke.mindustry.world.blocks.types.storage;
|
package io.anuke.mindustry.world.blocks.types.storage;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.world.BlockBar;
|
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
|
|
||||||
public class Vault extends StorageBlock {
|
public class Vault extends StorageBlock {
|
||||||
public int capacity = 1000;
|
|
||||||
|
|
||||||
public Vault(String name){
|
public Vault(String name){
|
||||||
super(name);
|
super(name);
|
||||||
solid = true;
|
solid = true;
|
||||||
update = true;
|
update = true;
|
||||||
bars.add(new BlockBar(Color.GREEN, true, tile -> (float)tile.entity.inventory.totalItems()/capacity));
|
itemCapacity = 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -35,7 +32,7 @@ public class Vault extends StorageBlock {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptItem(Item item, Tile tile, Tile source) {
|
public boolean acceptItem(Item item, Tile tile, Tile source) {
|
||||||
return tile.entity.inventory.totalItems() < capacity;
|
return tile.entity.inventory.totalItems() < itemCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user