local this = class("cameraController")

function this:ctor(mode)
  self.mode = mode
  self.virCamera = nil
  self.cameraTactics = nil
end

function this:getCameraTactics()
  return self.cameraTactics
end

function this:getVirCamera()
  return self.virCamera
end

function this:getMode()
  return self.mode
end

function this:switchIn(...)
end

function this:switchOut(...)
end

function this:bindEntity(entity)
  C_CameraManager.SetFollowTarget(entity:getTransform())
  local virCamera = self:getVirCamera()
  if virCamera then
    virCamera:ResetTarget(entity:getTransform())
  end
end

function this:bindTransform(transform)
  C_CameraManager.SetFollowTarget(transform)
  local virCamera = self:getVirCamera()
  if virCamera then
    virCamera:ResetTarget(transform)
  end
end

function this:bindGameObject(go)
  C_CameraManager.SetFollowTarget(go.transform)
  local virCamera = self:getVirCamera()
  if virCamera then
    virCamera:ResetTarget(go.transform)
  end
end

function this:refreshVirCameraOffset(...)
end

function this:setBlendStyle(style, time)
  C_CameraManager.SetBrainBlendStyle(style)
  C_CameraManager.SetBrainBlendTime(time / 1000)
end

function this:clearCameraColliderData()
  if L_CommonUtil.isValid(self.cameraTactics) then
    local virtualCamera = self.cameraTactics:GetVirtualCamera()
    if virtualCamera then
      local cinemachineCollider = virtualCamera:GetComponent(typeof(CS.Cinemachine.WorldCinemachineCollider))
      if cinemachineCollider then
        cinemachineCollider:ClearCameraColliderData()
      end
    end
  end
end

function this:onDestroy()
  if L_CommonUtil.isValid(self.virCamera) then
    C_GameObject.Destroy(self.virCamera.gameObject)
  end
  if L_CommonUtil.isValid(self.cameraTactics) then
    self.cameraTactics:Dispose()
  end
  self.virCamera = nil
  self.cameraTactics = nil
end

function this:getCameraDistance()
  if self.cameraTactics then
    return self.cameraTactics:GetCameraDis()
  end
end

function this:setCameraDistance(dis)
  if self.cameraTactics then
    self.cameraTactics:SetCameraDis(dis)
  end
end

function this:getCameraRotateAxisValue()
  if self.virCamera then
    local anim = self.virCamera:GetCinemachineComponent(1)
    local horizontal = anim.m_HorizontalAxis
    local vertical = anim.m_VerticalAxis
    return horizontal.Value, vertical.Value
  end
end

function this:setCameraRotateAxisValue(angleHor, angleVer)
  if self.cameraTactics then
    self.cameraTactics:SetCameraRotateX(angleHor, true)
    self.cameraTactics:SetCameraRotateY(angleVer, true)
  end
end

function this:setCameraScreen(x, y)
  if self.cameraTactics then
    self.cameraTactics:SetCameraScreen(x, y)
  end
end

function this:getCameraScreen()
  local x, y = 0.5, 0.5
  if self.cameraTactics then
    local transposer = self.cameraTactics.transposer
    if transposer and not transposer:IsNull() then
      x, y = transposer.m_ScreenX or 0.5, transposer.m_ScreenY or 0.5
    end
  end
  return x, y
end

function this:setCameraSpeed()
end

return this
