local this = class("mapCollectionItemNode", require("ui.manager.map.node.mapNode"))
local _typeImg = typeof(C_LImage)
local _typeRect = typeof(C_RectTransform)
local _typeBtn = typeof(C_LButton)
local PATH_AREACOLLECTIONITEMNODE = "UI/Pages/Map/BigMap/cellMapCollectionItemNode.prefab"

function this:_generate(parent, pool)
  local go = pool:syncGameObject(PATH_AREACOLLECTIONITEMNODE)
  self.go = go
  self.trans = self.go:GetComponent(_typeRect)
  self.nodeBg = self.go.transform:Find("nodeIconBg")
  self.collectionItemGo = self.nodeBg.transform:Find("nodeIcon").gameObject
  self.btnNode = self.go:GetComponent(_typeBtn)
  self.choose = self.trans:Find("IsChoose").gameObject
  self.imgNode = self.collectionItemGo:GetComponent(_typeImg)
  self.imgNodeBg = self.nodeBg.gameObject:GetComponent(_typeImg)
  self.canvasGroup = self.go:GetComponent(typeof(C_CanvasGroup))
  if not string.isEmpty(self.icon) then
    self.img:LoadSprite(self.icon)
  end
end

function this:addClick(clickHandle)
  if not self.btnNode then
    return
  end
  self.btnNode.onClick:RemoveAllListeners()
  self.btnNode.onClick:AddListener(clickHandle)
end

function this:setSize(size)
  local nodeIconBg = self.go.transform:Find("nodeIconBg").gameObject
  nodeIconBg.transform.localScale = L_Vector3.new(0.5, 0.5)
end

return this
