local z=require(script.Parent.Parent.lib.t)local Y=z.tuple(z.number,z.instanceOf("\077\111\100\101\108"),z.Color3,z.optional(z.number))local function Z(z,Z,a,U)assert(Y(z,Z,a,U))U=U or 0 local G=z*2 local X=Z.PrimaryPart local I,f=Z:GetBoundingBox()local d=I.p local m=d.Y-f.Y/2 local t=Vector3.new(d.X,m+U,d.Z)local F=Instance.new("\080\097\114\116")F.Color=a F.Name=("\082\097\100\105\117\115\037\105"):format(z)F.Position=t F.Size=Vector3.new(1,.2,1)F.Material=Enum.Material.Neon F.Transparency=.75 F.Anchored=false F.CanCollide=false local H=Instance.new("\067\121\108\105\110\100\101\114\077\101\115\104")H.Scale=Vector3.new(G,1,G)H.Parent=F local x=Instance.new("\087\101\108\100\067\111\110\115\116\114\097\105\110\116")x.Part0=X x.Part1=F x.Parent=F F.Parent=Z return F end return Z
--[[
	Allows for easy visualization of a radius.

	The `model` must have a PrimaryPart. This is needed for bounding box
	calculations.

	This is useful for determining how far away a player needs to be from an NPC
	to interact, or how far away the player can be before an enemy will start
	aggroing.

	Usage:

		-- Places a red, 20 stud radius at the bottom of an NPC
		visualizeRadius(20, npc, Color3.fromRGB(255, 0, 0))

		-- Using more than one radius. The last value sets how far up the radius
		-- is pushed so they don't overlap
		visualizeRadius(20, npc, Color3.fromRGB(255, 0, 0), 0.2)
		visualizeRadius(30, npc, Color3.fromRGB(255, 206, 73), 0.1)
]]

local t = require(script.Parent.Parent.lib.t)

local visualizeRadiusCheck = t.tuple(
	t.number,
	t.instanceOf("Model"),
	t.Color3,
	t.optional(t.number)
)

local function visualizeRadius(radius, model, color, yOffset)
	assert(visualizeRadiusCheck(radius, model, color, yOffset))

	yOffset = yOffset or 0

	local diameter = radius * 2
	local primary = model.PrimaryPart
	local cframe, size = model:GetBoundingBox()
	local position = cframe.p

	local bottom = position.Y - (size.Y /2)
	local bottomPos = Vector3.new(position.X, bottom + yOffset, position.Z)

	local part = Instance.new("Part")
	part.Color = color
	part.Name = ("Radius%i"):format(radius)
	part.Position = bottomPos
	part.Size = Vector3.new(1, 0.2, 1)
	part.Material = Enum.Material.Neon
	part.Transparency = 0.75
	part.Anchored = false
	part.CanCollide = false

	local mesh = Instance.new("CylinderMesh")
	mesh.Scale = Vector3.new(diameter, 1, diameter)
	mesh.Parent = part

	local weld = Instance.new("WeldConstraint")
	weld.Part0 = primary
	weld.Part1 = part
	weld.Parent = part

	part.Parent = model

	return part
end

return visualizeRadius
