local this = class("roguePointTpl")

function this:init(config)
  self.data = config
  self.cityDic = {}
  for i, v in pairs(config) do
    if not self.cityDic[v.cityId] then
      self.cityDic[v.cityId] = {}
    end
    if not self.cityDic[v.cityId][v.type] then
      self.cityDic[v.cityId][v.type] = {}
    end
    table.insert(self.cityDic[v.cityId][v.type], v)
  end
end

function this:getTplById(id)
  return self.data[id]
end

function this:getBorthPoint(tpl)
  return tpl.borthPoint
end

function this:getId(tpl)
  return tpl.id
end

function this:getType(tpl)
  return tpl.type
end

function this:getCityId(tpl)
  return tpl.cityId
end

function this:getName(tpl)
  return L_Config:provider(tpl.name)
end

function this:getPositionById(id)
  local tpl = self:getTplById(id)
  return self:getPositionByTpl(tpl)
end

function this:getRotationById(id)
  local tpl = self:getTplById(id)
  return self:getRotationByTpl(tpl)
end

function this:getPositionByTpl(tpl)
  local p = tpl.borthPoint
  return {
    x = p[1],
    y = p[2],
    z = p[3]
  }
end

function this:getPositionByTpl(tpl)
  local p = tpl.borthPoint
  return {
    x = p[1],
    y = p[2],
    z = p[3]
  }
end

function this:getRotationByTpl(tpl)
  local p = tpl.borthPoint
  return {
    x = p[4],
    y = p[5],
    z = p[6]
  }
end

function this:getRangeByTpl(tpl)
  return tpl.radius
end

function this:getTplListByCityIdAndType(cityId, type)
  return self.cityDic[cityId][type]
end

return this
