diff --git a/core/src/gas/world/GasBlock.java b/core/src/gas/world/GasBlock.java index d3856fb..c272669 100644 --- a/core/src/gas/world/GasBlock.java +++ b/core/src/gas/world/GasBlock.java @@ -202,7 +202,7 @@ public void setBars(){ }else{ current = entity -> entity.gasses == null ? null : entity.gasses.current(); } - bars.add("liquid", entity -> new Bar(() -> entity.gasses.get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName, + bars.add("gas", entity -> new Bar(() -> entity.gasses.get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName, () -> current.get(entity).barColor(), () -> entity == null || entity.liquids == null ? 0f : entity.gasses.get(current.get(entity)) / liquidCapacity)); } diff --git a/core/src/gas/world/blocks/production/GenericCrafterWithGas.java b/core/src/gas/world/blocks/production/GenericCrafterWithGas.java new file mode 100644 index 0000000..3717257 --- /dev/null +++ b/core/src/gas/world/blocks/production/GenericCrafterWithGas.java @@ -0,0 +1,101 @@ +package gas.world.blocks.production; + +import arc.math.*; +import arc.util.*; +import gas.*; +import gas.world.meta.*; +import mindustry.type.*; +import mindustry.world.meta.*; + +public class GenericCrafterWithGas extends GasGenericCrafter{ + public @Nullable GasStack outputGas; + + public GenericCrafterWithGas(String name){ + super(name); + } + + @Override + public void setStats(){ + super.setStats(); + + if (outputGas != null) { + aStats.add(Stat.output, new GasValue(outputGas.gas, outputGas.amount * (60f / craftTime), true)); + } + } + + @Override + public void init(){ + super.init(); + + outputsGas = outputGas != null; + } + public class GenericCrafterWithGasBuild extends GasGenericCrafterBuild{ + + @Override + public boolean shouldConsume() { + if (outputItems != null) { + for (ItemStack output : outputItems) { + if (items.get(output.item) + output.amount > itemCapacity) { + return false; + } + } + } + boolean gasBool = outputGas != null && gasses != null && gasses.get(outputGas.gas) >= gasCapacity - 0.001f; + boolean liquidBool = outputLiquid == null || !(liquids != null && liquids.get(outputLiquid.liquid) >= liquidCapacity - 0.001f); + return (liquidBool || gasBool) && enabled; + } + @Override + public void updateTile() { + if (consValid()) { + + progress += getProgressIncrease(craftTime); + totalProgress += delta(); + warmup = Mathf.approachDelta(warmup, 1f, warmupSpeed); + + if (Mathf.chanceDelta(updateEffectChance)) { + updateEffect.at(x + Mathf.range(size * 4f), y + Mathf.range(size * 4)); + } + } else { + warmup = Mathf.approachDelta(warmup, 0f, warmupSpeed); + } + + if (progress >= 1f) { + consume(); + + + if(outputItems != null){ + for(ItemStack output : outputItems){ + for(int i = 0; i < output.amount; i++){ + offload(output.item); + } + } + } + + if (outputLiquid != null) { + handleLiquid(this, outputLiquid.liquid, outputLiquid.amount); + } + + if (outputGas != null) { + handleGas(this, outputGas.gas, outputGas.amount); + } + + craftEffect.at(x, y); + progress %= 1f; + } + + if(outputItems != null && timer(timerDump, dumpTime / timeScale)){ + for(ItemStack output : outputItems){ + dump(output.item); + } + } + + if (outputLiquid != null && outputLiquid.liquid != null && hasLiquids) { + dumpLiquid(outputLiquid.liquid); + } + + if (outputGas != null && outputGas.gas != null && hasGasses) { + dumpGas(outputGas.gas); + } + } + } +}