mirror of
https://github.com/Keyslam-Group/Concord.git
synced 2025-12-07 13:44:55 -05:00
Add serialization and deserialization functions to component, entity, world
This commit is contained in:
parent
c217183cb9
commit
6cd66e6737
6 changed files with 214 additions and 33 deletions
|
|
@ -20,12 +20,22 @@ function Components.register(name, componentClass)
|
|||
end
|
||||
|
||||
if (rawget(Components, name)) then
|
||||
error("bad argument #2 to 'Components.register' (ComponentClass with name '"..name.."' was already registerd)", 3)
|
||||
error("bad argument #2 to 'Components.register' (ComponentClass with name '"..name.."' was already registerd)", 3) -- luacheck: ignore
|
||||
end
|
||||
|
||||
Components[name] = componentClass
|
||||
componentClass.__name = name
|
||||
end
|
||||
|
||||
function Components.has(name)
|
||||
return Components[name] and true or false
|
||||
end
|
||||
|
||||
function Components.get(name)
|
||||
return Components[name]
|
||||
end
|
||||
|
||||
|
||||
return setmetatable(Components, {
|
||||
__index = function(_, name)
|
||||
error("Attempt to index ComponentClass '"..tostring(name).."' that does not exist / was not registered", 2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue