All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.mathiewz.slick.util.pathfinding.navmesh.NavPath Maven / Gradle / Ivy

Go to download

The main purpose of this libraryis to modernize and maintain the slick2D library.

The newest version!
package com.github.mathiewz.slick.util.pathfinding.navmesh;

import java.util.ArrayList;

/**
 * A path across a navigation mesh
 *
 * @author kevin
 */
public class NavPath {
    /** The list of links that form this path */
    private final ArrayList links = new ArrayList<>();

    /**
     * Create a new path
     */
    public NavPath() {
    }

    /**
     * Push a link to the end of the path
     *
     * @param link
     *            The link to the end of the path
     */
    public void push(Link link) {
        links.add(link);
    }

    /**
     * Get the length of the path
     *
     * @return The number of steps in the path
     */
    public int length() {
        return links.size();
    }

    /**
     * Get the x coordinate of the given step
     *
     * @param step
     *            The index of the step to retrieve
     * @return The x coordinate at the given step index
     */
    public float getX(int step) {
        return links.get(step).getX();
    }

    /**
     * Get the y coordinate of the given step
     *
     * @param step
     *            The index of the step to retrieve
     * @return The y coordinate at the given step index
     */
    public float getY(int step) {
        return links.get(step).getY();
    }

    /**
     * Get a string representation of this instance
     *
     * @return The string representation of this instance
     */
    @Override
    public String toString() {
        return "[Path length=" + length() + "]";
    }

    /**
     * Remove a step in the path
     *
     * @param i
     */
    public void remove(int i) {
        links.remove(i);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy