local this = class("bigStreamMapPainter", require("ui.manager.map.painter.mapPainter"))
local _areaTpl = L_GameTpl:getWorldAreaTpl()
local PATH_CONTAINER = "Program/Map/pre_mapContainer.prefab"

function this:ctor(...)
  this.super.ctor(self, ...)
  self.index = 0
  self.middle = self.mapData.imgSize / 2
end

function this:paint(container)
  self.handle = C_LuaUtility.LoadGameObjectSync(PATH_CONTAINER)
  local go = Unity.GameObject.Instantiate(self.handle.gameObject)
  self.paintNode = go.transform
  self.paintNodeGo = go
  self.paintNode:Reset(container, true)
  self.paintNode:SetAsFirstSibling()
  self.mapLoader2D = self.paintNodeGo:AddComponent(typeof(C_BigMapLoader2D))
  local tpl = _areaTpl:getTplById(self.mapData.areaId)
  self.cellSize = _areaTpl:getRowAndColumn(tpl)
  L_Vector3.setUISize(container, self.mapData.imgSize)
  L_Vector3.setUISize(self.paintNode, self.mapData.imgSize)
  local cellSize = C_Vector2(self.cellSize.x, self.cellSize.y)
  local imgSize = C_Vector2(self.middle.x, self.middle.y)
  self.mapLoader2D:Init(cellSize, 1, self.mapData.areaId, imgSize)
end

function this:setTargetTrans(parent)
  if self.mapLoader2D == nil then
    return
  end
  self.mapLoader2D:InitCenterPosition(parent)
end

function this:onDrag()
end

function this:onSlider(imgScale)
  if self.mapLoader2D == nil then
    return
  end
  self.mapLoader2D:SetMapScale(imgScale)
end

function this:removePaint()
  if self.paintNodeGo ~= nil then
    C_GameObject.Destroy(self.paintNodeGo)
    self.paintNodeGo = nil
  end
end

function this:onDestroy()
  if self.handle then
    C_LuaUtility.DestroyObject(self.handle)
  end
end

return this
