local F=(game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")):WaitForChild("\087\111\114\108\100\069\110\103\105\110\101")local t=require(F:WaitForChild("\079\098\106\101\099\116"))local l=require(script.Parent.Region)local B=require(F:WaitForChild("\116"))local A=B.tuple(B.string,B.optional(B.array(l.instance)))local U=t:Extend("\082\101\103\105\111\110\071\114\111\117\112")function U.constructor(l,F,t)assert(A(F,t))t=t or{}l._name=F l._regions=t end function U.AddRegion(t,F)assert(l:Is(F),"\069\120\112\101\099\116\101\100 \114\101\103\105\111\110")table.insert(t._regions,F)end function U.GetRegionPointsAt(t,F)assert(B.number(F))local l=t._regions[F]if l then return l:GetPoint0(),l:GetPoint1(),l:GetName()end end function U.ContainsPoint(t,F)for t,l in next,t._regions do local B,A=l:ContainsPoint(F)if B then return true,A end end return false end return U
local WorldEngine = game:GetService("ReplicatedStorage"):WaitForChild("WorldEngine")
local Object = require(WorldEngine:WaitForChild("Object"))
local Region = require(script.Parent.Region)
local t = require(WorldEngine:WaitForChild("t"))

local IS_REGION_GROUP = t.tuple(t.string, t.optional(t.array(Region.instance)))

local RegionGroup = Object:Extend("RegionGroup")
function RegionGroup:constructor(name, regions)
	assert(IS_REGION_GROUP(name, regions))
	regions = regions or {}
	self._name = name
	self._regions = regions
end

function RegionGroup:AddRegion(region)
	assert(Region:Is(region), "Expected region")
	table.insert(self._regions, region)
end

function RegionGroup:GetRegionPointsAt(index)
	assert(t.number(index))
	local region = self._regions[index]
	if region then
		return region:GetPoint0(), region:GetPoint1(), region:GetName()
	end
end

-- luacov: disable
function RegionGroup:ContainsPoint(point)
	for _, region in next, self._regions do
		local inPoint, name = region:ContainsPoint(point)
		if inPoint then
			return true, name
		end
	end

	return false
end
-- luacov: enable

return RegionGroup
