

class Game_Pathfinder_Vertex extends Game_Position {

	/**
	 * @param   {Game_Engine_Entity_Block|null} block
	 * @returns {self}
	 */
	setBlock(block) {
		this.block = block;
		return this;
	}

	/**
	 * @returns {Game_Engine_Entity_Block|null}
	 */
	getBlock() {
		return this.block;
	}

	/**
	 * @returns {boolean}
	 */
	hasBlock() {
		return this.getBlock() !== null;
	}

	/**
	 * @returns {boolean}
	 */
	isBlocked() {
		return this.getDensity() === 1;
	}

	/**
	 * @returns {float}
	 */
	getDensity() {
		if (!this.hasBlock()) {
			return 0;
		}

		var block = this.getBlock();

		return block.getDensity();
	}

	/**
	 * @returns {Game_Pathfinder_Vertex|null}
	 */
	getParentVertex() {
		return this.parent_vertex;
	}

	/**
	 * @returns {boolean}
	 */
	hasParentVertex() {
		return this.getParentVertex() !== null;
	}

	/**
	 * @param   {Game_Pathfinder_Vertex} parent_vertex
	 * @returns {self}
	 */
	setParentVertex(parent_vertex) {
		this.parent_vertex = parent_vertex;
		return this;
	}

	/**
	 * @param   {Game_Pathfinder_Vertex} anchor_vertex
	 * @returns {self}
	 */
	setAnchorVertex(anchor_vertex) {
		this.anchor_vertex = anchor_vertex;
		return this;
	}

	/**
	 * @returns {Game_Pathfinder_Vertex|null}
	 */
	getAnchorVertex() {
		return this.anchor_vertex;
	}

	/**
	 * @returns {float}
	 */
	getAggregateCost() {
		return this.aggregate_cost;
	}

	/**
	 * @param   {float} aggregate_cost
	 * @returns {self}
	 */
	setAggregateCost(aggregate_cost) {
		this.aggregate_cost = aggregate_cost;
		return this;
	}

	/**
	 * @returns {boolean}
	 */
	wasVisited() {
		return this.visited;
	}

	/**
	 * @param   {boolean} was_visited
	 * @returns {self}
	 */
	setWasVisited(was_visited) {
		this.visited = was_visited;
		return this;
	}

	/**
	 * @returns {float|null}
	 */
	getHeuristic() {
		return this.heuristic;
	}

	/**
	 * @param   {float} heuristic
	 * @returns {self}
	 */
	setHeuristic(heuristic) {
		this.heuristic = heuristic;
		return this;
	}

	/**
	 * @returns {boolean}
	 */
	hasHeuristic() {
		return this.getHeuristic() !== null;
	}

	/**
	 * @param   {float} score
	 * @returns {self}
	 */
	setScore(score) {
		this.score = score;
		return this;
	}

	/**
	 * @returns {float}
	 */
	getScore() {
		return this.score;
	}

	/**
	 * @param   {Game_Pathfinder_Vertex} vertex
	 * @returns {float}
	 */
	getDistanceToVertex(vertex) {
		return this.getDistanceToPosition(vertex);
	}

	/**
	 * @param   {Game_Position} position
	 * @returns {boolean}
	 */
	matchesPosition(position) {
		return this.equals(position);
	}

}

ObjectHelper.extend(Game_Pathfinder_Vertex.prototype, {
	heuristic:      null,
	aggregate_cost: 0,
	score:          0,

	visited:        false,
	closed:         false,

	parent_vertex:  null,
	anchor_vertex:  null,

	// @param {Game_Engine_Entity_Block|null}
	block:          null
});

module.exports = Game_Pathfinder_Vertex;
