--[[
    Indexes the avatar joints and gives them a default orientation
]]

function ClientAvatarComponent:setupJoints()
	self.shoulders = {}
	self.hips = {}
	self.knees = {}

	local leftShoulder = self.avatar:FindFirstChild("LeftShoulder", true)
	local rightShoulder = self.avatar:FindFirstChild("RightShoulder", true)
	local leftHip = self.avatar:FindFirstChild("LeftHip", true)
	local rightHip = self.avatar:FindFirstChild("RightHip", true)
	local leftKnee = self.avatar:FindFirstChild("LeftKnee", true)
	local rightKnee = self.avatar:FindFirstChild("RightKnee", true)

	-- Transform doesn't replicate, so this is applied clientside on each client
	-- As animations can't be shared between users yet, we can't use an animation for this

	if leftShoulder and leftShoulder:IsA("Motor6D") then
		leftShoulder.Transform = CFrame.Angles(0.3 * math.pi, 0, 0)
		self.shoulders.left = leftShoulder
	end
	if rightShoulder and rightShoulder:IsA("Motor6D") then
		rightShoulder.Transform = CFrame.Angles(0.3 * math.pi, 0, 0)
		self.shoulders.right = rightShoulder
	end
	if leftHip and leftHip:IsA("Motor6D") then
		leftHip.Transform = CFrame.Angles(0.5 * math.pi, 0, 0)
		self.hips.left = leftHip
	end
	if rightHip and rightHip:IsA("Motor6D") then
		rightHip.Transform = CFrame.Angles(0.5 * math.pi, 0, 0)
		self.hips.right = rightHip
	end
	if leftKnee and leftKnee:IsA("Motor6D") then
		leftKnee.Transform = CFrame.Angles(-0.5 * math.pi, 0, 0)
		self.knees.left = leftKnee
	end
	if rightKnee and rightKnee:IsA("Motor6D") then
		rightKnee.Transform = CFrame.Angles(-0.5 * math.pi, 0, 0)
		self.knees.right = rightKnee
	end
end
