Example usage for com.badlogic.gdx.ai.pfa DefaultConnection DefaultConnection

List of usage examples for com.badlogic.gdx.ai.pfa DefaultConnection DefaultConnection

Introduction

In this page you can find the example usage for com.badlogic.gdx.ai.pfa DefaultConnection DefaultConnection.

Prototype

public DefaultConnection(N fromNode, N toNode) 

Source Link

Usage

From source file:toniarts.openkeeper.world.creature.pathfinding.MapIndexedGraph.java

License:Open Source License

private void addIfValidCoordinate(final TileData startTile, final int x, final int y,
        final Array<Connection<TileData>> connections) {

    // Valid coordinate
    TileData tile = worldState.getMapData().getTile(x, y);
    if (tile != null) {
        Terrain terrain = tile.getTerrain();
        if (!terrain.getFlags().contains(Terrain.TerrainFlag.SOLID)) {

            // TODO: Rooms, obstacles and what not, should create an universal isAccessible(Creature) to map loader / world handler maybe
            if (creature != null) {

                if (!worldState.isAccessible(tile, creature)) {
                    return;
                }// w w  w.java 2  s  .c o m

                if (creature.getFlags().contains(Creature.CreatureFlag.CAN_FLY)) {
                    connections.add(new DefaultConnection<>(startTile, tile)); // No cost
                    return;
                }
            }
            connections.add(new MapConnection(startTile, tile));
        }
    }
}