@Override public Array<Connection<TileCoordinate>> getConnections(final TileCoordinate fromNode) { Array<Connection<TileCoordinate>> array = new Array<>(); if (!isCollision(null, fromNode.getAbove())) { array.add(new DefaultConnection<>(getCachedNode(fromNode), getCachedNode(fromNode.getAbove()))); } if (!isCollision(null, fromNode.getBelow())) { array.add(new DefaultConnection<>(getCachedNode(fromNode), getCachedNode(fromNode.getBelow()))); } if (!isCollision(null, fromNode.getLeft())) { array.add(new DefaultConnection<>(getCachedNode(fromNode), getCachedNode(fromNode.getLeft()))); } if (!isCollision(null, fromNode.getRight())) { array.add(new DefaultConnection<>(getCachedNode(fromNode), getCachedNode(fromNode.getRight()))); } return array; }
@Override public Array<Connection<GridNode>> getConnections() { if (neighbours == null) { neighbours = new Array<>(8); for (int dir = 0; dir <= 7; dir++) { final int xx = x + xOff[dir]; final int yy = y + yOff[dir]; if (xx >= 0 && yy >= 0 && xx < graph.width && yy < graph.height && graph.nodes[yy][xx] != null) neighbours.add(new GridConnection<GridNode>(this, graph.nodes[yy][xx], (xOff[dir] == 0 || yOff[dir] == 0 ? 1f : 1.414f) * 10f)); } } return neighbours; }
public TileCoordinate getNextTarget(final TileCoordinate location, final TileCoordinate destination) { final GraphPath<Connection<TileCoordinate>> path = new DefaultGraphPath<>(); pathFinder.searchConnectionPath( graph.getCachedNode(location), graph.getCachedNode(destination), heuristic, path ); return path.getCount() == 0 ? null : path.get(0).getToNode(); }
@Override public boolean searchConnectionPath (N startNode, N endNode, Heuristic<N> heuristic, GraphPath<Connection<N>> outPath) { // Perform AStar boolean found = search(startNode, endNode, heuristic); if (found) { // Create a path made of connections generateConnectionPath(startNode, outPath); } return found; }
protected void generateConnectionPath (N startNode, GraphPath<Connection<N>> outPath) { // Work back along the path, accumulating connections // outPath.clear(); while (current.node != startNode) { outPath.add(current.connection); current = nodeRecords[graph.getIndex(current.connection.getFromNode())]; } // Reverse the path outPath.reverse(); }
public MyNode(final int index, final int x, final int y,final String value, final int capacity) { this.index = index; this.x = x; this.y = y; this.value = value; this.connections = new Array<Connection<MyNode>>(capacity); }
public AStartPathFinding(AStarMap map) { this.map = map; this.pathfinder = new IndexedAStarPathFinder<Node>(createGraph(map)); this.connectionPath = new DefaultGraphPath<Connection<Node>>(); this.heuristic = new Heuristic<Node>() { @Override public float estimate (Node node, Node endNode) { // Manhattan distance return Math.abs(endNode.x - node.x) + Math.abs(endNode.y - node.y); } }; }
public Node(AStarMap map, int x, int y) { this.x = x; this.y = y; this.index = x * map.getHeight() + y; this.isWall = false; this.connections = new Array<Connection<Node>>(); }
public Triangle(Vector3 a, Vector3 b, Vector3 c, int triIndex, int meshPartIndex) { this.a = a; this.b = b; this.c = c; this.triIndex = triIndex; this.meshPartIndex = meshPartIndex; this.centroid = new Vector3(a).add(b).add(c).scl(1f / 3f); this.connections = new Array<Connection<Triangle>>(); }
/**return nothing, as this isn't used*/ @Override public Array<Connection<Tile>> getConnections(Tile fromNode){ return null; }
public Array<Connection<Tile>> getContacts() { return contacts; }
@Override public Array<Connection<Tile>> getConnections(Tile fromNode) { return fromNode.getOwner() == owner ? fromNode.getContacts() : new Array<>(); }
public Array<Connection<MyNode>> getConnections() { return connections; }
@Override public Array<Connection<MyNode>> getConnections (MyNode fromNode) { return fromNode.getConnections(); }
public Array<Connection<MyNode>> getConnections () { return connections; }
@Override public Array<Connection<TestNode>> getConnections() { return mConnections; }
@Override public Array<Connection<Node>> getConnections(Node fromNode) { return fromNode.getConnections(); }
public Array<Connection<Node>> getConnections () { return connections; }
public FlatTiledNode (int x, int y, int type, int connectionCapacity) { super(x, y, type, new Array<Connection<FlatTiledNode>>(connectionCapacity)); }
public TiledNode (int x, int y, int type, Array<Connection<N>> connections) { this.x = x; this.y = y; this.type = type; this.connections = connections; }
@Override public Array<Connection<N>> getConnections () { return this.connections; }
@Override public Array<Connection<Node>> getConnections() { return connections; }
public Array<Connection<Triangle>> getConnections() { return connections; }
@Override @SuppressWarnings("unchecked") public Array<Connection<Triangle>> getConnections(Triangle fromNode) { return (Array<Connection<Triangle>>) (Array<?>) sharedEdges.getValueAt(fromNode.triIndex); }
@Override public Array<Connection<GridNode>> getConnections(GridNode fromNode) { return fromNode.getConnections(); }
@Override public Array<Connection<Routable>> getConnections() { throw new NotImplementedException(); }
@Override public Array<Connection<FlatTiledNode>> getConnections (FlatTiledNode fromNode) { return fromNode.getConnections(); }
public Array<Connection<N>> getConnections () { return this.connections; }
@Override public Array<Connection<HierarchicalTiledNode>> getConnections (HierarchicalTiledNode fromNode) { return fromNode.getConnections(); }
public HierarchicalTiledNode (int x, int y, int type, int index, int connectionCapacity) { super(x, y, type, new Array<Connection<HierarchicalTiledNode>>(connectionCapacity)); this.index = index; }