Class WebFinder


  • public class WebFinder
    extends java.lang.Object
    Web pathfinding class, generally shouldn't need to be accessed directly
    • Method Detail

      • getWebFinder

        public static WebFinder getWebFinder()
      • loadWebNodes

        public static void loadWebNodes()
      • isLoaded

        public static boolean isLoaded()
        Checks if the base web nodes have been loaded into the client
        Returns:
        true if loaded, false if still loading
      • calculate

        public GlobalPath<AbstractWebNode> calculate​(AbstractWebNode start,
                                                     AbstractWebNode destination,
                                                     int maxDepth)
        Calculates a web path with a given start node, destination node, and a maximum depth
        Parameters:
        start - Starting node
        destination - Destination node
        maxDepth - Maximum depth, -1 if no max
        Returns:
        GlobalPath if found, null if not found or maximum depth reached
      • disableTeleport

        public void disableTeleport​(Teleport teleport)
        Disables a teleport from being used in the pathfinder
        Parameters:
        teleport - the Teleport to disable
      • enableTeleport

        public void enableTeleport​(Teleport teleport)
        Re-enables a previously disabled teleport to be used in the pathfinder
        Parameters:
        teleport - the Teleport to re-enable
      • disableWebNodeType

        public void disableWebNodeType​(WebNodeType type)
        Disables a type of web nodes from being used in the pathfinder
        Parameters:
        type - the WebNodeType to disable
      • enableWebNodeType

        public void enableWebNodeType​(WebNodeType type)
        Re-enables a previously disabled type of web nodes to be used in the pathfinder
        Parameters:
        type - the WebNodeType to re-enable
      • canUseInventoryTeleports

        public boolean canUseInventoryTeleports()
      • canUseEquipmentTeleports

        public boolean canUseEquipmentTeleports()
      • disableInventoryTeleports

        public void disableInventoryTeleports()
      • enableInventoryTeleports

        public void enableInventoryTeleports()
      • disableEquipmentTeleports

        public void disableEquipmentTeleports()
      • enableEquipmentTeleports

        public void enableEquipmentTeleports()
      • getNearest

        public AbstractWebNode getNearest​(AbstractWebNode target)
        Gets the closest basic web (default 5 tile threshold) node for the given argument.

        Note: This method will only return BasicWebNode's.

        Parameters:
        target - the target you wish to find the nearest web node of.
        Returns:
        the closest basic web node to the given tile if found, otherwise null.
      • getNearest

        public AbstractWebNode getNearest​(AbstractWebNode target,
                                          int threshold)
        Gets the closest basic web node to for given argument.

        Note: This method will only return BasicWebNode's.

        Parameters:
        target - the target you wish to find the nearest web node of.
        threshold - the threshold of search you would like to perform.
        Returns:
        the closest basic web node to the given tile if found, otherwise null.
      • getNearest

        public AbstractWebNode getNearest​(Tile target,
                                          int threshold)
        Gets the closest basic web node to for given argument.

        Note: This method will only return BasicWebNode's.

        Parameters:
        target - the target you wish to find the nearest web node of.
        threshold - the threshold of search you would like to perform.
        Returns:
        the closest basic web node to the given tile if found, otherwise null.
      • addNode

        public boolean addNode​(Tile newNodeTarget)
        Creates and adds a new BasicWebNode at the provided tile and connects it to the nearest web node in our web
        Parameters:
        newNodeTarget - The tile to create a BasicWebNode at
        Returns:
        true if successful
      • createAndAddNode

        public AbstractWebNode createAndAddNode​(Tile newNodeTarget)
        Creates and adds a new BasicWebNode at the provided tile and connects it to the nearest web node in our web
        Parameters:
        newNodeTarget - The tile to create a BasicWebNode at
        Returns:
        the created AbstractWebNode if it successfully finds a nearby node to connect to, null otherwise
      • getNodesWithin

        public java.util.ArrayList<AbstractWebNode> getNodesWithin​(int dist,
                                                                   Tile t)
      • removeNode

        public void removeNode​(int idx)
      • addCustomWebPath

        public void addCustomWebPath​(CustomWebPath customWebPath)
      • addBlacklistedNode

        public void addBlacklistedNode​(AbstractWebNode node)
      • clearBlacklist

        public void clearBlacklist()
      • clearCustomNodes

        public void clearCustomNodes()
      • addWebNode

        public void addWebNode​(AbstractWebNode node)
        This adds a custom web node to our standard web nodes without adding any connections automatically
        Parameters:
        node - The web node to add to our web
      • addWebNodes

        public void addWebNodes​(AbstractWebNode... nodes)
        This just calls addWebNode for each web node passed in
        Parameters:
        nodes - the web nodes to add
      • get

        public AbstractWebNode get​(int index)

        Returns the web node with the given index

        NOTE: You shouldn't be connecting to our web nodes using this method, as the index can change at any time. You should use getNearest(Tile, int) to find the correct node.

        Parameters:
        index - the index of the web node
        Returns:
        The web node if it exists, null if the nodes haven't been loaded or if it's not found
      • resetWebNodes

        public void resetWebNodes()
      • setPathRandomization

        public void setPathRandomization​(double randomization)
        Sets the randomization factor used when web pathfinding.

        A value of 0.0 will disable any randomization, and any positive value will allow for less optimal paths to be generated. The default value of this is 0.005 which allows for paths up to roughly 0.5% less optimal paths per web node.

        Parameters:
        randomization - the randomization factor from 0.00 to 1.00
      • getPathRandomization

        public double getPathRandomization()
      • getCurrentPathQuery

        public WebPathQuery getCurrentPathQuery()