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

function this:ctor(...)
  this.super.ctor(self, ...)
end

function this:setIsUnlock(isUnLock)
  if self.isUnLock == isUnLock then
    return
  end
  self.isUnLock = isUnLock
  if self.goLock then
    self.goLock:ActiveTrans(not isUnLock)
  end
  if self.imgNode then
    self.imgNode.color = isUnLock and C_Color(1, 1, 1, 1) or C_Color(1, 1, 1, 0.7)
  end
end

function this:_generate(parent, pool)
  local go = pool:syncGameObject(PATH_MAPNODE)
  self.go = go
  self.trans = self.go:GetComponent(_typeRect)
  self.imgNode = self.trans:Find("animroot/nodeIcon"):GetComponent(_typeImg)
  self.goLock = self.trans:Find("animroot/lock").gameObject
  self.btnNode = self.go:GetComponent(_typeBtn)
  self.choose = self.trans:Find("animroot/IsChoose").gameObject
  self.animation = self.go:GetComponent(typeof(C_Animation))
  self.location = self.trans:Find("animroot/nodeIcon/location").gameObject
  self.locationTrans = self.location:GetComponent(typeof(C_RectTransform))
end

function this:refreshLockState()
  local blockTpl = L_GameTpl:getHomeBlockTpl()
  local bTpl = blockTpl:getTplByWorldMapId(self.entityId)
  local bId = blockTpl:getId(bTpl)
  local isUnlock = L_HomeUtil.getIsBlockUnlock(bId)
  self:setIsUnlock(isUnlock)
end

function this:showUnlockEffect()
  if self.goLock then
    self.goLock:ActiveTrans(true)
  end
  local anim = self.trans:Find("animroot/lock"):GetComponent(typeof(C_Animation))
  anim:Play("anim_homearea_unlock")
end

function this:refreshNodeTraceState()
end

return this
