local this = class("worldMapGroupTpl")

function this:init(config)
  self.data = config
end

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

function this:getOffsets(tpl)
  local offsetPos = {}
  local tInsert = table.insert
  for _, v in ipairs(tpl.offsets) do
    tInsert(offsetPos, L_Vector3.new(v[1], v[2], v[3]))
  end
  return offsetPos
end

function this:getPosition(tpl)
  local pos = tpl.position
  return L_Vector3.new(pos[1], pos[2], pos[3])
end

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

function this:getObjects(tpl)
  return tpl.objects
end

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

function this:getSceneId(tpl)
  return tpl.sceneId
end

function this:getAllGroupByWorldId(worldId)
  local groups = {}
  local tInsert = table.insert
  for k, v in pairs(self.data) do
    if v.sceneId == worldId then
      tInsert(groups, k)
    end
  end
  return groups
end

function this:getAI(tpl)
  return tpl.path or ""
end

function this:getAIParam(tpl)
  return tpl.param or ""
end

function this:getCaptain(tpl)
  local captain = tpl.captain
  if captain == 0 and 0 < #tpl.objects then
    captain = tpl.objects[1]
  end
  return captain
end

return this
