local this = class("mapAreaMaskNode", require("ui.manager.map.node.mapNode"))
local _typeRect = typeof(C_RectTransform)
local _typeImg = typeof(C_LImage)
local PATH_AREABLOCKNODE = "UI/MapMask/MaskPrefab/pre_AreaMask.prefab"
local PATH_AREABLOCKNODE_MINI = "UI/MapMask/MaskPrefab/pre_AreaMask_mini.prefab"

function this:setShow(isShow)
  if self.controlByUnlockEffect == true then
    return
  end
  self.areaMask:ActiveTrans(not isShow)
end

function this:generate(parent, pool, isMiniMap)
  self:_generate(pool or L_ResPool, isMiniMap)
  self.controlByUnlockEffect = false
  if parent then
    self.trans:SetParent(parent)
    self.trans.offsetMin = C_Vector2(0, 0)
    self.trans.offsetMax = C_Vector2(0, 0)
    L_Vector3.setScale(self.trans, L_Vector3.getTemp(1, 1, 1))
    L_Vector3.setLocalPos(self.trans, L_Vector3.getTemp())
  end
  if not string.isEmpty(self.iconPath) then
    self.imgNode:LoadSprite(self.iconPath, false)
    self.imgNode_outline_1:LoadSprite(self.iconPath, false)
    self.imgNode_outline_2:LoadSprite(self.iconPath, false)
    self.imgNode_outline_3:LoadSprite(self.iconPath, false)
  end
end

function this:_generate(pool, isMiniMap)
  local go
  if isMiniMap then
    go = pool:syncGameObject(PATH_AREABLOCKNODE_MINI)
  else
    go = pool:syncGameObject(PATH_AREABLOCKNODE)
  end
  self.go = go
  self.trans = self.go:GetComponent(_typeRect)
  self.areaMask = self.go
  self.imgNode = isMiniMap and self.go:GetComponent(typeof(_typeImg)) or self.go:GetComponent(typeof(C_LMaskImage))
  self.imgNode_outline_1 = self.trans:Find("outline1").gameObject:GetComponent(_typeImg)
  self.imgNode_outline_2 = self.trans:Find("outline2").gameObject:GetComponent(_typeImg)
  self.imgNode_outline_3 = self.trans:Find("outline3").gameObject:GetComponent(_typeImg)
end

function this:refreshPosByMapData(mapData)
end

function this:refreshState(mapData)
end

function this:refreshLockState()
  if math.isEmpty(self.id) then
    return
  end
  local isUnlock = L_SceneStore:getPointIsUnlock(self.id)
  self:setShow(isUnlock)
end

function this:setEffectStatus(bool)
  if self.controlByUnlockEffect == nil then
    self.controlByUnlockEffect = false
  end
  self.controlByUnlockEffect = bool
  self.areaMask:ActiveTrans(bool)
end

function this:onDestroy()
  this.super.onDestroy(self)
end

return this
