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;
}
}
Aggregations