local AnimatorHelper = {}

function AnimatorHelper:PlayAnimation(root)
    local animatorGameObject = root.gameObject
    animatorGameObject:GetComponent("Animator"):Play()
end

function AnimatorHelper:PlayAnimationByName(root, szAnimName)
    local animatorGameObject = root.gameObject
    animatorGameObject:GetComponent("Animator"):Play(szAnimName)
end

function AnimatorHelper:SetBool(root, szParam, bActive)
    local animatorGameObject = root.gameObject
    animatorGameObject:GetComponent("Animator"):SetBool(szParam, bActive)
end

function AnimatorHelper:SetTrigger(root, szParam)
    local animatorGameObject = root.gameObject
    animatorGameObject:GetComponent("Animator"):SetTrigger(szParam)
end

function AnimatorHelper:ResetTrigger(root, szParam)
    local animatorGameObject = root.gameObject
    animatorGameObject:GetComponent("Animator"):ResetTrigger(szParam)
end

function AnimatorHelper:SetFloat(root, szParam, nNumber)
    local animatorGameObject = root.gameObject
    animatorGameObject:GetComponent("Animator"):SetFloat(szParam, nNumber)
end

function AnimatorHelper:GetAnimatorLength(root, szAnimName)
    local animatorGameObject = root.gameObject
    local tClips = animatorGameObject:GetComponent("Animator").runtimeAnimatorController.animationClips
    local nLength = 0
    for _, clip in ipairs(tClips) do
        if clip.name == szAnimName then
            nLength = clip.length
            break
        end
    end
    return nLength
end

return AnimatorHelper