Fixed cryofluid mixer
This commit is contained in:
@@ -517,9 +517,9 @@ public class Blocks implements ContentList{
|
||||
consumes.items(new ItemStack(Items.titanium, 2), new ItemStack(Items.lead, 4), new ItemStack(Items.silicon, 3), new ItemStack(Items.copper, 3));
|
||||
}};
|
||||
|
||||
cryofluidMixer = new GenericCrafter("cryofluidmixer"){{
|
||||
cryofluidMixer = new LiquidConverter("cryofluidmixer"){{
|
||||
requirements(Category.crafting, ItemStack.with(Items.lead, 130, Items.silicon, 80, Items.thorium, 90));
|
||||
outputLiquid = new LiquidStack(Liquids.cryofluid, 7.2f);
|
||||
outputLiquid = new LiquidStack(Liquids.cryofluid, 0.1f);
|
||||
craftTime = 60f;
|
||||
size = 2;
|
||||
hasPower = true;
|
||||
@@ -531,7 +531,7 @@ public class Blocks implements ContentList{
|
||||
|
||||
consumes.power(1f);
|
||||
consumes.item(Items.titanium);
|
||||
consumes.liquid(Liquids.water, 7.2f);
|
||||
consumes.liquid(Liquids.water, 0.1f);
|
||||
|
||||
int liquidRegion = reg("-liquid"), topRegion = reg("-top"), bottomRegion = reg("-bottom");
|
||||
|
||||
@@ -1080,7 +1080,8 @@ public class Blocks implements ContentList{
|
||||
health = 700;
|
||||
powerProduction = 14f;
|
||||
consumes.item(Items.thorium);
|
||||
consumes.liquid(Liquids.cryofluid, 0.1f);
|
||||
heating = 0.02f;
|
||||
consumes.liquid(Liquids.cryofluid, 0.1f).update(false);
|
||||
}};
|
||||
|
||||
impactReactor = new ImpactReactor("impact-reactor"){{
|
||||
|
||||
@@ -63,6 +63,16 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
|
||||
unit.onSuperDeath();
|
||||
|
||||
//visual only.
|
||||
if(Net.client()){
|
||||
Tile tile = world.tile(unit.spawner);
|
||||
if(tile != null && !Net.client()){
|
||||
tile.block().unitRemoved(tile, unit);
|
||||
}
|
||||
|
||||
unit.spawner = noSpawner;
|
||||
}
|
||||
|
||||
//must run afterwards so the unit's group is not null when sending the removal packet
|
||||
Core.app.post(unit::remove);
|
||||
}
|
||||
@@ -280,7 +290,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||
public void removed(){
|
||||
super.removed();
|
||||
Tile tile = world.tile(spawner);
|
||||
if(tile != null){
|
||||
if(tile != null && !Net.client()){
|
||||
tile.block().unitRemoved(tile, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package io.anuke.mindustry.world;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Vector2;
|
||||
import io.anuke.arc.util.Log;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.content.Fx;
|
||||
@@ -62,6 +61,7 @@ public abstract class BlockStorage extends UnlockableContent{
|
||||
|
||||
/**Remove a stack from this inventory, and return the amount removed.*/
|
||||
public int removeStack(Tile tile, Item item, int amount){
|
||||
if(tile.entity == null || tile.entity.items == null) return 0;
|
||||
amount = Math.min(amount, tile.entity.items.get(item));
|
||||
tile.entity.noSleep();
|
||||
tile.entity.items.remove(item, amount);
|
||||
|
||||
@@ -16,15 +16,11 @@ import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.mindustry.ui.Bar;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.consumers.ConsumeItems;
|
||||
import io.anuke.mindustry.world.consumers.ConsumeLiquid;
|
||||
import io.anuke.mindustry.world.consumers.ConsumeType;
|
||||
import io.anuke.mindustry.world.consumers.*;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.StatUnit;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package io.anuke.mindustry.world.blocks.production;
|
||||
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.consumers.ConsumeLiquidBase;
|
||||
import io.anuke.mindustry.world.consumers.ConsumeType;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
|
||||
public class LiquidConverter extends GenericCrafter{
|
||||
|
||||
public LiquidConverter(String name){
|
||||
super(name);
|
||||
hasLiquids = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
ConsumeLiquidBase cl = consumes.get(ConsumeType.liquid);
|
||||
cl.update(true);
|
||||
outputLiquid.amount = cl.amount;
|
||||
super.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
stats.remove(BlockStat.output);
|
||||
stats.add(BlockStat.output, outputLiquid.liquid, outputLiquid.amount * craftTime, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
GenericCrafterEntity entity = tile.entity();
|
||||
ConsumeLiquidBase cl = consumes.get(ConsumeType.liquid);
|
||||
|
||||
if(tile.entity.cons.valid()){
|
||||
float use = Math.min(cl.amount * entity.delta(), liquidCapacity - entity.liquids.get(outputLiquid.liquid));
|
||||
if(hasPower){
|
||||
use *= entity.power.satisfaction; // Produce less liquid if power is not maxed
|
||||
}
|
||||
entity.progress += use / cl.amount / craftTime;
|
||||
entity.liquids.add(outputLiquid.liquid, use);
|
||||
if(entity.progress >= 1f){
|
||||
entity.cons.trigger();
|
||||
entity.progress = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
tryDumpLiquid(tile, outputLiquid.liquid);
|
||||
}
|
||||
}
|
||||
@@ -123,6 +123,7 @@ public class UnitFactory extends Block{
|
||||
public void unitRemoved(Tile tile, Unit unit){
|
||||
UnitFactoryEntity entity = tile.entity();
|
||||
entity.spawned --;
|
||||
entity.spawned = Math.max(entity.spawned, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user