local this = class("moduleBossAreaEnter", G_UIModuleBase)
local _enemyTpl = L_GameTpl:getEnemyTpl()

function this.bind()
  return {active_node = false, txt_tips = ""}
end

function this.methods()
  return {}
end

function this:open()
  L_BattleDataManager:addListener(L_BattleDataManager.event.bossAreaEnter, self.onEvent_bossAreaEnter, self)
  L_BattleDataManager:addListener(L_BattleDataManager.event.playerFightStateChange, self.onEvent_fightStateChange, self)
end

function this:onEvent_bossAreaEnter(bEnter, monsterId)
  if not bEnter then
    self.bind.active_node = false
    return
  end
  local monsterCfg = _enemyTpl:getTplById(monsterId)
  if not monsterCfg then
    return
  end
  self.bind.active_node = true
  self.bind.txt_tips = L_Lang:get(L_WordsTpl:getValue("ui_into_boss_area_tips"), {
    [0] = _enemyTpl:getName(monsterCfg)
  })
end

function this:onEvent_fightStateChange()
  if L_BattleDataManager:checkPlayerBattle() then
    self.bind.active_node = false
  end
end

function this:close()
  L_BattleDataManager:removeListener(L_BattleDataManager.event.bossAreaEnter, self.onEvent_bossAreaEnter, self)
  L_BattleDataManager:removeListener(L_BattleDataManager.event.playerFightStateChange, self.onEvent_fightStateChange, self)
end

function this:activate()
  self:open()
  self:openModules()
  self:show()
  self:showModules()
end

function this:deActivate()
  self:hide()
  self:hideModules()
  self:close()
  self:closeModules()
end

return this
