// Path: core/src/me/minidigger/projecttd/components/PathComponent.java
// public class PathComponent implements Component, Pool.Poolable {
// 
//     public int tilesToGoal = -1;
//     public Vector2 nextPoint;
//     public PathFindingSystem.GoalReachedAction completed = (e) -> {
//     };
// 
//     @Override
//     public void reset() {
//         tilesToGoal = -1;
//         nextPoint = null;
//         completed = (e) -> {
//         };
//     }
// }
// 
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
// 
//     public Vector2 position;
//     public float rotation = 0f;
// 
//     @Override
//     public void reset() {
//         position = new Vector2();
//         rotation = 0f;
//     }
// }
// 
// Path: core/src/me/minidigger/projecttd/utils/CoordinateUtil.java
// public class CoordinateUtil {
// 
//     private static Vector3 vector3 = new Vector3();
// 
//     public static Vector2 touchToWorld(Vector2 point, Camera camera) {
//         vector3.set(point, 0);
//         camera.unproject(vector3);
//         point.set(vector3.x, vector3.y);
//         return point;
//     }
// 
//     public static Vector2 worldToTouch(Vector2 point, Camera camera) {
//         vector3.set(point, 0);
//         camera.project(vector3);
//         point.set(vector3.x, vector3.y);
//         return point;
//     }
// 
//     public static Vector2 alignToGrid(Vector2 input) {
//         input.x = (int) (input.x) + 0.5f;
//         input.y = (int) (input.y) + 0.5f;
//         return input;
//     }
// }
// 
// Path: core/src/me/minidigger/projecttd/utils/Vector2i.java
// public class Vector2i {
// 
//     public int x;
//     public int y;
// 
//     public Vector2i(int x, int y) {
//         this.x = x;
//         this.y = y;
//     }
// 
//     @Override
//     public String toString() {
//         return "Vector2i{" +
//                 "x=" + x +
//                 ", y=" + y +
//                 '}';
//     }
// }


import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
import com.badlogic.gdx.math.Vector2;
import me.minidigger.projecttd.components.PathComponent;
import me.minidigger.projecttd.components.TransformComponent;
import me.minidigger.projecttd.utils.CoordinateUtil;
import me.minidigger.projecttd.utils.Vector2i;
import java.util.LinkedList;
import java.util.Queue;
package me.minidigger.projecttd.systems;



/**
 * Created by mbenndorf on 13.04.2017.
 */
public class PathFindingSystem extends IteratingSystem {

    private final int mapWidth;
    private final int mapHeight;

    private final TileType[][] map;
    private int[][] cost;
    private boolean[][] visited;
    private Vector2[][] direction;

    private Vector2 goal;

    private ComponentMapper<TransformComponent> transformM = ComponentMapper.getFor(TransformComponent.class);
// Path: core/src/me/minidigger/projecttd/components/PathComponent.java
// public class PathComponent implements Component, Pool.Poolable {
// 
//     public int tilesToGoal = -1;
//     public Vector2 nextPoint;
//     public PathFindingSystem.GoalReachedAction completed = (e) -> {
//     };
// 
//     @Override
//     public void reset() {
//         tilesToGoal = -1;
//         nextPoint = null;
//         completed = (e) -> {
//         };
//     }
// }
// 
// Path: core/src/me/minidigger/projecttd/components/TransformComponent.java
// public class TransformComponent implements Component, Pool.Poolable {
// 
//     public Vector2 position;
//     public float rotation = 0f;
// 
//     @Override
//     public void reset() {
//         position = new Vector2();
//         rotation = 0f;
//     }
// }
// 
// Path: core/src/me/minidigger/projecttd/utils/CoordinateUtil.java
// public class CoordinateUtil {
// 
//     private static Vector3 vector3 = new Vector3();
// 
//     public static Vector2 touchToWorld(Vector2 point, Camera camera) {
//         vector3.set(point, 0);
//         camera.unproject(vector3);
//         point.set(vector3.x, vector3.y);
//         return point;
//     }
// 
//     public static Vector2 worldToTouch(Vector2 point, Camera camera) {
//         vector3.set(point, 0);
//         camera.project(vector3);
//         point.set(vector3.x, vector3.y);
//         return point;
//     }
// 
//     public static Vector2 alignToGrid(Vector2 input) {
//         input.x = (int) (input.x) + 0.5f;
//         input.y = (int) (input.y) + 0.5f;
//         return input;
//     }
// }
// 
// Path: core/src/me/minidigger/projecttd/utils/Vector2i.java
// public class Vector2i {
// 
//     public int x;
//     public int y;
// 
//     public Vector2i(int x, int y) {
//         this.x = x;
//         this.y = y;
//     }
// 
//     @Override
//     public String toString() {
//         return "Vector2i{" +
//                 "x=" + x +
//                 ", y=" + y +
//                 '}';
//     }
// }


// Path: core/src/me/minidigger/projecttd/systems/PathFindingSystem.java
import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
import com.badlogic.gdx.math.Vector2;
import me.minidigger.projecttd.components.PathComponent;
import me.minidigger.projecttd.components.TransformComponent;
import me.minidigger.projecttd.utils.CoordinateUtil;
import me.minidigger.projecttd.utils.Vector2i;
import java.util.LinkedList;
import java.util.Queue;

package me.minidigger.projecttd.systems;



/**
 * Created by mbenndorf on 13.04.2017.
 */
public class PathFindingSystem extends IteratingSystem {

    private final int mapWidth;
    private final int mapHeight;

    private final TileType[][] map;
    private int[][] cost;
    private boolean[][] visited;
    private Vector2[][] direction;

    private Vector2 goal;

    private ComponentMapper<TransformComponent> transformM = ComponentMapper.getFor(TransformComponent.class);
    private ComponentMapper<PathComponent> pathM = ComponentMapper.getFor(PathComponent.class);