local A=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local p=A:WaitForChild("\077\111\100\117\108\101\115")local f=A:WaitForChild("\077\111\100\101\108\115")local R=require(p.src.utils.Logger)local u={}function u.findModel(p,A)if not A.modelFolder then R:e("\078\111 \109\111\100\101\108\070\111\108\100\101\114 \102\111\114 \105\116\101\109",A)end local u=f:FindFirstChild(A.modelFolder)if not u then R:e("\078\111 \109\111\100\101\108\070\111\108\100\101\114 \102\111\117\110\100 \119\105\116\104 \110\097\109\101\058 "..A.modelFolder)return end local K=u:FindFirstChild(A.modelName)if not K then R:e("\078\111 \109\111\100\101\108 \102\111\117\110\100 \119\105\116\104 \110\097\109\101\058 "..A.modelName)return end R:d("\077\111\100\101\108 \102\111\117\110\100 \119\105\116\104 \110\097\109\101\058 "..A.modelName)return K end function u.setTransparency(f,A,p)local R=A:GetDescendants()for f=1,#R,1 do local u=R[f]if u:IsA("\066\097\115\101\080\097\114\116")and A.PrimaryPart~=u then u.Transparency=p end end end function u.setTransparencyAndCanCollide(R,A,p,f)local u=A:GetDescendants()for R=1,#u,1 do local K=u[R]if K:IsA("\066\097\115\101\080\097\114\116")and A.PrimaryPart~=K then K.Transparency=p K.CanCollide=f end end end function u.removePitch(f,A,p)local R,u,K=A:ToOrientation()return CFrame.new(A.Position)*CFrame.fromOrientation(0,u,K)end function u.onlyDirection(p,A)local f,R,u=A:ToOrientation()return CFrame.new(A.Position)*CFrame.fromOrientation(0,R,0)end return u
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Modules = ReplicatedStorage:WaitForChild('Modules')
local Models = ReplicatedStorage:WaitForChild('Models')
local logger = require(Modules.src.utils.Logger)

local ModelManager = {}

function ModelManager:findModel(item)
	if not item.modelFolder then
		logger:e('No modelFolder for item', item)
	end

	local modelFolder = Models:FindFirstChild(item.modelFolder)
	if not modelFolder then
		logger:e('No modelFolder found with name: ' .. item.modelFolder)
		return
	end

	local model = modelFolder:FindFirstChild(item.modelName)

	if not model then
		logger:e('No model found with name: ' .. item.modelName)
		return
	end

	logger:d('Model found with name: ' .. item.modelName)

	return model
end

function ModelManager:setTransparency(model, transparency)
	local descendants = model:GetDescendants()
	for i = 1, #descendants do
		local descendant = descendants[i]
		-- PrimaryPart is usually invicible bounding box
		if descendant:IsA('BasePart') and model.PrimaryPart ~= descendant then
			descendant.Transparency = transparency
		end
	end
end
function ModelManager:setTransparencyAndCanCollide(model, transparency, canCollide)
	local descendants = model:GetDescendants()
	for i = 1, #descendants do
		local descendant = descendants[i]
		-- PrimaryPart is usually invicible bounding box
		if descendant:IsA('BasePart') and model.PrimaryPart ~= descendant then
			descendant.Transparency = transparency
			descendant.CanCollide = canCollide
		end
	end
end

function ModelManager:removePitch(cf, defaultCf)
	local _, RY, RZ = cf:ToOrientation()
	return CFrame.new(cf.Position) * CFrame.fromOrientation(0, RY, RZ)
end

function ModelManager:onlyDirection(cf)
	local _, RY, RZ = cf:ToOrientation()
	return CFrame.new(cf.Position) * CFrame.fromOrientation(0, RY, 0)
end

return ModelManager