mirror of
https://github.com/Keyslam-Group/Concord.git
synced 2025-09-01 11:53:57 -04:00
Usability improvements
- Now entity.key() is the same as entity.key.value - Entity:serialize only serializes component given correctly - Any other value inside the Entity is ignored - Disable some diagnostics used in Lua language server by sumneko
This commit is contained in:
parent
cf05cfc972
commit
9bccd05019
5 changed files with 9 additions and 1 deletions
|
@ -1 +1,2 @@
|
|||
---@diagnostic disable: lowercase-global
|
||||
std="love+luajit"
|
||||
|
|
|
@ -22,6 +22,10 @@ function Key:deserialize (data)
|
|||
self.value = getKey(self, data)
|
||||
end
|
||||
|
||||
function Key.__mt:__call()
|
||||
return self.value
|
||||
end
|
||||
|
||||
function Key:removed (replaced)
|
||||
if not replaced then
|
||||
local entity = self.__entity
|
||||
|
|
|
@ -95,6 +95,7 @@ end
|
|||
function Component:__initialize(entity, ...)
|
||||
local component = self:__new(entity)
|
||||
|
||||
---@diagnostic disable-next-line: redundant-parameter
|
||||
self.__populate(component, ...)
|
||||
|
||||
return component
|
||||
|
|
|
@ -248,7 +248,8 @@ function Entity:serialize(ignoreKey)
|
|||
if not ignoreKey then
|
||||
data.key = component.value
|
||||
end
|
||||
elseif (name ~= "__world") and (name ~= "__isEntity") and (component.__name == name) then
|
||||
--We only care about components that were properly given to the entity
|
||||
elseif Type.isComponent(component) and (component.__name == name) then
|
||||
local componentData = component:serialize()
|
||||
|
||||
if componentData ~= nil then
|
||||
|
|
|
@ -476,6 +476,7 @@ end
|
|||
|
||||
return setmetatable(World, {
|
||||
__call = function(_, ...)
|
||||
---@diagnostic disable-next-line: redundant-parameter
|
||||
return World.new(...)
|
||||
end,
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue