74 Deque<Position> positions =
new ArrayDeque<>(approximation);
75 return new Path(addWalks(source, end, targetWidth, targetLength, positions));
87 private Deque<Position> addWalks(
Mob source,
Position target,
int targetWidth,
int targetLength, Deque<Position> positions) {
92 if (targetWidth > 0 || targetLength > 0)
93 target =
Utility.findBestInside(source, targInt);
95 boolean projectiles = source.pathfinderProjectiles;
97 while (!
Region.reachable(targ, targetWidth, targetLength, current, source.
width(), source.
length())) {
98 Direction direction = getDirection(current, target);
100 if (!traversable(source, current, targInt, direction, projectiles)) {
102 if (traversable(source, current, targInt,
Direction.WEST, projectiles)) {
104 }
else if (traversable(source, current, targInt,
Direction.NORTH, projectiles)) {
108 }
else if (direction == Direction.NORTH_EAST) {
109 if (traversable(source, current, targInt, Direction.NORTH, projectiles)) {
110 direction = Direction.NORTH;
111 }
else if (traversable(source, current, targInt, Direction.EAST, projectiles)) {
112 direction = Direction.EAST;
115 }
else if (direction == Direction.SOUTH_WEST) {
116 if (traversable(source, current, targInt, Direction.SOUTH, projectiles)) {
117 direction = Direction.SOUTH;
118 }
else if (traversable(source, current, targInt, Direction.WEST, projectiles)) {
119 direction = Direction.WEST;
122 }
else if (direction == Direction.SOUTH_EAST) {
123 if (traversable(source, current, targInt, Direction.SOUTH, projectiles)) {
124 direction = Direction.SOUTH;
125 }
else if (traversable(source, current, targInt, Direction.EAST, projectiles)) {
126 direction = Direction.EAST;
133 if (direction == NONE)
136 current = current.
transform(direction.getFaceLocation());
137 positions.addLast(current);
142 private boolean traversable(Mob source, Position current, Interactable target, Direction direction,
boolean projectiles) {
143 Position next = current.transform(direction.getFaceLocation());
144 return (projectiles ?
projectileCheck(current, next) : traversable(current, source.width(), direction))
145 && !Utility.inside(next, source.width(), source.length(), target.getPosition(), target.width(), target.length());