Search in sources :

Example 1 with LiquidBlock

use of io.anuke.mindustry.world.blocks.types.LiquidBlock in project Mindustry by Anuken.

the class LiquidJunction method handleLiquid.

@Override
public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount) {
    int dir = source.relativeTo(tile.x, tile.y);
    dir = (dir + 4) % 4;
    Tile to = tile.getNearby(dir);
    Timers.run(20f, () -> {
        if (to.block() instanceof LiquidBlock && ((LiquidBlock) to.block()).acceptLiquid(to, tile, liquid, amount))
            ((LiquidBlock) to.block()).handleLiquid(to, tile, liquid, amount);
    });
}
Also used : Tile(io.anuke.mindustry.world.Tile) LiquidBlock(io.anuke.mindustry.world.blocks.types.LiquidBlock)

Example 2 with LiquidBlock

use of io.anuke.mindustry.world.blocks.types.LiquidBlock in project Mindustry by Anuken.

the class LiquidJunction method acceptLiquid.

@Override
public boolean acceptLiquid(Tile dest, Tile source, Liquid liquid, float amount) {
    int dir = source.relativeTo(dest.x, dest.y);
    dir = (dir + 4) % 4;
    Tile to = dest.getNearby(dir);
    return to != null && to.block() instanceof LiquidBlock && ((LiquidBlock) to.block()).acceptLiquid(to, dest, liquid, amount);
}
Also used : Tile(io.anuke.mindustry.world.Tile) LiquidBlock(io.anuke.mindustry.world.blocks.types.LiquidBlock)

Aggregations

Tile (io.anuke.mindustry.world.Tile)2 LiquidBlock (io.anuke.mindustry.world.blocks.types.LiquidBlock)2