--[[
	Draws a ray between CFrame towards part. If the ray is close to the part (as defined by the discrepencies below), returns true - else returns false.
]]

local MAX_PERIPHERAL_SIGHT = 10
local MAX_SIGHT_RANGE = 1

return function(originCFrame, targetPart, ignoreInstance)
	local targetPartCFrame = targetPart.CFrame

	local pointedCFrame = CFrame.new(originCFrame.Position, targetPartCFrame.Position)

	local ray = Ray.new(pointedCFrame.Position, pointedCFrame.LookVector * 500)

	local hitPart, hitPosition = workspace:FindPartOnRay(ray, ignoreInstance)

	local discrepency = (hitPosition - targetPartCFrame.Position).magnitude
	local range = (originCFrame.LookVector - pointedCFrame.LookVector).magnitude

	if hitPart and (hitPart == targetPart or discrepency < MAX_PERIPHERAL_SIGHT) and range < MAX_SIGHT_RANGE then
		return true
	else
		return false
	end
end
