local Concord = require("lib.Concord")

-- Modules
local Entity     = Concord.entity
local Component  = Concord.component
local System     = Concord.system
local World      = Concord.world

-- Containers
local Components  = Concord.components

local constructor = {}

function constructor.default_component_lambda(c, data)
  c.data = data
end

--- build component ecs component
---@param name string
---@param lambda? function(c, data)
function constructor.component(name, lambda)
  local ok, value = Components.try(name)
  if not ok then
    return Component(name, lambda or constructor.default_component_lambda)
  end
end

--- build component ecs state
---@param name string
function constructor.state(name)
  local ok, value = Components.try(name)
  if not ok then
    return Component(name)
  end
end

return constructor
