Class CustomWebPath


  • public class CustomWebPath
    extends java.lang.Object
    CustomWebPath is a helper class that makes creating and attaching custom web nodes to our standard web nodes easier
    • Field Detail

      • startNode

        public int startNode
      • endNode

        public int endNode
    • Constructor Detail

      • CustomWebPath

        public CustomWebPath​(Tile... tiles)
        Creates a new BasicWebNode for each Tile with two way connections between each node
        Parameters:
        tiles - Tiles to add to the custom web path
      • CustomWebPath

        public CustomWebPath​(boolean connect,
                             AbstractWebNode... nodes)
        Adds each web node to this custom web node path If connect is true, each node will have a two way connection to the previous node
        Parameters:
        connect - If True will add two way connections, if False the connection will be one way from previous to current
        nodes - AbstractWebNode nodes to add to this path
    • Method Detail

      • addNode

        public void addNode​(AbstractWebNode node,
                            boolean twoWay)
        Adds a web node to the end of this path's list. If twoWay is true, it will do a two way connection to the previous node.
        Parameters:
        node - AbstractWebNode to add to the end of the list
        twoWay - boolean whether the connection should be two way or one way
      • connectToStart

        public void connectToStart​(int nodeIndex)
        This will connect the start of this path to the provided node index when attachToWeb() or WebFinder.addCustomWebPath(CustomWebPath) is called for this path This will NOT add this path to the full global web.
        Parameters:
        nodeIndex - The index of the AbstractWebNode to attach this path to
      • connectStartToClosestNode

        public boolean connectStartToClosestNode()
        This will connect the start of this path to the nearest BasicWebNode when attachToWeb() or WebFinder.addCustomWebPath(CustomWebPath) is called for this path This will NOT cadd this path to the full global web.
        Returns:
        true if there's a node within 32 tiles to attach it to, false otherwise
      • connectEndToClosestNode

        public boolean connectEndToClosestNode()
        This will connect the end of this path to the nearest BasicWebNode when attachToWeb() or WebFinder.addCustomWebPath(CustomWebPath) is called

        Note: This should only be called after all web nodes are added, otherwise it'll attach at the wrong point in your custom path This will NOT add this path to the full global web.

        Returns:
        true if there's a node within 32 tiles to attach it to, false otherwise
      • connectToEnd

        public void connectToEnd​(int nodeIndex)
        This will connect the end of this path to the provided node index when attachToWeb() or WebFinder.addCustomWebPath(CustomWebPath) is called for this path This will NOT connect this path to the full global web
        Parameters:
        nodeIndex - The index of the AbstractWebNode to attach this path to
      • attachToWeb

        public void attachToWeb()
        Attaches this custom web path into the global web
      • attachToWeb

        public boolean attachToWeb​(boolean attachStart,
                                   boolean attachEnd)
        Attaches this custom web path into the global web Will automatically call connectStartToClosestNode() and connectEndToClosestNode() based on the parameters passed
        Parameters:
        attachStart -
        attachEnd -
        Returns:
        False if attach start is requested and fails, false if attach end is requested and fails, else true