Added cryofluid mixer, liquid rebalancing

This commit is contained in:
Anuken 2018-03-13 18:54:28 -04:00
parent 539971b5a0
commit b822a02d41
17 changed files with 464 additions and 346 deletions

View File

Before

Width:  |  Height:  |  Size: 171 B

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 529 B

After

Width:  |  Height:  |  Size: 536 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

After

Width:  |  Height:  |  Size: 91 KiB

View File

@ -1,7 +1,7 @@
#Autogenerated file. Do not modify.
#Tue Mar 13 11:22:58 EDT 2018
#Tue Mar 13 18:52:30 EDT 2018
version=release
androidBuildCode=479
androidBuildCode=489
name=Mindustry
code=3.4
build=custom build

View File

@ -13,7 +13,7 @@ public class Liquid {
none = new Liquid("none", Color.CLEAR),
water = new Liquid("water", Color.ROYAL){
{
heatCapacity = 0.7f;
heatCapacity = 0.4f;
}
},
plasma = new Liquid("plasma", Color.CORAL){
@ -38,8 +38,8 @@ public class Liquid {
},
cryofluid = new Liquid("cryofluid", Color.SKY){
{
heatCapacity = 0.8f;
temperature = 0.1f;
heatCapacity = 0.75f;
temperature = 0.5f;
}
},
sulfuricAcid = new Liquid("sulfuricAcid", Color.YELLOW){

View File

@ -56,6 +56,7 @@ public class Recipes {
new Recipe(crafting, ProductionBlocks.stoneformer, stack(Item.steel, 10), stack(Item.iron, 10)),
new Recipe(crafting, ProductionBlocks.lavasmelter, stack(Item.steel, 30), stack(Item.titanium, 15)),
new Recipe(crafting, ProductionBlocks.siliconextractor, stack(Item.steel, 30), stack(Item.titanium, 15)),
new Recipe(crafting, ProductionBlocks.cryofluidmixer, stack(Item.steel, 30), stack(Item.titanium, 15)),
new Recipe(crafting, ProductionBlocks.weaponFactory, stack(Item.steel, 60), stack(Item.iron, 60)).setDesktop(),
//new Recipe(crafting, ProductionBlocks.centrifuge, stack(Item.steel, 30), stack(Item.iron, 30)),

View File

@ -91,7 +91,7 @@ public abstract class BaseBlock {
if(ofract > fract) return;
float flow = Math.min((fract - ofract) * liquidCapacity/2f,
float flow = Math.min((fract - ofract) * (liquidCapacity/(1.3f + tile.entity.liquid.liquid.viscosity)),
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;

View File

@ -1,7 +1,6 @@
package io.anuke.mindustry.world.blocks;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.blocks.types.LiquidBlock;
import io.anuke.mindustry.world.blocks.types.distribution.*;
import io.anuke.mindustry.world.blocks.types.storage.SortedUnloader;
import io.anuke.mindustry.world.blocks.types.storage.Unloader;
@ -11,11 +10,11 @@ public class DistributionBlocks{
public static final Block
conduit = new LiquidBlock("conduit"){{
conduit = new Conduit("conduit"){{
health = 45;
}},
pulseconduit = new LiquidBlock("pulseconduit"){{
pulseconduit = new Conduit("pulseconduit"){{
liquidCapacity = 16f;
liquidFlowFactor = 4.9f;
health = 65;
@ -23,12 +22,10 @@ public class DistributionBlocks{
liquidrouter = new LiquidRouter("liquidrouter"){{
liquidCapacity = 40f;
liquidRegion = "liquidrouter-liquid";
}},
liquidtank = new LiquidRouter("liquidtank"){{
size = 3;
liquidRegion = "liquidtank-liquid";
liquidCapacity = 1500f;
}},

View File

@ -61,6 +61,19 @@ public class ProductionBlocks{
size = 2;*/
}
},
cryofluidmixer = new LiquidMixer("cryofluidmixer"){
{
health = 200;
inputLiquid = Liquid.water;
outputLiquid = Liquid.cryofluid;
inputItem = Item.titanium;
liquidPerItem = 70f;
itemCapacity = 50;
powerUse = 0.1f;
size = 2;
}
},
coalextractor = new LiquidCrafter("coalextractor"){
{
@ -181,9 +194,9 @@ public class ProductionBlocks{
laserdrill = new GenericDrill("laserdrill"){
{
drillTime = 240;
drillTime = 200;
size = 2;
powerUse = 0.08f;
powerUse = 0.2f;
hasPower = true;
}
},

View File

@ -8,8 +8,7 @@ import io.anuke.mindustry.world.blocks.types.modules.LiquidModule;
import io.anuke.ucore.graphics.Draw;
public class LiquidBlock extends Block{
protected final int timerFlow = timers++;
protected String liquidRegion = "conduitliquid";
protected String liquidRegion = name() + "-liquid";
public LiquidBlock(String name) {
super(name);
@ -31,22 +30,15 @@ public class LiquidBlock extends Block{
int rotation = rotate ? tile.getRotation() * 90 : 0;
Draw.rect(name() + "-bottom", tile.worldx(), tile.worldy(), rotation);
Draw.rect(name() + "-bottom", tile.drawx(), tile.drawy(), rotation);
if(mod.amount > 0.01f){
if(mod.amount > 0.001f){
Draw.color(mod.liquid.color);
Draw.alpha(mod.amount / liquidCapacity);
Draw.rect(liquidRegion, tile.worldx(), tile.worldy(), rotation);
Draw.rect(liquidRegion, tile.drawx(), tile.drawy(), rotation);
Draw.color();
}
Draw.rect(name() + "-top", tile.worldx(), tile.worldy(), rotation);
}
@Override
public void update(Tile tile){
if(tile.entity.liquid.amount > 0.01f && tile.entity.timer.get(timerFlow, 1)){
tryMoveLiquid(tile, tile.getNearby(tile.getRotation()));
}
Draw.rect(name() + "-top", tile.drawx(), tile.drawy(), rotation);
}
}

View File

@ -0,0 +1,33 @@
package io.anuke.mindustry.world.blocks.types.distribution;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import io.anuke.mindustry.resource.Liquid;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.LiquidBlock;
import io.anuke.ucore.graphics.Draw;
public class Conduit extends LiquidBlock {
protected final int timerFlow = timers++;
public Conduit(String name) {
super(name);
liquidRegion = "conduit-liquid";
}
@Override
public void update(Tile tile){
if(tile.entity.liquid.amount > 0.001f && tile.entity.timer.get(timerFlow, 1)){
tryMoveLiquid(tile, tile.getNearby(tile.getRotation()));
}
}
@Override
public TextureRegion[] getIcon(){
return new TextureRegion[]{Draw.region(name() + "-bottom"), Draw.region(name() + "-top")};
}
@Override
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount) {
return super.acceptLiquid(tile, source, liquid, amount) && ((2 + source.relativeTo(tile.x, tile.y)) % 4 != tile.getRotation());
}
}

View File

@ -33,7 +33,7 @@ public class NuclearReactor extends LiquidPowerGenerator{
protected int fuelUseTime = 130; //time to consume 1 fuel
protected float powerMultiplier = 0.45f; //power per frame, depends on full capacity
protected float heating = 0.007f; //heating per frame
protected float coolantPower = 0.007f; //how much heat decreases per coolant unit
protected float coolantPower = 0.015f; //how much heat decreases per coolant unit
protected float smokeThreshold = 0.3f; //threshold at which block starts smoking
protected int explosionRadius = 19;
protected int explosionDamage = 135;
@ -85,12 +85,17 @@ public class NuclearReactor extends LiquidPowerGenerator{
}
if(entity.liquid.amount > 0){
//TODO proper coolant usage
float coolDirection = Mathf.clamp(10f * (0.6f - entity.liquid.liquid.temperature), -2f, 2f);
float maxCool = entity.liquid.amount * coolantPower * entity.liquid.liquid.heatCapacity;
entity.heat -= maxCool * coolDirection; //TODO steam when cooling large amounts?
entity.heat = Mathf.clamp(entity.heat);
entity.liquid.amount -= Math.min(entity.liquid.amount, entity.heat / coolantPower);
//TODO steam when cooling large amounts?
float liquidPower = 1f;
if(liquidPower > 0){ //is coolant
float pow = coolantPower * entity.liquid.liquid.heatCapacity;
float maxCool = Math.min(entity.liquid.amount, entity.heat / pow); //max that can be cooled in terms of liquid
entity.heat -= maxCool * pow;
entity.liquid.amount -= maxCool;
}else{ //is heater
//TODO
}
}
if(entity.heat > smokeThreshold){

View File

@ -1,10 +1,66 @@
package io.anuke.mindustry.world.blocks.types.production;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.resource.Liquid;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.LiquidBlock;
import io.anuke.ucore.core.Timers;
public class LiquidMixer extends LiquidBlock{
protected Liquid inputLiquid = Liquid.none;
protected Liquid outputLiquid = Liquid.none;
protected Item inputItem = null;
protected float liquidPerItem = 50f;
protected float powerUse = 0f;
public LiquidMixer(String name) {
super(name);
hasInventory = true;
hasPower = true;
rotate = false;
liquidRegion = name() + "-liquid";
solid = true;
}
@Override
public void update(Tile tile){
if(tile.entity.liquid.amount > 0.001f){
tryDumpLiquid(tile);
}
tile.entity.power.amount -= Math.min(Timers.delta() * powerUse, tile.entity.power.amount);
}
@Override
public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount) {
LiquidMixerEntity entity = tile.entity();
entity.accumulator += amount;
int items = (int)(entity.accumulator / liquidPerItem);
entity.inventory.removeItem(inputItem, items);
entity.accumulator %= liquidPerItem;
entity.liquid.liquid = outputLiquid;
entity.liquid.amount += amount;
}
@Override
public boolean acceptItem(Item item, Tile tile, Tile source) {
return item == inputItem && tile.entity.inventory.getItem(item) < itemCapacity;
}
@Override
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount) {
return liquid == inputLiquid && tile.entity.liquid.amount + amount <= liquidCapacity &&
tile.entity.inventory.hasItem(inputItem, (int)((tile.<LiquidMixerEntity>entity().accumulator + amount)/amount)) &&
tile.entity.power.amount >= powerUse;
}
@Override
public TileEntity getEntity() {
return new LiquidMixerEntity();
}
static class LiquidMixerEntity extends TileEntity {
float accumulator;
}
}