Search in sources :

Example 1 with IZone

use of buildcraft.api.core.IZone in project LogisticsPipes by RS485.

the class LPRobotConnectionControl method isModified.

public boolean isModified(LogisticsRoutingBoardRobot board) {
    Set<Pair<DoubleCoordinates, ForgeDirection>> localConnectedRobots = new HashSet<>();
    DoubleCoordinates sourceRobotPosition = CoordinateUtils.add(board.getLinkedStationPosition().center(), board.robot.getLinkedStation().side(), 0.5);
    IZone zone = board.robot.getZoneToWork();
    for (Pair<DoubleCoordinates, ForgeDirection> canidatePos : globalAvailableRobots.get(board.robot.worldObj)) {
        DoubleCoordinates canidateRobotPosition = CoordinateUtils.add(new DoubleCoordinates(canidatePos.getValue1()).center(), canidatePos.getValue2(), 0.5);
        double distance = canidateRobotPosition.distanceTo(sourceRobotPosition);
        boolean isPartOfZone;
        if (zone != null) {
            isPartOfZone = zone.contains(canidateRobotPosition.getXCoord(), canidateRobotPosition.getYCoord(), canidateRobotPosition.getZCoord());
        } else {
            isPartOfZone = distance < Configs.MAX_ROBOT_DISTANCE;
        }
        if (isPartOfZone) {
            localConnectedRobots.add(canidatePos);
        }
    }
    if (board.getConnectionDetails().localConnectedRobots.equals(localConnectedRobots)) {
        return false;
    } else {
        board.getConnectionDetails().localConnectedRobots.clear();
        board.getConnectionDetails().localConnectedRobots.addAll(localConnectedRobots);
        return true;
    }
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IZone(buildcraft.api.core.IZone) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) HashSet(java.util.HashSet) Pair(logisticspipes.utils.tuples.Pair)

Aggregations

IZone (buildcraft.api.core.IZone)1 HashSet (java.util.HashSet)1 Pair (logisticspipes.utils.tuples.Pair)1 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)1