diff --git a/mods/CORE/Entity/src/Entity.lua b/mods/CORE/Entity/src/Entity.lua index b46df62..2c592e1 100644 --- a/mods/CORE/Entity/src/Entity.lua +++ b/mods/CORE/Entity/src/Entity.lua @@ -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