1package com.runehive.game.world.entity.mob.movement;
3import com.runehive.game.world.Interactable;
4import com.runehive.game.world.entity.mob.Direction;
5import com.runehive.game.world.entity.mob.Mob;
6import com.runehive.game.world.entity.mob.data.PacketType;
7import com.runehive.game.world.pathfinding.distance.Manhattan;
8import com.runehive.game.world.pathfinding.path.Path;
9import com.runehive.game.world.pathfinding.path.impl.AStarPathFinder;
10import com.runehive.game.world.pathfinding.path.impl.DijkstraPathFinder;
11import com.runehive.game.world.pathfinding.path.impl.SimplePathFinder;
12import com.runehive.game.world.position.Position;
13import com.runehive.net.packet.out.SendConfig;
14import com.runehive.net.packet.out.HintArrowTile;
15import com.runehive.net.packet.out.HintArrowClear;
17import java.util.ArrayDeque;
18import java.util.Deque;
42 private Deque<Point>
waypoints =
new ArrayDeque<>();
78 final int newX =
mob.getX() + x;
79 final int newY =
mob.getY() + y;
125 int diffX = x - last.
x;
126 int diffY = y - last.
y;
127 int max = Math.max(Math.abs(diffX), Math.abs(diffY));
128 for (
int i = 0; i < max; i++) {
131 }
else if (diffX > 0) {
136 }
else if (diffY > 0) {
152 int diffX = x - last.
x;
153 int diffY = y - last.
y;
161 boolean teleporting = mob.teleportTarget !=
null;
164 mob.positionChange =
true;
165 mob.setPosition(
mob.teleportTarget);
166 mob.clearTeleportTarget();
168 Point walkPoint, runPoint =
null;
175 int walkDir = walkPoint ==
null ? -1 : walkPoint.
dir;
176 int runDir = runPoint ==
null ? -1 : runPoint.
dir;
179 this.walkingDirection = walkDir;
180 this.runningDirection = runDir;
182 int diffX =
mob.getPosition().getLocalX(
mob.lastPosition);
183 int diffY =
mob.getPosition().getLocalY(
mob.lastPosition);
184 boolean changed =
false;
187 }
else if (diffX >= 88) {
192 }
else if (diffY >= 88) {
196 mob.regionChange =
true;
207 if (p ==
null || p.
dir == -1) {
214 mob.setPosition(
mob.getPosition().transform(diffX, diffY));
222 boolean noMoreSteps =
waypoints.isEmpty();
223 if (arrived || noMoreSteps) {
340 if (last ==
null)
return null;
boolean dijkstraPath(Position destination)
Finds a medium path to the target.
void walkTo(Position position)
Handles mob walking to a certain position.
void walk(Position position)
Walks to a certain position.
Deque< Point > waypoints
The queue of waypoints.
void addStepInternal(int x, int y)
Adds a single step to the queue internally without counting gaps.
void finish()
Removes the first waypoint which is only used for calculating directions.
Direction lastDirection
The last direction the mob walked in.
boolean runQueue
Run for this queue (CTRL-CLICK) toggle.
Position peekDestination()
boolean aStarPath(Position destination)
Finds a smart path to the target.
Position destinationHint
Destination hint-arrow state.
boolean simplePath(Position destination)
Finds a smart path to the target.
boolean isRunning()
Checks if any running flag is set.
void setRunningToggled(boolean runToggled)
Sets the run toggled flag.
AStarPathFinder getSmartPathFinder()
boolean runToggled
Run toggle (button in client).
static final SimplePathFinder SIMPLE_PATH_FINDER
The smart path finder.
void onRegionChange()
Re-emit hint arrow on region change.
Point getNextPoint()
Gets the next point of movement.
boolean addPath(Path path)
Finds a smart path to the target.
void walkTo(int x, int y)
Handles mob walking to certain coordinates.
static final DijkstraPathFinder DIJKSTRA_PATH_FINDER
The smart path finder.
boolean dijkstraPath(Interactable interactable)
Finds a medium path to the target.
boolean aStarPath(Interactable interactable)
Finds a smart path to the target.
void setRunningQueue(boolean runQueue)
Sets the run queue flag.
void processNextMovement()
Processes the next player's movement.
boolean isRunningToggled()
Gets the run toggled flag.
void reset()
Resets the walking queue so it contains no more steps.
boolean isMoving
Mob is moving.
Movement(Mob mob)
Creates the WalkingQueue for the specified.
void addStep(int x, int y)
Adds a single step to the walking queue, filling in the points to the previous point in the queue if ...
final AStarPathFinder smartPathFinder
The smart path finder.
boolean simplePath(Interactable interactable)
Finds a smart path to the target.
static final int MAXIMUM_SIZE
The maximum size of the queue.
boolean isRunningQueue()
Gets the running queue flag.
int getWalkingDirection()
int getRunningDirection()
Represents a single point in the queue.
final int y
The y-coordinate.
final int x
The x-coordinate.
final int dir
The direction to walk to this point.
The Manhattan Distance is the distance between two points measured along axes at right angles.
Represents a single path in the path finding system.
void addSteps(final Movement movement)
boolean isPossible()
Gets the condition if the path is possible.
Represents a PathFinder which uses the A* search algorithm(by passingobstacles).
Represents a simple path finder which determines a straight path to the first blocked tile or it's de...
Represents a single tile on the game world.
void execute(Player player)
Clears any active hint arrow (317 opcode 254, type=0).
Shows the flashing yellow hint arrow pointing at a world tile (317 opcode 254, type=2).
The OutgoingPacket responsible for changing settings on a client.
Represents the enumerated directions an entity can walk or face.
static final byte[] DELTA_Y
Difference in Y coordinates for directions array.
static int direction(int dx, int dy)
static final ImmutableList< Direction > DIRECTIONS
static final byte[] DELTA_X
Difference in X coordinates for directions array.
An object implementing Interactable has uses.