Search in sources :

Example 1 with IFluidSink

use of logisticspipes.interfaces.routing.IFluidSink in project LogisticsPipes by RS485.

the class LogisticsFluidManager method getBestReply.

@Override
public Pair<Integer, Integer> getBestReply(FluidStack stack, IRouter sourceRouter, List<Integer> jamList) {
    for (ExitRoute candidateRouter : sourceRouter.getIRoutersByCost()) {
        if (!candidateRouter.containsFlag(PipeRoutingConnectionType.canRouteTo)) {
            continue;
        }
        if (candidateRouter.destination.getSimpleID() == sourceRouter.getSimpleID()) {
            continue;
        }
        if (jamList.contains(candidateRouter.destination.getSimpleID())) {
            continue;
        }
        if (candidateRouter.destination.getPipe() == null || !candidateRouter.destination.getPipe().isEnabled()) {
            continue;
        }
        CoreRoutedPipe pipe = candidateRouter.destination.getPipe();
        if (!(pipe instanceof IFluidSink)) {
            continue;
        }
        int amount = ((IFluidSink) pipe).sinkAmount(stack);
        if (amount > 0) {
            Pair<Integer, Integer> result = new Pair<>(candidateRouter.destination.getSimpleID(), amount);
            return result;
        }
    }
    Pair<Integer, Integer> result = new Pair<>(0, 0);
    return result;
}
Also used : IFluidSink(logisticspipes.interfaces.routing.IFluidSink) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) ExitRoute(logisticspipes.routing.ExitRoute) Pair(logisticspipes.utils.tuples.Pair)

Aggregations

IFluidSink (logisticspipes.interfaces.routing.IFluidSink)1 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)1 ExitRoute (logisticspipes.routing.ExitRoute)1 Pair (logisticspipes.utils.tuples.Pair)1