use of org.apollo.game.model.area.collision.CollisionManager in project apollo by apollo-rsps.
the class WalkingQueue method pulse.
/**
* Pulses this WalkingQueue.
*/
public void pulse() {
Position position = mob.getPosition();
int height = position.getHeight();
Direction firstDirection = Direction.NONE;
Direction secondDirection = Direction.NONE;
World world = mob.getWorld();
CollisionManager collisionManager = world.getCollisionManager();
Position next = points.poll();
if (next != null) {
firstDirection = Direction.between(position, next);
if (!collisionManager.traversable(position, EntityType.NPC, firstDirection)) {
clear();
firstDirection = Direction.NONE;
} else {
previousPoints.add(next);
position = new Position(next.getX(), next.getY(), height);
mob.setLastDirection(firstDirection);
if (running) {
next = points.poll();
if (next != null) {
secondDirection = Direction.between(position, next);
if (!collisionManager.traversable(position, EntityType.NPC, secondDirection)) {
clear();
secondDirection = Direction.NONE;
} else {
previousPoints.add(next);
position = new Position(next.getX(), next.getY(), height);
mob.setLastDirection(secondDirection);
}
}
}
}
}
mob.setDirections(firstDirection, secondDirection);
mob.setPosition(position);
}
Aggregations