local system_constructor = require("love_src.wrapper.Concord.system")
local debug_label = require("love_src.src.world.common.component.debug_label")
local transform = require("love_src.src.world.common.component.transform")

local system = {}

system.__index = system

system.pool = {
  pool = {
    debug_label.dict.debug_label,
    transform.dict.position
  }
}

system.components = {
  [debug_label.dict.debug_label] = debug_label.debug_label,
  [transform.dict.position] = transform.position
}

function system.new()
  local new_system = system_constructor.new("debug_world_draw", system.pool)
  if (new_system) then
    for k, v in pairs(system) do
		  new_system[k] = v
	  end
    return new_system
  else
    return nil
  end
end

local function draw(text, x, y)
  love.graphics.push()
  love.graphics.print(text, x, y)
  love.graphics.pop()
end

function system:draw()
  for _, e in ipairs(self.pool) do
    local text = e[debug_label.dict.debug_label].data
    local x = e[transform.dict.position].data[1]
    local y = e[transform.dict.position].data[2]
    draw(text, x, y)
  end
end

return system
