mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-12 19:09:34 +07:00
Added liquid tunnel recipe, fixed crashes/bugs
This commit is contained in:
parent
9b3c9aaea2
commit
992fcc73b8
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.
|
||||
#Sat Mar 03 23:20:20 EST 2018
|
||||
#Sun Mar 04 00:17:03 EST 2018
|
||||
version=release
|
||||
androidBuildCode=344
|
||||
androidBuildCode=348
|
||||
name=Mindustry
|
||||
code=3.4
|
||||
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.liquidrouter, 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.fluxpump, stack(Item.steel, 10), stack(Item.dirium, 5)),
|
||||
|
@ -57,6 +57,9 @@ public class DistributionBlocks{
|
||||
|
||||
}},
|
||||
tunnel = new TunnelConveyor("conveyortunnel"){{
|
||||
}},
|
||||
conduittunnel = new TunnelConduit("conduittunnel"){{
|
||||
|
||||
}},
|
||||
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)){
|
||||
tryMoveLiquid(tile, tile.getNearby(tile.getRotation()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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.world.Tile;
|
||||
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 {
|
||||
protected int maxdist = 3;
|
||||
@ -11,18 +13,23 @@ public class TunnelConduit extends Conduit {
|
||||
protected TunnelConduit(String name) {
|
||||
super(name);
|
||||
rotate = true;
|
||||
update = false;
|
||||
solid = true;
|
||||
health = 70;
|
||||
instantTransfer = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
Draw.rect(name, tile.drawx(), tile.drawy(), tile.getRotation() * 90);
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
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();
|
||||
|
||||
@ -31,31 +38,27 @@ public class TunnelConduit extends Conduit {
|
||||
|
||||
@Override
|
||||
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);
|
||||
if (rot != (tile.getRotation() + 2) % 4) return false;
|
||||
Tile tunnel = getDestTunnel(tile, liquid, amount);
|
||||
Tile tunnel = getDestTunnel(tile);
|
||||
|
||||
if (tunnel != null) {
|
||||
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 {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Tile getDestTunnel(Tile tile, Liquid liquid, float amount) {
|
||||
Tile getDestTunnel(Tile tile) {
|
||||
Tile dest = tile;
|
||||
int rel = (tile.getRotation() + 2) % 4;
|
||||
for (int i = 0; i < maxdist; i++) {
|
||||
if (dest == null) return null;
|
||||
dest = dest.getNearby(rel);
|
||||
if (dest != null && dest.block() instanceof TunnelConduit && dest.getRotation() == rel
|
||||
&& dest.getNearby(rel) != null
|
||||
&& ((TunnelConduit) dest.getNearby(rel).block()).acceptLiquid(dest.getNearby(rel), dest, liquid, amount)) {
|
||||
&& dest.getNearby(rel) != null) {
|
||||
return dest;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user