--[[
	Indicates whether the local player is in range of the `target` object
	Returns: Boolean whether player is in range
]]
--
local function inRange()
	local distance = player:DistanceFromCharacter(target.Position)
	return distance > 0 and distance <= MAX_DISTANCE -- Distance should only be 0 when character doesnt exist
end

local function toggleInteraction()
	if ((not (MainFrame.Visible or GameplayUi.Enabled)) and inRange()) then
		show()
	else
		hide()
	end
end

local function interactionCheck()
	if not IS_CONSOLE then
		if ((not (MainFrame.Visible or GameplayUi.Enabled)) and inRange()) then
			InteractionButton.Visible = true
			InteractionBillboardButton.Visible = true
			InteractionArrow.Visible = false
		elseif not inRange() then
			InteractionButton.Visible = false
			InteractionBillboardButton.Visible = false
			InteractionArrow.Visible = true
		end
	end
	
	if MainFrame.Visible and not inRange() then
		hide()
	end
end
