--[[
	Check if all humanoids has completed animation for hiding/showing.
]]

modules.waitForHumanoidAnimations = function(self)
	return function()
		for _, humanoidController in pairs(self.humanoidControllers) do
			if humanoidController:isAnimating() then
				humanoidController.animationCompleted.Event:Wait()
			end
		end
	end
end

modules.getModelFace = function()
	return function(model)
		local face = model:GetAttribute(constants.Attributes.SurfaceCanvasFace)
		if not face then
			return Enum.NormalId.Front
		end

		-- Case insensitive to make it more user friendly
		face = string.lower(face)

		for _, enum in ipairs(Enum.NormalId:GetEnumItems()) do
			if string.lower(enum.Name) == string.lower(face) then
				return enum
			end
		end

		warn("[SurfaceArt] Face provided is in attributes is invalid, defaulting to Front")
		return Enum.NormalId.Front
	end
end

modules.cleanup = function(self)
	return function()
		self.userInputController:enable()
		self.guiController:enable()
		self.cameraModule:animateToHumanoidAsync()
	end
end

return modules
