Item & Node: inheritance from a Class
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
local getInstance, extend = Class.getInstance, Class.extend
|
||||
|
||||
local tableCopy, tableMerge, colorize = table.copy, table.merge, core.colorize
|
||||
|
||||
local ItemFactory = Smc.requireItemFactory()
|
||||
@@ -39,12 +37,12 @@ local RARITY_INDEX = {
|
||||
['unique'] = 0
|
||||
}
|
||||
|
||||
---@class Item
|
||||
---@class Item : Class
|
||||
---@field itemDef Item.ItemDefinition
|
||||
---@field luantiDef ItemDefinition
|
||||
---@field getType fun():string
|
||||
---@field defaultDef Item.ItemDefinition
|
||||
local Item = {
|
||||
local Item = Class:extend({
|
||||
defaultDef = {
|
||||
settings = {
|
||||
name = '',
|
||||
@@ -58,7 +56,7 @@ local Item = {
|
||||
},
|
||||
callbacks = {}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
---Adds an item's rarity tag to the description.
|
||||
---@param rarity Item.Rarity
|
||||
@@ -180,7 +178,7 @@ function Item:new(itemDef)
|
||||
end
|
||||
|
||||
---@type Item
|
||||
local instance = getInstance(self, {})
|
||||
local instance = self:getInstance({})
|
||||
|
||||
local luantiDef = itemDefToLuantiDef(itemDef)
|
||||
local type = itemDef.settings._type
|
||||
@@ -221,7 +219,7 @@ function Item:getExtended(defaultDef)
|
||||
defaultDef = tableMerge(defaultDef, self.defaultDef, true)
|
||||
|
||||
---@type Item
|
||||
local ChildClass = extend(self, {
|
||||
local ChildClass = self:extend({
|
||||
defaultDef = defaultDef,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user