Entity: add getExtended method
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user