Search in sources :

Example 1 with CollisionManager

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);
}
Also used : CollisionManager(org.apollo.game.model.area.collision.CollisionManager) Position(org.apollo.game.model.Position) World(org.apollo.game.model.World) Direction(org.apollo.game.model.Direction)

Aggregations

Direction (org.apollo.game.model.Direction)1 Position (org.apollo.game.model.Position)1 World (org.apollo.game.model.World)1 CollisionManager (org.apollo.game.model.area.collision.CollisionManager)1