local base = require("Scene.Monopoly.Base.BaseObject")
local MapDecorate = BaseClass("MapDecorate", base)

function MapDecorate:OnDelete()
  if self.res then
    self.res:Destroy()
    self.res = nil
    self.gameObject = nil
    self.effectNode = nil
    if self.trigger then
      self.trigger.onPointerClick = nil
      self.trigger = nil
    end
    self.triggerTransform = nil
  end
end

function MapDecorate:ArrivalBefore()
  self.res = self:CreateObject(string.format(UIAssets.MonopolyTiles, self.data.pad_before), function(req)
    local pos = self.data:GetLeftLowerWorldPos()
    req.gameObject.transform:Set_position(pos.x + 1, pos.y, pos.z - 1)
    if self.mgr.parent.transform then
      req.gameObject.transform:SetParent(self.mgr.parent.transform)
    end
    self.gameObject = req.gameObject
    self.effectNode = self.gameObject.transform:Find("EffectNode")
    if not IsNull(self.effectNode) then
      local curLandLock = DataCenter.MonopolyManager:GetCurrentLandLock()
      local show = curLandLock <= self.data.land_lock and 1 >= self.data.land_lock - curLandLock
      self.effectNode.gameObject:SetActive(show)
    end
    if self.data.stage_feature_building_id > 0 then
      self.trigger = req.gameObject:GetComponentInChildren(typeof(CS.TouchObjectEventTrigger))
      if self.trigger then
        self.triggerTransform = self.trigger.gameObject.transform
        
        function self.trigger.onPointerClick()
          self:OnTriggerClick()
        end
      end
    end
  end)
end

function MapDecorate:OnTriggerClick()
end

return MapDecorate
