local this = class("animatorComponent", L_EcsConst.component)

function this:ctor(...)
  this.super.ctor(self, ...)
end

function this:onBindGameObject(go)
  self.animator = self.parent:getAnimator(true)
end

function this:onDestroy()
  this.super.onDestroy(self)
  self.animator = nil
end

function this:initialize(avatarIndex)
end

function this:play(name, normalize)
  self.animator:Play(name, -1, normalize or 0)
end

function this:crossFade(name, fixedTransitionDuration)
  self.animator:CrossFade(name, fixedTransitionDuration or 0.25, -1, 0, 0)
end

function this:setSpeed(speed)
  self.animator.speed = speed
end

function this:getState(name)
  local state = self.animator:GetState(name)
  return state
end

function this:appendCallback(state, callback, binder)
  callback(binder)
end

function this:getCurAnimIndex()
  local csAlive = self.parent:getCsEntity()
  return csAlive.currentStateType
end

function this:getCurAnimName()
  local csAlive = self.parent:getCsEntity()
  return csAlive.currentStateName
end

function this:getCurAnimState()
  local state = self.animator:GetRunState()
  return state
end

function this:setBool(param, b)
  self.animator:SetBool(param, b)
end

function this:setInteger(param, int)
  self.animator:SetInteger(param, int)
end

function this:resetFaceAnim(boolean)
end

function this:getAnimDic(isToTable)
  local array = self.animator:GetCurrentAnimatorClipInfo(-1)
  local result = {}
  if isToTable then
    for i = 1, array.Length do
      table.insert(result, array[i - 1])
    end
  end
  return result
end

function this:getFaceAnimDic(isToTable)
  return self:getAnimDic(isToTable)
end

function this:getStateRMSpeed(stateName)
  return self.animator:GetStateRootMotionSpeed(stateName)
end

function this:Evaluate(dt)
  return self.animator:Evaluate(dt)
end

return this
