local DOTweenManager = {}

local DOTweenSequence = CS.DG.Tweening.DOTween.Sequence

function DOTweenManager:init()
    -- 三个参数分别是recycleAllByDefault， useSafeMode， logBehaviour
    if IS_PUBLISH then
        CS.DG.Tweening.DOTween.Init(false, false, CS.DG.Tweening.LogBehaviour.ErrorsOnly)
    else
        CS.DG.Tweening.DOTween.Init(false, false, CS.DG.Tweening.LogBehaviour.Default)
    end
end

function DOTweenManager:createSeqWithIntId(id)
	id = id or GConst.DOTWEEN_IDS.DEFAULT
	local seq = DOTweenSequence()
    seq:SetIntId(id)
	return seq
end

function DOTweenManager:createDOTweenToWithIntId(id, getter, setter, to, duration)
	id = id or GConst.DOTWEEN_IDS.DEFAULT
	local tween = CS.DG.Tweening.DOTween.To(getter, setter, to, duration)
    tween:SetIntId(id)
	return tween
end

function DOTweenManager:createDOTweenTo(getter, setter, to, duration)
	local tween = CS.DG.Tweening.DOTween.To(getter, setter, to, duration)
	return tween
end

-- 返回一个跟gameObject绑定的Sequence,当gameObject销毁的时候这个Sequence会跟着一起销毁
-- 但是偶尔会有gameObject销毁的时候这个Sequence没有跟着一起销毁，尚未查明原因，所以谨慎使用
function DOTweenManager:createSeqWithGameObject(gameObject)
	local seq = DOTweenSequence()
    seq:SetLink(gameObject)
	return seq
end

function DOTweenManager:doScale(trans,endValue, duration,onComplete)
	local tween = trans:DOScale(endValue, duration)
	tween.onComplete = function()
		if onComplete then
			onComplete()
		end
	end
end



return DOTweenManager