local S=game:GetService("\083\101\114\118\101\114\083\116\111\114\097\103\101")local w=require(S.Source.Constants.TileTypes)local J=require(S.Source.Constants.SlopeTypes)return function()local Z={}local u=S:FindFirstChild("\084\105\108\101\115")for S,w in pairs(w)do Z[w]={}local a=u:FindFirstChild(w)for S,J in pairs(J)do Z[w][J]={}local u=a:FindFirstChild(J)if u then for S,u in pairs(u:GetChildren())do local a=u:FindFirstChild("\068\105\102\102\105\099\117\108\116\121")local l=math.clamp(a.Value,0,100)table.insert(Z[w][J],{model=u,difficulty=l,type=w})end end end end return Z end
--[[
  Returns a dictionary with the model and difficulty data for each tile type and slope type
]]
local ServerStorage = game:GetService("ServerStorage")

local TileTypes = require(ServerStorage.Source.Constants.TileTypes)
local SlopeTypes = require(ServerStorage.Source.Constants.SlopeTypes)

return function()
	local tileIndex = {}

	local tiles = ServerStorage:FindFirstChild("Tiles")
	for _, tileType in pairs(TileTypes) do
		tileIndex[tileType] = {}

		local tileFolder = tiles:FindFirstChild(tileType)

		for _, slopeType in pairs(SlopeTypes) do
			tileIndex[tileType][slopeType] = {}

			local slopeFolder = tileFolder:FindFirstChild(slopeType)
			if slopeFolder then
				for _, model in pairs(slopeFolder:GetChildren()) do
					local difficultyObject = model:FindFirstChild("Difficulty")

					-- Clamp the difficulty value between 0 and 100 (as it is a percent)
					local difficulty = math.clamp(difficultyObject.Value, 0, 100)

					table.insert(tileIndex[tileType][slopeType], {
						model = model,
						difficulty = difficulty,
						type = tileType,
					})
				end
			end
		end
	end

	return tileIndex
end
