Added liquid tunnel recipe, fixed crashes/bugs
This commit is contained in:
BIN
core/assets-raw/sprites/blocks/tech/conduittunnel.png
Normal file
BIN
core/assets-raw/sprites/blocks/tech/conduittunnel.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 224 B |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
@@ -1,7 +1,7 @@
|
|||||||
#Autogenerated file. Do not modify.
|
#Autogenerated file. Do not modify.
|
||||||
#Sat Mar 03 23:20:20 EST 2018
|
#Sun Mar 04 00:17:03 EST 2018
|
||||||
version=release
|
version=release
|
||||||
androidBuildCode=344
|
androidBuildCode=348
|
||||||
name=Mindustry
|
name=Mindustry
|
||||||
code=3.4
|
code=3.4
|
||||||
build=custom build
|
build=custom build
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ public class Recipes {
|
|||||||
new Recipe(liquid, DistributionBlocks.pulseconduit, stack(Item.titanium, 1), stack(Item.steel, 1)),
|
new Recipe(liquid, DistributionBlocks.pulseconduit, stack(Item.titanium, 1), stack(Item.steel, 1)),
|
||||||
new Recipe(liquid, DistributionBlocks.liquidrouter, stack(Item.steel, 2)),
|
new Recipe(liquid, DistributionBlocks.liquidrouter, stack(Item.steel, 2)),
|
||||||
new Recipe(liquid, DistributionBlocks.liquidjunction, stack(Item.steel, 2)),
|
new Recipe(liquid, DistributionBlocks.liquidjunction, stack(Item.steel, 2)),
|
||||||
|
new Recipe(liquid, DistributionBlocks.conduittunnel, stack(Item.titanium, 2), stack(Item.steel, 2)),
|
||||||
|
|
||||||
new Recipe(liquid, ProductionBlocks.pump, stack(Item.steel, 10)),
|
new Recipe(liquid, ProductionBlocks.pump, stack(Item.steel, 10)),
|
||||||
new Recipe(liquid, ProductionBlocks.fluxpump, stack(Item.steel, 10), stack(Item.dirium, 5)),
|
new Recipe(liquid, ProductionBlocks.fluxpump, stack(Item.steel, 10), stack(Item.dirium, 5)),
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ public class DistributionBlocks{
|
|||||||
|
|
||||||
}},
|
}},
|
||||||
tunnel = new TunnelConveyor("conveyortunnel"){{
|
tunnel = new TunnelConveyor("conveyortunnel"){{
|
||||||
|
}},
|
||||||
|
conduittunnel = new TunnelConduit("conduittunnel"){{
|
||||||
|
|
||||||
}},
|
}},
|
||||||
liquidjunction = new LiquidJunction("liquidjunction"){{
|
liquidjunction = new LiquidJunction("liquidjunction"){{
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ public class LiquidBlock extends Block implements LiquidAcceptor{
|
|||||||
if(entity.liquidAmount > 0.01f && entity.timer.get(timerFlow, 1)){
|
if(entity.liquidAmount > 0.01f && entity.timer.get(timerFlow, 1)){
|
||||||
tryMoveLiquid(tile, tile.getNearby(tile.getRotation()));
|
tryMoveLiquid(tile, tile.getNearby(tile.getRotation()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tryDumpLiquid(Tile tile){
|
public void tryDumpLiquid(Tile tile){
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package io.anuke.mindustry.world.blocks.types.distribution;
|
|||||||
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.LiquidAcceptor;
|
import io.anuke.mindustry.world.blocks.types.LiquidAcceptor;
|
||||||
|
import io.anuke.ucore.graphics.Draw;
|
||||||
|
import io.anuke.ucore.util.Log;
|
||||||
|
|
||||||
public class TunnelConduit extends Conduit {
|
public class TunnelConduit extends Conduit {
|
||||||
protected int maxdist = 3;
|
protected int maxdist = 3;
|
||||||
@@ -11,18 +13,23 @@ public class TunnelConduit extends Conduit {
|
|||||||
protected TunnelConduit(String name) {
|
protected TunnelConduit(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
rotate = true;
|
rotate = true;
|
||||||
update = false;
|
|
||||||
solid = true;
|
solid = true;
|
||||||
health = 70;
|
health = 70;
|
||||||
instantTransfer = true;
|
instantTransfer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Tile tile){
|
||||||
|
Draw.rect(name, tile.drawx(), tile.drawy(), tile.getRotation() * 90);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount) {
|
public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount) {
|
||||||
Tile tunnel = getDestTunnel(tile, liquid, amount);
|
Log.info("handle");
|
||||||
|
Tile tunnel = getDestTunnel(tile);
|
||||||
if (tunnel == null) return;
|
if (tunnel == null) return;
|
||||||
Tile to = tunnel.getNearby(tunnel.getRotation());
|
Tile to = tunnel.getNearby(tunnel.getRotation());
|
||||||
if (to == null || !(to instanceof LiquidAcceptor)) return;
|
if (to == null || !(to.block() instanceof LiquidAcceptor)) return;
|
||||||
|
|
||||||
LiquidAcceptor a = (LiquidAcceptor) to.block();
|
LiquidAcceptor a = (LiquidAcceptor) to.block();
|
||||||
|
|
||||||
@@ -31,31 +38,27 @@ public class TunnelConduit extends Conduit {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount) {
|
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount) {
|
||||||
TunnelConveyor.TunnelEntity entity = tile.entity();
|
|
||||||
|
|
||||||
if (entity.index >= entity.buffer.length - 1) return false;
|
|
||||||
|
|
||||||
int rot = source.relativeTo(tile.x, tile.y);
|
int rot = source.relativeTo(tile.x, tile.y);
|
||||||
if (rot != (tile.getRotation() + 2) % 4) return false;
|
if (rot != (tile.getRotation() + 2) % 4) return false;
|
||||||
Tile tunnel = getDestTunnel(tile, liquid, amount);
|
Tile tunnel = getDestTunnel(tile);
|
||||||
|
|
||||||
if (tunnel != null) {
|
if (tunnel != null) {
|
||||||
Tile to = tunnel.getNearby(tunnel.getRotation());
|
Tile to = tunnel.getNearby(tunnel.getRotation());
|
||||||
return to != null && (to instanceof LiquidAcceptor) && ((LiquidAcceptor) to.block()).acceptLiquid(to, tunnel, liquid, amount);
|
return to != null && (to.block() instanceof LiquidAcceptor) &&
|
||||||
|
((LiquidAcceptor) to.block()).acceptLiquid(to, tunnel, liquid, amount);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Tile getDestTunnel(Tile tile, Liquid liquid, float amount) {
|
Tile getDestTunnel(Tile tile) {
|
||||||
Tile dest = tile;
|
Tile dest = tile;
|
||||||
int rel = (tile.getRotation() + 2) % 4;
|
int rel = (tile.getRotation() + 2) % 4;
|
||||||
for (int i = 0; i < maxdist; i++) {
|
for (int i = 0; i < maxdist; i++) {
|
||||||
if (dest == null) return null;
|
if (dest == null) return null;
|
||||||
dest = dest.getNearby(rel);
|
dest = dest.getNearby(rel);
|
||||||
if (dest != null && dest.block() instanceof TunnelConduit && dest.getRotation() == rel
|
if (dest != null && dest.block() instanceof TunnelConduit && dest.getRotation() == rel
|
||||||
&& dest.getNearby(rel) != null
|
&& dest.getNearby(rel) != null) {
|
||||||
&& ((TunnelConduit) dest.getNearby(rel).block()).acceptLiquid(dest.getNearby(rel), dest, liquid, amount)) {
|
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user