Added LiquidDrill

This commit is contained in:
Anuken
2018-03-09 10:09:32 -05:00
parent 3131e8c7e9
commit c46f1ec590
7 changed files with 40 additions and 9 deletions

Before

Width:  |  Height:  |  Size: 383 B

After

Width:  |  Height:  |  Size: 383 B

+2 -2
View File
@@ -1,7 +1,7 @@
#Autogenerated file. Do not modify. #Autogenerated file. Do not modify.
#Thu Mar 08 21:56:36 EST 2018 #Thu Mar 08 23:00:40 EST 2018
version=release version=release
androidBuildCode=409 androidBuildCode=412
name=Mindustry name=Mindustry
code=3.4 code=3.4
build=custom build build=custom build
@@ -1,9 +1,6 @@
package io.anuke.mindustry.core; package io.anuke.mindustry.core;
import com.badlogic.gdx.utils.ByteArray; import com.badlogic.gdx.utils.*;
import com.badlogic.gdx.utils.IntMap;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.TimeUtils;
import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.SyncEntity; import io.anuke.mindustry.entities.SyncEntity;
@@ -65,7 +65,7 @@ public class Recipes {
new Recipe(production, ProductionBlocks.titaniumdrill, stack(Item.iron, 50), stack(Item.steel, 50)), new Recipe(production, ProductionBlocks.titaniumdrill, stack(Item.iron, 50), stack(Item.steel, 50)),
new Recipe(production, ProductionBlocks.uraniumdrill, stack(Item.iron, 40), stack(Item.steel, 40)), new Recipe(production, ProductionBlocks.uraniumdrill, stack(Item.iron, 40), stack(Item.steel, 40)),
new Recipe(production, ProductionBlocks.quartzextractor, stack(Item.titanium, 40), stack(Item.dirium, 40)), new Recipe(production, ProductionBlocks.quartzextractor, stack(Item.titanium, 40), stack(Item.dirium, 40)),
new Recipe(production, ProductionBlocks.biomatterextractor, stack(Item.titanium, 40), stack(Item.dirium, 40)), new Recipe(production, ProductionBlocks.cultivator, stack(Item.titanium, 40), stack(Item.dirium, 40)),
new Recipe(production, ProductionBlocks.laserdrill, stack(Item.titanium, 40), stack(Item.dirium, 40)), new Recipe(production, ProductionBlocks.laserdrill, stack(Item.titanium, 40), stack(Item.dirium, 40)),
new Recipe(power, ProductionBlocks.coalgenerator, stack(Item.iron, 30), stack(Item.stone, 20)), new Recipe(power, ProductionBlocks.coalgenerator, stack(Item.iron, 30), stack(Item.stone, 20)),
@@ -216,10 +216,12 @@ public class ProductionBlocks{
} }
}, },
biomatterextractor = new Drill("biomatterextractor"){ cultivator = new LiquidDrill("cultivator"){
{ {
resource = Blocks.grass; resource = Blocks.grass;
result = Item.biomatter; result = Item.biomatter;
inputLiquid = Liquid.water;
inputLiquidAmount = 0.1f;
time = 5; time = 5;
size = 2; size = 2;
} }
@@ -56,7 +56,7 @@ public class Teleporter extends PowerBlock{
TeleporterEntity entity = tile.entity(); TeleporterEntity entity = tile.entity();
if(entity != null){ if(entity != null){
entity.color = data; entity.color = data;
Arrays.fill(entity.items, 0); Arrays.fill(entity.inventory.items, 0);
} }
} }
@@ -0,0 +1,32 @@
package io.anuke.mindustry.world.blocks.types.production;
import io.anuke.mindustry.resource.Liquid;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Timers;
/**A drill that uses liquid as fuel.*/
public class LiquidDrill extends Drill {
protected Liquid inputLiquid = Liquid.water;
protected float inputLiquidAmount = 0.1f; //per frame
public LiquidDrill(String name){
super(name);
hasLiquids = true;
}
@Override
public void update(Tile tile){
float consume = Math.min(liquidCapacity, inputLiquidAmount * Timers.delta());
if(tile.entity.liquid.amount >= consume){
tile.entity.liquid.amount -= consume;
super.update(tile);
}
}
@Override
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount) {
return super.acceptLiquid(tile, source, liquid, amount) && liquid == inputLiquid;
}
}