--[[
	@param 	Path		Path			The Path-object we want to visualize
	@return	Model		DrawnPath		Returns the model containing the drawn path 	
--]]

function Pathfinder:DrawPath(Path)
	assert(Path and Path.Status == Enum.PathStatus.Success, "Pathfinder:DrawPath(Path) requires a valid Path!")
	self:DestroyDrawnPath()
	
	-- Generate new path visuals
	local container = self._DrawnPath or Instance.new("Model")
	container.Name = "Pathfinder_Path"
	for index, waypoint in pairs(Path:GetWaypoints()) do
		local p = Instance.new("Part")
		p.Name = string.format("Waypoint_%d", index)
		p.Anchored = true
		p.CanCollide = false
		p.Size = Vector3.new(1,1,1)
		p.CFrame = CFrame.new(waypoint.Position)
		p.BrickColor = waypoint.Action == Enum.PathWaypointAction.Jump and BrickColor.Blue() or BrickColor.Gray()
		p.Parent = container
	end
	container.Parent = workspace
	self._DrawnPath = container
	return container
end

function Pathfinder:DestroyDrawnPath()
	if self._DrawnPath then self._DrawnPath:ClearAllChildren() end
end
