local this = class("cellInteractOption", G_UIModuleBase)
local _interactiveTpl = L_GameTpl:getWorldInteractivetypeTpl()

function this.bind()
  return {
    txt_key = L_WordsTpl:getValue("ui_cellMapInteractive"),
    size_key = C_Vector2(72, 0),
    img_icon = "",
    txt_content = "",
    activeSelect = false,
    activeSelectTip = false
  }
end

function this.methods()
  return {
    onClick = function(self)
      self:invokeClick()
    end
  }
end

function this:open(options)
  local txt = L_WordsTpl:getValue("notice_homeProduction_34") .. L_SettingStore:getSetData(L_Const.settingType.interaction) .. " "
  self.bind.txt_key = txt
  self.bind.size_key = C_Vector2(string.len(txt) * 9, 0)
  local optionData = self.bind.optionData
  local interType = optionData.interactType
  local tpl = _interactiveTpl:getTplById(interType)
  local icon = _interactiveTpl:getIcon(tpl)
  self.bind.img_icon = icon
  self.bind.txt_content = optionData.displayName
  self._callback = optionData.onExecute
end

function this:invokeClick()
  if self._callback then
    self._callback()
  end
end

function this:refreshState()
  local isSelect = self.parent.selectedOption == self.bind.index
  self.bind.activeSelect = isSelect
  self.bind.activeSelectTip = isSelect
end

return this
