local page = class("pageFaceIn", G_UIPageBase)

function page.bind()
  return {}
end

function page.methods()
  return {
    onClick_close = function(self)
      L_UI:close(self.pageName)
    end
  }
end

function page:created(...)
  page.super.created(self, ...)
end

function page:preOpen(options)
  page.super.preOpen(self, options)
  L_SceneManager:addListener(L_SceneManager.event.switchSceneStart, self.closeMe, self)
  L_SceneManager:addListener(L_SceneManager.event.suspendCurScene, self.closeMe, self)
  local virCamera = C_CameraManager.GetTactics().cineMachineCamera
  local trans = virCamera.transform
  self.ikComponent = L_PlayerManager:getMainHeroEntity():getLookAtIKComponent(true)
  self.ikComponent:enableIK(trans)
end

function page:close()
  page.super.close(self)
  L_SceneManager:removeListener(L_SceneManager.event.switchSceneStart, self.closeMe)
  L_SceneManager:removeListener(L_SceneManager.event.suspendCurScene, self.closeMe)
  if self.ikComponent then
    self.ikComponent:disableIK()
  end
  local fixedFollow = C_CameraManager.GetTactics().fixFollow
  if L_CommonUtil.isValid(fixedFollow) then
    fixedFollow:ZoomOutWithTarget(false)
  end
end

function page:closeMe(pageName)
  L_UI:close(self.pageName)
end

function page:onEvent_otherOpen(pageName)
  if pageName and pageName ~= self.pageName then
    L_UI:close(self.pageName)
  end
end

return page
