Oil extractor water now needed / new liquid physics / new plastic balance
|
After Width: | Height: | Size: 240 B |
|
After Width: | Height: | Size: 239 B |
|
After Width: | Height: | Size: 228 B |
|
Before Width: | Height: | Size: 475 B After Width: | Height: | Size: 496 B |
|
Before Width: | Height: | Size: 638 B After Width: | Height: | Size: 695 B |
BIN
core/assets-raw/sprites/blocks/production/plasticformer-top.png
Normal file
|
After Width: | Height: | Size: 194 B |
|
Before Width: | Height: | Size: 410 B After Width: | Height: | Size: 497 B |
|
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 96 KiB |
@@ -1,7 +1,7 @@
|
|||||||
#Autogenerated file. Do not modify.
|
#Autogenerated file. Do not modify.
|
||||||
#Wed Mar 28 10:18:53 EDT 2018
|
#Wed Mar 28 19:56:26 EDT 2018
|
||||||
version=release
|
version=release
|
||||||
androidBuildCode=693
|
androidBuildCode=706
|
||||||
name=Mindustry
|
name=Mindustry
|
||||||
code=3.4
|
code=3.4
|
||||||
build=custom build
|
build=custom build
|
||||||
|
|||||||
@@ -100,27 +100,29 @@ public class CraftingBlocks {
|
|||||||
size = 2;
|
size = 2;
|
||||||
}},
|
}},
|
||||||
|
|
||||||
plasticFormer = new GenericCrafter("plasticformer") {{
|
plasticFormer = new PlasticFormer("plasticformer") {{
|
||||||
inputLiquid = Liquids.oil;
|
inputLiquid = Liquids.oil;
|
||||||
liquidUse = 0.3f;
|
liquidUse = 0.3f;
|
||||||
liquidCapacity = 60f;
|
liquidCapacity = 60f;
|
||||||
powerUse = 0.3f;
|
powerUse = 0.5f;
|
||||||
craftTime = 80f;
|
craftTime = 80f;
|
||||||
output = Items.plastic;
|
output = Items.plastic;
|
||||||
itemCapacity = 30;
|
itemCapacity = 30;
|
||||||
size = 2;
|
size = 2;
|
||||||
health = 320;
|
health = 320;
|
||||||
hasPower = hasLiquids = true;
|
hasPower = hasLiquids = true;
|
||||||
|
craftEffect = Fx.formsmoke;
|
||||||
|
updateEffect = Fx.plasticburn;
|
||||||
}},
|
}},
|
||||||
|
|
||||||
biomatterCompressor = new Compressor("biomattercompressor") {{
|
biomatterCompressor = new Compressor("biomattercompressor") {{
|
||||||
input = new ItemStack(Items.biomatter, 1);
|
input = new ItemStack(Items.biomatter, 1);
|
||||||
liquidCapacity = 60f;
|
liquidCapacity = 60f;
|
||||||
itemCapacity = 50;
|
itemCapacity = 50;
|
||||||
powerUse = 0.05f;
|
powerUse = 0.06f;
|
||||||
craftTime = 10f;
|
craftTime = 25f;
|
||||||
outputLiquid = Liquids.oil;
|
outputLiquid = Liquids.oil;
|
||||||
outputLiquidAmount = 0.08f;
|
outputLiquidAmount = 0.1f;
|
||||||
size = 2;
|
size = 2;
|
||||||
health = 320;
|
health = 320;
|
||||||
hasLiquids = true;
|
hasLiquids = true;
|
||||||
|
|||||||
@@ -1,55 +1,51 @@
|
|||||||
package io.anuke.mindustry.content.blocks;
|
package io.anuke.mindustry.content.blocks;
|
||||||
|
|
||||||
import io.anuke.mindustry.content.Items;
|
|
||||||
import io.anuke.mindustry.content.Liquids;
|
|
||||||
import io.anuke.mindustry.graphics.Fx;
|
import io.anuke.mindustry.graphics.Fx;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.blocks.types.defense.RepairTurret;
|
import io.anuke.mindustry.world.blocks.types.defense.RepairTurret;
|
||||||
import io.anuke.mindustry.world.blocks.types.defense.ShieldBlock;
|
import io.anuke.mindustry.world.blocks.types.defense.ShieldBlock;
|
||||||
import io.anuke.mindustry.world.blocks.types.distribution.Teleporter;
|
import io.anuke.mindustry.world.blocks.types.distribution.Teleporter;
|
||||||
import io.anuke.mindustry.world.blocks.types.power.ItemPowerGenerator;
|
import io.anuke.mindustry.world.blocks.types.power.*;
|
||||||
|
|
||||||
public class PowerBlocks {
|
public class PowerBlocks {
|
||||||
public static final Block
|
public static final Block
|
||||||
|
|
||||||
coalgenerator = new io.anuke.mindustry.world.blocks.types.power.ItemPowerGenerator("coalgenerator") {{
|
coalgenerator = new BurnerGenerator("coalgenerator") {{
|
||||||
generateItem = Items.coal;
|
//generateItem = Items.coal;
|
||||||
powerOutput = 0.04f;
|
powerOutput = 0.04f;
|
||||||
powerCapacity = 40f;
|
powerCapacity = 40f;
|
||||||
}},
|
}},
|
||||||
|
|
||||||
thermalgenerator = new io.anuke.mindustry.world.blocks.types.power.LiquidPowerGenerator("thermalgenerator") {{
|
thermalgenerator = new LiquidHeatGenerator("thermalgenerator") {{
|
||||||
generateLiquid = Liquids.lava;
|
|
||||||
maxLiquidGenerate = 0.5f;
|
maxLiquidGenerate = 0.5f;
|
||||||
powerPerLiquid = 0.08f;
|
powerPerLiquid = 0.08f;
|
||||||
powerCapacity = 40f;
|
powerCapacity = 40f;
|
||||||
generateEffect = Fx.redgeneratespark;
|
generateEffect = Fx.redgeneratespark;
|
||||||
}},
|
}},
|
||||||
|
|
||||||
combustiongenerator = new io.anuke.mindustry.world.blocks.types.power.LiquidPowerGenerator("combustiongenerator") {{
|
combustiongenerator = new LiquidBurnerGenerator("combustiongenerator") {{
|
||||||
generateLiquid = Liquids.oil;
|
|
||||||
maxLiquidGenerate = 0.4f;
|
maxLiquidGenerate = 0.4f;
|
||||||
powerPerLiquid = 0.12f;
|
powerPerLiquid = 0.12f;
|
||||||
powerCapacity = 40f;
|
powerCapacity = 40f;
|
||||||
}},
|
}},
|
||||||
|
|
||||||
rtgenerator = new ItemPowerGenerator("rtgenerator") {{
|
rtgenerator = new BurnerGenerator("rtgenerator") {{
|
||||||
generateItem = Items.thorium;
|
//generateItem = Items.thorium;
|
||||||
powerCapacity = 40f;
|
powerCapacity = 40f;
|
||||||
powerOutput = 0.03f;
|
powerOutput = 0.03f;
|
||||||
itemDuration = 240f;
|
itemDuration = 240f;
|
||||||
}},
|
}},
|
||||||
|
|
||||||
solarpanel = new io.anuke.mindustry.world.blocks.types.power.SolarGenerator("solarpanel") {{
|
solarpanel = new SolarGenerator("solarpanel") {{
|
||||||
generation = 0.003f;
|
generation = 0.003f;
|
||||||
}},
|
}},
|
||||||
|
|
||||||
largesolarpanel = new io.anuke.mindustry.world.blocks.types.power.SolarGenerator("largesolarpanel") {{
|
largesolarpanel = new SolarGenerator("largesolarpanel") {{
|
||||||
size = 3;
|
size = 3;
|
||||||
generation = 0.012f;
|
generation = 0.012f;
|
||||||
}},
|
}},
|
||||||
|
|
||||||
nuclearReactor = new io.anuke.mindustry.world.blocks.types.power.NuclearReactor("nuclearreactor") {{
|
nuclearReactor = new NuclearReactor("nuclearreactor") {{
|
||||||
size = 3;
|
size = 3;
|
||||||
health = 600;
|
health = 600;
|
||||||
breaktime *= 2.3f;
|
breaktime *= 2.3f;
|
||||||
@@ -74,16 +70,16 @@ public class PowerBlocks {
|
|||||||
health = 400;
|
health = 400;
|
||||||
}},
|
}},
|
||||||
|
|
||||||
battery = new io.anuke.mindustry.world.blocks.types.power.PowerGenerator("battery") {{
|
battery = new PowerGenerator("battery") {{
|
||||||
powerCapacity = 320f;
|
powerCapacity = 320f;
|
||||||
}},
|
}},
|
||||||
|
|
||||||
batteryLarge = new io.anuke.mindustry.world.blocks.types.power.PowerGenerator("batterylarge") {{
|
batteryLarge = new PowerGenerator("batterylarge") {{
|
||||||
size = 3;
|
size = 3;
|
||||||
powerCapacity = 2000f;
|
powerCapacity = 2000f;
|
||||||
}},
|
}},
|
||||||
|
|
||||||
powernode = new io.anuke.mindustry.world.blocks.types.power.PowerDistributor("powernode"),
|
powernode = new PowerDistributor("powernode"),
|
||||||
|
|
||||||
teleporter = new Teleporter("teleporter");
|
teleporter = new Teleporter("teleporter");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,7 @@ package io.anuke.mindustry.content.blocks;
|
|||||||
import io.anuke.mindustry.content.Items;
|
import io.anuke.mindustry.content.Items;
|
||||||
import io.anuke.mindustry.content.Liquids;
|
import io.anuke.mindustry.content.Liquids;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.blocks.types.production.Cultivator;
|
import io.anuke.mindustry.world.blocks.types.production.*;
|
||||||
import io.anuke.mindustry.world.blocks.types.production.Drill;
|
|
||||||
import io.anuke.mindustry.world.blocks.types.production.GenericDrill;
|
|
||||||
import io.anuke.mindustry.world.blocks.types.production.SolidPump;
|
|
||||||
|
|
||||||
public class ProductionBlocks {
|
public class ProductionBlocks {
|
||||||
public static final Block
|
public static final Block
|
||||||
@@ -86,8 +83,10 @@ public class ProductionBlocks {
|
|||||||
liquidCapacity = 30f;
|
liquidCapacity = 30f;
|
||||||
}},
|
}},
|
||||||
|
|
||||||
oilextractor = new SolidPump("oilextractor") {{
|
oilextractor = new Fracker("oilextractor") {{
|
||||||
result = Liquids.oil;
|
result = Liquids.oil;
|
||||||
|
inputLiquid = Liquids.water;
|
||||||
|
inputLiquidUse = 0.3f;
|
||||||
powerUse = 0.6f;
|
powerUse = 0.6f;
|
||||||
pumpAmount = 0.06f;
|
pumpAmount = 0.06f;
|
||||||
size = 3;
|
size = 3;
|
||||||
|
|||||||
@@ -179,6 +179,14 @@ public class Fx{
|
|||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
plasticburn = new Effect(40, e -> {
|
||||||
|
Angles.randLenVectors(e.id, 5, 3f + e.ifract()*5f, (x, y)->{
|
||||||
|
Draw.color(Color.valueOf("e9ead3"), Color.GRAY, e.ifract());
|
||||||
|
Fill.circle(e.x + x, e.y + y, e.fract()*1f);
|
||||||
|
Draw.reset();
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
|
||||||
pulverize = new Effect(25, e -> {
|
pulverize = new Effect(25, e -> {
|
||||||
Angles.randLenVectors(e.id, 5, 3f + e.ifract()*5f, (x, y)->{
|
Angles.randLenVectors(e.id, 5, 3f + e.ifract()*5f, (x, y)->{
|
||||||
Draw.color(Color.valueOf("eae4f0"), Color.GRAY, e.ifract());
|
Draw.color(Color.valueOf("eae4f0"), Color.GRAY, e.ifract());
|
||||||
@@ -222,6 +230,14 @@ public class Fx{
|
|||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
formsmoke = new Effect(40, e -> {
|
||||||
|
Angles.randLenVectors(e.id, 6, 5f + e.ifract()*8f, (x, y)->{
|
||||||
|
Draw.color(Color.valueOf("f1e479"), Color.LIGHT_GRAY, e.ifract());
|
||||||
|
Fill.poly(e.x + x, e.y + y, 4, 0.2f+e.fract()*2f, 45);
|
||||||
|
Draw.reset();
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
|
||||||
blastsmoke = new Effect(26, e -> {
|
blastsmoke = new Effect(26, e -> {
|
||||||
Angles.randLenVectors(e.id, 12, 1f + e.ifract()*23f, (x, y)->{
|
Angles.randLenVectors(e.id, 12, 1f + e.ifract()*23f, (x, y)->{
|
||||||
float size = 2f+e.fract()*6f;
|
float size = 2f+e.fract()*6f;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package io.anuke.mindustry.world;
|
|||||||
import com.badlogic.gdx.math.GridPoint2;
|
import com.badlogic.gdx.math.GridPoint2;
|
||||||
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.ucore.core.Timers;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
public abstract class BaseBlock {
|
public abstract class BaseBlock {
|
||||||
public boolean hasInventory = true;
|
public boolean hasInventory = true;
|
||||||
@@ -92,14 +92,17 @@ public abstract class BaseBlock {
|
|||||||
|
|
||||||
if(ofract > fract) return;
|
if(ofract > fract) return;
|
||||||
|
|
||||||
float flow = Math.min((fract - ofract) * (liquidCapacity/(1.1f + tile.entity.liquid.liquid.viscosity)),
|
float flow = Math.min(Mathf.clamp((fract - ofract)*(1f)) * (liquidCapacity), tile.entity.liquid.amount);
|
||||||
Math.min(tile.entity.liquid.amount/liquidFlowFactor * Math.max(Timers.delta(), 1f), tile.entity.liquid.amount));
|
|
||||||
|
|
||||||
if(flow <= 0f || tile.entity.liquid.amount < flow) return;
|
flow = Math.min(flow, next.block().liquidCapacity - next.entity.liquid.amount - 0.001f);
|
||||||
|
|
||||||
if(next.block().acceptLiquid(next, tile, tile.entity.liquid.liquid, flow)){
|
if(flow <= 0f) return;
|
||||||
next.block().handleLiquid(next, tile, tile.entity.liquid.liquid, flow);
|
|
||||||
tile.entity.liquid.amount -= flow;
|
float amount = flow;
|
||||||
|
|
||||||
|
if(next.block().acceptLiquid(next, tile, tile.entity.liquid.liquid, amount)){
|
||||||
|
next.block().handleLiquid(next, tile, tile.entity.liquid.liquid, amount);
|
||||||
|
tile.entity.liquid.amount -= amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ public class TunnelConduit extends LiquidBlock {
|
|||||||
Tile to = tunnel.getNearby(tunnel.getRotation());
|
Tile to = tunnel.getNearby(tunnel.getRotation());
|
||||||
if (to == null || !(to.block().hasLiquids)) return;
|
if (to == null || !(to.block().hasLiquids)) return;
|
||||||
|
|
||||||
if (to.block().acceptLiquid(tile, source, liquid, amount)) to.block().handleLiquid(to, tunnel, liquid, amount);
|
if (to.block().acceptLiquid(to, tunnel, liquid, amount))
|
||||||
|
to.block().handleLiquid(to, tunnel, liquid, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.anuke.mindustry.world.blocks.types.power;
|
package io.anuke.mindustry.world.blocks.types.power;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
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.BarType;
|
||||||
@@ -13,22 +14,26 @@ import io.anuke.ucore.graphics.Draw;
|
|||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
import io.anuke.ucore.util.Strings;
|
import io.anuke.ucore.util.Strings;
|
||||||
|
|
||||||
public class ItemPowerGenerator extends PowerGenerator {
|
import java.io.DataInputStream;
|
||||||
public int itemCapacity = 20;
|
import java.io.DataOutputStream;
|
||||||
public Item generateItem;
|
import java.io.IOException;
|
||||||
public float powerOutput;
|
|
||||||
public float itemDuration = 70f;
|
|
||||||
public Effect generateEffect = Fx.generatespark;
|
|
||||||
public Color heatColor = Color.valueOf("ff9b59");
|
|
||||||
|
|
||||||
public ItemPowerGenerator(String name) {
|
public class BurnerGenerator extends PowerGenerator {
|
||||||
|
protected float minFlammability = 0.2f;
|
||||||
|
protected float powerOutput;
|
||||||
|
protected float itemDuration = 70f;
|
||||||
|
protected Effect generateEffect = Fx.generatespark;
|
||||||
|
protected Color heatColor = Color.valueOf("ff9b59");
|
||||||
|
|
||||||
|
public BurnerGenerator(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
itemCapacity = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBars(){
|
public void setBars(){
|
||||||
super.setBars();
|
super.setBars();
|
||||||
bars.replace(new BlockBar(BarType.inventory, true, tile -> (float)tile.entity.inventory.getItem(generateItem) / itemCapacity));
|
bars.replace(new BlockBar(BarType.inventory, true, tile -> (float)tile.entity.inventory.totalItems() / itemCapacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -36,7 +41,6 @@ public class ItemPowerGenerator extends PowerGenerator {
|
|||||||
super.setStats();
|
super.setStats();
|
||||||
stats.add("powergenerationsecond", Strings.toFixed(powerOutput*60f, 2));
|
stats.add("powergenerationsecond", Strings.toFixed(powerOutput*60f, 2));
|
||||||
stats.add("generationsecondsitem", Strings.toFixed(itemDuration/60f, 2));
|
stats.add("generationsecondsitem", Strings.toFixed(itemDuration/60f, 2));
|
||||||
stats.add("input", generateItem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -47,7 +51,7 @@ public class ItemPowerGenerator extends PowerGenerator {
|
|||||||
|
|
||||||
if(entity.generateTime > 0){
|
if(entity.generateTime > 0){
|
||||||
Draw.color(heatColor);
|
Draw.color(heatColor);
|
||||||
float alpha = (entity.inventory.hasItem(generateItem) ? 1f : Mathf.clamp(entity.generateTime));
|
float alpha = (entity.inventory.totalItems() > 0 ? 1f : Mathf.clamp(entity.generateTime));
|
||||||
alpha = alpha * 0.7f + Mathf.absin(Timers.time(), 12f, 0.3f) * alpha;
|
alpha = alpha * 0.7f + Mathf.absin(Timers.time(), 12f, 0.3f) * alpha;
|
||||||
Draw.alpha(alpha);
|
Draw.alpha(alpha);
|
||||||
Draw.rect(name + "-top", tile.worldx(), tile.worldy());
|
Draw.rect(name + "-top", tile.worldx(), tile.worldy());
|
||||||
@@ -57,14 +61,14 @@ public class ItemPowerGenerator extends PowerGenerator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||||
return item == generateItem && tile.entity.inventory.getItem(generateItem) < itemCapacity;
|
return item.flammability >= minFlammability && tile.entity.inventory.totalItems() < itemCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void update(Tile tile){
|
||||||
GeneratorEntity entity = tile.entity();
|
BurnerEntity entity = tile.entity();
|
||||||
|
|
||||||
float maxPower = Math.min(powerCapacity - entity.power.amount, powerOutput * Timers.delta());
|
float maxPower = Math.min(powerCapacity - entity.power.amount, powerOutput * Timers.delta()) * entity.efficiency;
|
||||||
float mfract = maxPower/(powerOutput);
|
float mfract = maxPower/(powerOutput);
|
||||||
|
|
||||||
if(entity.generateTime > 0f){
|
if(entity.generateTime > 0f){
|
||||||
@@ -73,9 +77,15 @@ public class ItemPowerGenerator extends PowerGenerator {
|
|||||||
entity.generateTime = Mathf.clamp(entity.generateTime);
|
entity.generateTime = Mathf.clamp(entity.generateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(entity.generateTime <= 0f && entity.inventory.hasItem(generateItem)){
|
if(entity.generateTime <= 0f && entity.inventory.totalItems() > 0){
|
||||||
Effects.effect(generateEffect, tile.worldx() + Mathf.range(3f), tile.worldy() + Mathf.range(3f));
|
Effects.effect(generateEffect, tile.worldx() + Mathf.range(3f), tile.worldy() + Mathf.range(3f));
|
||||||
entity.inventory.removeItem(generateItem, 1);
|
for(int i = 0; i < entity.inventory.items.length; i ++){
|
||||||
|
if(entity.inventory.items[i] > 0){
|
||||||
|
entity.inventory.items[i] --;
|
||||||
|
entity.efficiency = Item.getByID(i).flammability;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
entity.generateTime = 1f;
|
entity.generateTime = 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,4 +93,23 @@ public class ItemPowerGenerator extends PowerGenerator {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity getEntity() {
|
||||||
|
return new BurnerEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class BurnerEntity extends GeneratorEntity{
|
||||||
|
public float efficiency;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(DataOutputStream stream) throws IOException {
|
||||||
|
stream.writeFloat(efficiency);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(DataInputStream stream) throws IOException {
|
||||||
|
efficiency = stream.readFloat();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ import io.anuke.mindustry.entities.TileEntity;
|
|||||||
import io.anuke.mindustry.graphics.Fx;
|
import io.anuke.mindustry.graphics.Fx;
|
||||||
import io.anuke.mindustry.resource.Liquid;
|
import io.anuke.mindustry.resource.Liquid;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.mindustry.world.blocks.types.power.BurnerGenerator.BurnerEntity;
|
||||||
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;
|
||||||
@@ -11,14 +12,14 @@ import io.anuke.ucore.graphics.Draw;
|
|||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
import io.anuke.ucore.util.Strings;
|
import io.anuke.ucore.util.Strings;
|
||||||
|
|
||||||
public class LiquidPowerGenerator extends io.anuke.mindustry.world.blocks.types.power.PowerGenerator {
|
public class LiquidBurnerGenerator extends PowerGenerator {
|
||||||
public Liquid generateLiquid;
|
protected float minEfficiency = 0.2f;
|
||||||
public float powerPerLiquid = 0.13f;
|
protected float powerPerLiquid = 0.13f;
|
||||||
/**Maximum liquid used per frame.*/
|
/**Maximum liquid used per frame.*/
|
||||||
public float maxLiquidGenerate = 0.4f;
|
protected float maxLiquidGenerate = 0.4f;
|
||||||
public Effect generateEffect = Fx.generatespark;
|
protected Effect generateEffect = Fx.generatespark;
|
||||||
|
|
||||||
public LiquidPowerGenerator(String name) {
|
public LiquidBurnerGenerator(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
liquidCapacity = 30f;
|
liquidCapacity = 30f;
|
||||||
hasLiquids = true;
|
hasLiquids = true;
|
||||||
@@ -29,7 +30,6 @@ public class LiquidPowerGenerator extends io.anuke.mindustry.world.blocks.types.
|
|||||||
super.setStats();
|
super.setStats();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -53,6 +53,7 @@ public class LiquidPowerGenerator extends io.anuke.mindustry.world.blocks.types.
|
|||||||
TileEntity entity = tile.entity();
|
TileEntity entity = tile.entity();
|
||||||
|
|
||||||
if(entity.liquid.amount > 0){
|
if(entity.liquid.amount > 0){
|
||||||
|
float powerPerLiquid = getEfficiency(entity.liquid.liquid)*this.powerPerLiquid;
|
||||||
float used = Math.min(entity.liquid.amount, maxLiquidGenerate * Timers.delta());
|
float used = Math.min(entity.liquid.amount, maxLiquidGenerate * Timers.delta());
|
||||||
used = Math.min(used, (powerCapacity - entity.power.amount)/powerPerLiquid);
|
used = Math.min(used, (powerCapacity - entity.power.amount)/powerPerLiquid);
|
||||||
|
|
||||||
@@ -60,7 +61,6 @@ public class LiquidPowerGenerator extends io.anuke.mindustry.world.blocks.types.
|
|||||||
entity.power.amount += used * powerPerLiquid;
|
entity.power.amount += used * powerPerLiquid;
|
||||||
|
|
||||||
if(used > 0.001f && Mathf.chance(0.05 * Timers.delta())){
|
if(used > 0.001f && Mathf.chance(0.05 * Timers.delta())){
|
||||||
|
|
||||||
Effects.effect(generateEffect, tile.drawx() + Mathf.range(3f), tile.drawy() + Mathf.range(3f));
|
Effects.effect(generateEffect, tile.drawx() + Mathf.range(3f), tile.drawy() + Mathf.range(3f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,6 +70,15 @@ public class LiquidPowerGenerator extends io.anuke.mindustry.world.blocks.types.
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||||
return liquid == generateLiquid && super.acceptLiquid(tile, source, liquid, amount);
|
return getEfficiency(liquid) >= minEfficiency && super.acceptLiquid(tile, source, liquid, amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity getEntity() {
|
||||||
|
return new BurnerEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected float getEfficiency(Liquid liquid){
|
||||||
|
return liquid.flammability;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package io.anuke.mindustry.world.blocks.types.power;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.resource.Liquid;
|
||||||
|
|
||||||
|
public class LiquidHeatGenerator extends LiquidBurnerGenerator {
|
||||||
|
|
||||||
|
public LiquidHeatGenerator(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected float getEfficiency(Liquid liquid){
|
||||||
|
return liquid.flammability;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
package io.anuke.mindustry.world.blocks.types.power;
|
package io.anuke.mindustry.world.blocks.types.power;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import io.anuke.mindustry.content.Liquids;
|
import io.anuke.mindustry.content.Items;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.entities.effect.DamageArea;
|
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.content.Items;
|
|
||||||
import io.anuke.mindustry.resource.Liquid;
|
import io.anuke.mindustry.resource.Liquid;
|
||||||
import io.anuke.mindustry.world.BarType;
|
import io.anuke.mindustry.world.BarType;
|
||||||
import io.anuke.mindustry.world.BlockBar;
|
import io.anuke.mindustry.world.BlockBar;
|
||||||
@@ -24,7 +23,7 @@ import java.io.IOException;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
|
|
||||||
public class NuclearReactor extends io.anuke.mindustry.world.blocks.types.power.LiquidPowerGenerator {
|
public class NuclearReactor extends LiquidBurnerGenerator {
|
||||||
protected final int timerFuel = timers++;
|
protected final int timerFuel = timers++;
|
||||||
|
|
||||||
protected final Translator tr = new Translator();
|
protected final Translator tr = new Translator();
|
||||||
@@ -44,7 +43,6 @@ public class NuclearReactor extends io.anuke.mindustry.world.blocks.types.power.
|
|||||||
public NuclearReactor(String name) {
|
public NuclearReactor(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
generateItem = Items.thorium;
|
generateItem = Items.thorium;
|
||||||
generateLiquid = Liquids.water;
|
|
||||||
itemCapacity = 30;
|
itemCapacity = 30;
|
||||||
liquidCapacity = 50;
|
liquidCapacity = 50;
|
||||||
explosionEffect = Fx.nuclearShockwave;
|
explosionEffect = Fx.nuclearShockwave;
|
||||||
|
|||||||
@@ -82,5 +82,6 @@ public class PowerGenerator extends PowerBlock {
|
|||||||
|
|
||||||
public static class GeneratorEntity extends TileEntity{
|
public static class GeneratorEntity extends TileEntity{
|
||||||
public float generateTime;
|
public float generateTime;
|
||||||
|
public float uptime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ package io.anuke.mindustry.world.blocks.types.production;
|
|||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.mindustry.world.blocks.types.production.GenericCrafter.GenericCrafterEntity;
|
||||||
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
public class Compressor extends PowerCrafter {
|
public class Compressor extends PowerCrafter {
|
||||||
|
|
||||||
@@ -12,9 +15,41 @@ public class Compressor extends PowerCrafter {
|
|||||||
hasLiquids = true;
|
hasLiquids = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Tile tile) {
|
||||||
|
GenericCrafterEntity entity = tile.entity();
|
||||||
|
|
||||||
|
float powerUsed = Math.min(Timers.delta() * powerUse, tile.entity.power.amount);
|
||||||
|
float liquidAdded = Math.min(outputLiquidAmount * Timers.delta(), liquidCapacity - entity.liquid.amount);
|
||||||
|
int itemsUsed = Mathf.ceil(1 + input.amount * entity.progress);
|
||||||
|
|
||||||
|
if(entity.power.amount > powerUsed && entity.inventory.hasItem(input.item, itemsUsed) && liquidAdded > 0.001f){
|
||||||
|
entity.progress += 1f/craftTime;
|
||||||
|
entity.totalProgress += Timers.delta();
|
||||||
|
handleLiquid(tile, tile, outputLiquid, liquidAdded);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(entity.progress >= 1f){
|
||||||
|
entity.inventory.removeItem(input);
|
||||||
|
if(outputItem != null) offloadNear(tile, outputItem);
|
||||||
|
entity.progress = 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(outputItem != null && entity.timer.get(timerDump, 5)){
|
||||||
|
tryDump(tile, outputItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(outputLiquid != null){
|
||||||
|
tryDumpLiquid(tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile) {
|
public void draw(Tile tile) {
|
||||||
|
GenericCrafterEntity entity = tile.entity();
|
||||||
|
|
||||||
Draw.rect(name, tile.drawx(), tile.drawy());
|
Draw.rect(name, tile.drawx(), tile.drawy());
|
||||||
|
Draw.rect(name + "-frame" + (int) Mathf.absin(entity.totalProgress, 5f, 2.999f), tile.drawx(), tile.drawy());
|
||||||
Draw.color(Color.CLEAR, tile.entity.liquid.liquid.color, tile.entity.liquid.amount / liquidCapacity);
|
Draw.color(Color.CLEAR, tile.entity.liquid.liquid.color, tile.entity.liquid.amount / liquidCapacity);
|
||||||
Draw.rect(name + "-liquid", tile.drawx(), tile.drawy());
|
Draw.rect(name + "-liquid", tile.drawx(), tile.drawy());
|
||||||
Draw.color();
|
Draw.color();
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package io.anuke.mindustry.world.blocks.types.production;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
|
import io.anuke.mindustry.resource.Liquid;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.ucore.core.Timers;
|
||||||
|
|
||||||
|
public class Fracker extends SolidPump {
|
||||||
|
protected Liquid inputLiquid;
|
||||||
|
protected float inputLiquidUse;
|
||||||
|
|
||||||
|
public Fracker(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Tile tile) {
|
||||||
|
FrackerEntity entity = tile.entity();
|
||||||
|
|
||||||
|
if(entity.input >= inputLiquidUse * Timers.delta()){
|
||||||
|
super.update(tile);
|
||||||
|
entity.input -= inputLiquidUse * Timers.delta();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount) {
|
||||||
|
if(liquid != inputLiquid){
|
||||||
|
super.handleLiquid(tile, source, liquid, amount);
|
||||||
|
}else{
|
||||||
|
FrackerEntity entity = tile.entity();
|
||||||
|
entity.input += amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount) {
|
||||||
|
FrackerEntity entity = tile.entity();
|
||||||
|
|
||||||
|
return (liquid == inputLiquid && entity.input < inputLiquidUse) || super.acceptLiquid(tile, source, liquid, amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity getEntity() {
|
||||||
|
return new FrackerEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class FrackerEntity extends TileEntity{
|
||||||
|
public float input;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@ 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;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
import io.anuke.ucore.util.Strings;
|
import io.anuke.ucore.util.Strings;
|
||||||
|
|
||||||
public class GenericCrafter extends Block{
|
public class GenericCrafter extends Block{
|
||||||
@@ -29,6 +30,8 @@ public class GenericCrafter extends Block{
|
|||||||
protected float powerUse;
|
protected float powerUse;
|
||||||
protected float liquidUse;
|
protected float liquidUse;
|
||||||
protected Effect craftEffect = Fx.purify;
|
protected Effect craftEffect = Fx.purify;
|
||||||
|
protected Effect updateEffect = Fx.none;
|
||||||
|
protected float updateEffectChance = 0.04f;
|
||||||
|
|
||||||
public GenericCrafter(String name) {
|
public GenericCrafter(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
@@ -84,8 +87,12 @@ public class GenericCrafter extends Block{
|
|||||||
(inputItem == null || entity.inventory.hasItem(inputItem.item, itemsUsed))){
|
(inputItem == null || entity.inventory.hasItem(inputItem.item, itemsUsed))){
|
||||||
|
|
||||||
entity.progress += 1f / craftTime * Timers.delta();
|
entity.progress += 1f / craftTime * Timers.delta();
|
||||||
|
entity.totalProgress += Timers.delta();
|
||||||
if(hasPower) entity.power.amount -= powerUsed;
|
if(hasPower) entity.power.amount -= powerUsed;
|
||||||
if(hasLiquids) entity.liquid.amount -= liquidUsed;
|
if(hasLiquids) entity.liquid.amount -= liquidUsed;
|
||||||
|
|
||||||
|
if(Mathf.chance(Timers.delta() * updateEffectChance))
|
||||||
|
Effects.effect(updateEffect, entity.x + Mathf.range(size*4f), entity.y + Mathf.range(size*4));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(entity.progress >= 1f){
|
if(entity.progress >= 1f){
|
||||||
@@ -119,5 +126,6 @@ public class GenericCrafter extends Block{
|
|||||||
|
|
||||||
public static class GenericCrafterEntity extends TileEntity{
|
public static class GenericCrafterEntity extends TileEntity{
|
||||||
public float progress;
|
public float progress;
|
||||||
|
public float totalProgress;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package io.anuke.mindustry.world.blocks.types.production;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.ucore.graphics.Draw;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
|
public class PlasticFormer extends GenericCrafter {
|
||||||
|
|
||||||
|
public PlasticFormer(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Tile tile) {
|
||||||
|
super.draw(tile);
|
||||||
|
|
||||||
|
GenericCrafterEntity entity = tile.entity();
|
||||||
|
|
||||||
|
Draw.alpha(Mathf.absin(entity.totalProgress, 3f, 0.9f));
|
||||||
|
Draw.rect(name + "-top", tile.drawx(), tile.drawy());
|
||||||
|
Draw.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,12 +39,14 @@ public class PowerCrafter extends Block{
|
|||||||
|
|
||||||
if(entity.power.amount > powerUsed && entity.inventory.hasItem(input.item, itemsUsed)){
|
if(entity.power.amount > powerUsed && entity.inventory.hasItem(input.item, itemsUsed)){
|
||||||
entity.progress += 1f/craftTime;
|
entity.progress += 1f/craftTime;
|
||||||
|
entity.totalProgress += Timers.delta();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(entity.progress >= 1f){
|
if(entity.progress >= 1f){
|
||||||
entity.inventory.removeItem(input);
|
entity.inventory.removeItem(input);
|
||||||
if(outputItem != null) offloadNear(tile, outputItem);
|
if(outputItem != null) offloadNear(tile, outputItem);
|
||||||
if(outputLiquid != null) handleLiquid(tile, tile, outputLiquid, outputLiquidAmount);
|
if(outputLiquid != null) handleLiquid(tile, tile, outputLiquid, outputLiquidAmount);
|
||||||
|
entity.progress = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(outputItem != null && entity.timer.get(timerDump, 5)){
|
if(outputItem != null && entity.timer.get(timerDump, 5)){
|
||||||
|
|||||||