Entity: add getExtended method

This commit is contained in:
Van
2026-02-09 18:16:14 +03:00
parent ec8499ff76
commit 660c96ab5c

View File

@@ -1,4 +1,4 @@
local getInstance = Class.getInstance
local getInstance, extend = Class.getInstance, Class.extend
local tableCopy, tableMerge = table.copy, table.merge
@@ -65,4 +65,20 @@ function Entity:new(entityDef)
return instance
end
---Allows you to create a child class of an entity by specifying
---default parameters that will be added to the entity's parameters
---when an instance is received.
---@param defaultDef Entity.EntityDefinition
---@return Entity
function Entity:getExtended(defaultDef)
defaultDef = defMerge(self.defaultDef, defaultDef)
---@type Entity
local ChildClass = extend(self, {
defaultDef = defaultDef,
})
return ChildClass
end
return Entity