Annotations changes: clarification of types, addition of missing annotations
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
---Luanti mod
|
---Luanti mod
|
||||||
---@class Mod
|
---@class Mod
|
||||||
---@field public name string Technical name of the mod.
|
---@field name string Technical name of the mod.
|
||||||
---@field public shortName string
|
---@field shortName string
|
||||||
---@field public path string Path to the mod folder.
|
---@field path string Path to the mod folder.
|
||||||
---@field public Class table A public class that provides a mod.
|
---@field Class table A public class that provides a mod.
|
||||||
---@field public require fun(FileName:string):table
|
---@field require fun(FileName:string):table
|
||||||
Mod = {}
|
Mod = {}
|
||||||
|
|
||||||
---Returns the mod name without prefixes
|
---Returns the mod name without prefixes
|
||||||
@@ -29,40 +29,36 @@ end
|
|||||||
|
|
||||||
function Mod:new()
|
function Mod:new()
|
||||||
---@type Mod
|
---@type Mod
|
||||||
self = setmetatable(Mod.getInfo(), { __index = self })
|
local instance = setmetatable(Mod.getInfo(), { __index = self })
|
||||||
|
|
||||||
return self
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
---Get an instance of a public class provided by a mod
|
---Get an instance of a public class provided by a mod
|
||||||
---@param ... any?
|
---@param ... any?
|
||||||
---@return table
|
---@return table
|
||||||
-- TODO: возможно стоит создать какой-то абстрактный класс,
|
|
||||||
-- который будет является алеасом на table и будет обозначать наш класс
|
|
||||||
function Mod:getModClassInstance(...)
|
function Mod:getModClassInstance(...)
|
||||||
local instance = self.Class:new(...)
|
local classInstance = self.Class:new(...)
|
||||||
|
|
||||||
return instance
|
return classInstance
|
||||||
end
|
end
|
||||||
|
|
||||||
---Inherits a child class from a parent class
|
---Inherits a child class from a parent class
|
||||||
---@static
|
|
||||||
---@param ParentClass table
|
---@param ParentClass table
|
||||||
---@param ChildClass table?
|
---@param ChildClass table?
|
||||||
---@return table
|
---@return table
|
||||||
function Mod:getClassExtended(ParentClass, ChildClass)
|
function Mod:getClassExtended(ParentClass, ChildClass)
|
||||||
local ChildClass = setmetatable(ChildClass or {}, { __index = ParentClass })
|
local childClass = setmetatable(ChildClass or {}, { __index = ParentClass })
|
||||||
|
|
||||||
return ChildClass
|
return childClass
|
||||||
end
|
end
|
||||||
|
|
||||||
---Inherits a child class from a parent public class provided by the mod.
|
---Inherits a child class from a parent public class provided by the mod.
|
||||||
---@static
|
|
||||||
---@param ChildClass table?
|
---@param ChildClass table?
|
||||||
---@return table
|
---@return table
|
||||||
function Mod:getModClassExtended(ChildClass)
|
function Mod:getModClassExtended(ChildClass)
|
||||||
local ChildClass = Mod:getClassExtended(self.Class, ChildClass or {})
|
local childClass = Mod:getClassExtended(self.Class, ChildClass or {})
|
||||||
|
|
||||||
return ChildClass
|
return childClass
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -19,22 +19,27 @@ local Item = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
---The alias `table.merge` for EmmyLua
|
||||||
|
---@type fun(...):(NodeDefinition|ItemDefinition)
|
||||||
|
local defMerge = function(...)
|
||||||
|
return table.merge(...)
|
||||||
|
end
|
||||||
|
|
||||||
---@param itemDef Item.ItemDefinition
|
---@param itemDef Item.ItemDefinition
|
||||||
|
---@return NodeDefinition|ItemDefinition
|
||||||
local function itemDefToLuantiDef(itemDef)
|
local function itemDefToLuantiDef(itemDef)
|
||||||
-- TODO: удалить следующую строчку, когда подключим ide-helper от Алека
|
|
||||||
---@diagnostic disable-next-line: undefined-field
|
|
||||||
itemDef = table.copy(itemDef)
|
itemDef = table.copy(itemDef)
|
||||||
local s = itemDef.settings
|
local s = itemDef.settings
|
||||||
local c = itemDef.callbacks
|
local c = itemDef.callbacks
|
||||||
local description = s.title .. "\n" .. s.description
|
local description = s.title .. "\n" .. s.description
|
||||||
s.title, s.description = nil, description
|
s.title, s.description = nil, description
|
||||||
|
|
||||||
local luantiDef = table.merge(s, c)
|
local luantiDef = defMerge(s, c)
|
||||||
|
|
||||||
return luantiDef
|
return luantiDef
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param luantiDef table
|
---@param luantiDef NodeDefinition|ItemDefinition
|
||||||
local function register3dItem(luantiDef)
|
local function register3dItem(luantiDef)
|
||||||
local ld = luantiDef
|
local ld = luantiDef
|
||||||
local name = ld.name
|
local name = ld.name
|
||||||
@@ -42,7 +47,7 @@ local function register3dItem(luantiDef)
|
|||||||
core.register_node(':'..name, luantiDef)
|
core.register_node(':'..name, luantiDef)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param luantiDef table
|
---@param luantiDef ItemDefinition
|
||||||
local function registerFlatItem(luantiDef)
|
local function registerFlatItem(luantiDef)
|
||||||
local ld = luantiDef
|
local ld = luantiDef
|
||||||
local name = ld.name
|
local name = ld.name
|
||||||
@@ -50,7 +55,7 @@ local function registerFlatItem(luantiDef)
|
|||||||
core.register_craftitem(':'..name, luantiDef)
|
core.register_craftitem(':'..name, luantiDef)
|
||||||
end
|
end
|
||||||
|
|
||||||
---The aleas `table.merge` for EmmyLua
|
---The alias `table.merge` for EmmyLua
|
||||||
---@type fun(...):(Item.ItemDefinition)
|
---@type fun(...):(Item.ItemDefinition)
|
||||||
local defMerge = function(...)
|
local defMerge = function(...)
|
||||||
return table.merge(...)
|
return table.merge(...)
|
||||||
@@ -81,13 +86,13 @@ function Item:new(itemDef)
|
|||||||
registerFlatItem(luantiDef)
|
registerFlatItem(luantiDef)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@return string
|
|
||||||
function instance:getVisual()
|
function instance:getVisual()
|
||||||
return visual
|
return visual
|
||||||
end
|
end
|
||||||
|
|
||||||
instance.itemDef = itemDef
|
instance.itemDef = itemDef
|
||||||
instance.luantiDef = luantiDef
|
instance.luantiDef = luantiDef
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -113,6 +118,7 @@ function Item:getFactory(defaultDef)
|
|||||||
defaultDef = self.defaultDef
|
defaultDef = self.defaultDef
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@type ItemFactory
|
||||||
local instance = Core.ItemFactory():new(self, defaultDef)
|
local instance = Core.ItemFactory():new(self, defaultDef)
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
---@class Item.Callbacks
|
---@class Item.Callbacks
|
||||||
local Callbacks = {}
|
local Callbacks = {}
|
||||||
|
|
||||||
-- TODO: Вписать вместо `table` более определенные классы: ItemStack, ObjectRef и т.п.
|
-- TODO: Разобраться с дубликатами аннотаций полей. Приоритетно брать аннотации из util/ide-helper
|
||||||
|
|
||||||
---Called when the 'place' key was pressed with the item in hand
|
---Called when the 'place' key was pressed with the item in hand
|
||||||
---and pointing at a node.
|
---and pointing at a node.
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
---@class Item.Settings
|
---@class Item.Settings
|
||||||
local Settings = {}
|
local Settings = {}
|
||||||
|
|
||||||
|
-- TODO: Разобраться с дубликатами аннотаций полей. Приоритетно брать аннотации из util/ide-helper
|
||||||
|
|
||||||
---Technical name of the item. Must be unique and have the format `mod_name:item_name`
|
---Technical name of the item. Must be unique and have the format `mod_name:item_name`
|
||||||
---@type string
|
---@type string
|
||||||
Settings.name = ""
|
Settings.name = ""
|
||||||
@@ -70,7 +72,6 @@ Settings.color = nil
|
|||||||
|
|
||||||
---Maximum amount of items that can be in a single stack.
|
---Maximum amount of items that can be in a single stack.
|
||||||
---The default can be changed by the setting `default_stack_max`.
|
---The default can be changed by the setting `default_stack_max`.
|
||||||
---TODO: сделать другой стак по умолчанию?
|
|
||||||
---@type number?
|
---@type number?
|
||||||
Settings.stack_max = nil
|
Settings.stack_max = nil
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ local defMerge = function(...)
|
|||||||
return table.merge(...)
|
return table.merge(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
---@param shortNodeDefs table Table of the form `{ {name, title, description, tiles}, {name, title, description, tiles}, ...}`
|
---@param shortNodeDefs table Table of the form `{ {name, title, description, tiles}, {name, title, description, tiles}, ...}`
|
||||||
---@param addModName boolean? Whether to add the mod name to the settings.name. Default: `true`
|
---@param addModName boolean? Whether to add the mod name to the settings.name. Default: `true`
|
||||||
function ItemFactory:registerNodesByShortDef(shortNodeDefs, addModName)
|
function ItemFactory:registerNodesByShortDef(shortNodeDefs, addModName)
|
||||||
@@ -70,6 +69,7 @@ function ItemFactory:registerNodesByShortDef(shortNodeDefs, addModName)
|
|||||||
tiles = shortNodeDef[4]
|
tiles = shortNodeDef[4]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeDef = defMerge(nodeDef, self.defaultDef, true)
|
nodeDef = defMerge(nodeDef, self.defaultDef, true)
|
||||||
|
|
||||||
if addModName then
|
if addModName then
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ local Region = require("MapGen.Region")
|
|||||||
---@field isRunning boolean A static field that guarantees that only one instance of the `MapGen` class will work.
|
---@field isRunning boolean A static field that guarantees that only one instance of the `MapGen` class will work.
|
||||||
---@field nodeIDs table<string, string>
|
---@field nodeIDs table<string, string>
|
||||||
local MapGen = {
|
local MapGen = {
|
||||||
|
layersByName = {},
|
||||||
|
layersList = {},
|
||||||
multinoiseInitialized = false,
|
multinoiseInitialized = false,
|
||||||
isRunning = false,
|
isRunning = false,
|
||||||
}
|
}
|
||||||
@@ -38,16 +40,15 @@ local MapGen = {
|
|||||||
---@param nodeIDs table<string, string>
|
---@param nodeIDs table<string, string>
|
||||||
---@return MapGen
|
---@return MapGen
|
||||||
function MapGen:new(nodeIDs)
|
function MapGen:new(nodeIDs)
|
||||||
|
---@type MapGen
|
||||||
local instance = setmetatable({
|
local instance = setmetatable({
|
||||||
layersByName = {},
|
|
||||||
layersList = {},
|
|
||||||
nodeIDs = nodeIDs,
|
nodeIDs = nodeIDs,
|
||||||
--registeredRegions = {},
|
|
||||||
}, {__index = self})
|
}, {__index = self})
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Determines which layer a node belongs to based on its height coordinate.
|
||||||
---@param yPos number
|
---@param yPos number
|
||||||
---@return MapGen.Layer?
|
---@return MapGen.Layer?
|
||||||
function MapGen:getLayerByHeight(yPos)
|
function MapGen:getLayerByHeight(yPos)
|
||||||
@@ -66,6 +67,9 @@ function MapGen:getLayerByHeight(yPos)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Mark the world area between two heights as a `MapGen.Layer`.
|
||||||
|
---
|
||||||
|
---Note: layers must not overlap.
|
||||||
---@param name string
|
---@param name string
|
||||||
---@param minY number
|
---@param minY number
|
||||||
---@param maxY number
|
---@param maxY number
|
||||||
@@ -87,12 +91,15 @@ function MapGen:RegisterLayer(name, minY, maxY)
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param layerName string
|
---Mark a region of the world as a cubic region by two opposite vertices.
|
||||||
---@param minPos table
|
---
|
||||||
---@param maxPos table
|
---Regions must be included in layers and may overlap each other.
|
||||||
---@param multinoise table
|
---@param layerName string The name of the layer in which the new region will be included.
|
||||||
---@param regionIs2D boolean?
|
---@param minPos vector
|
||||||
---@param weightFactor number?
|
---@param maxPos vector
|
||||||
|
---@param multinoise table Noise that will be assigned to the region and that will influence map generation
|
||||||
|
---@param regionIs2D boolean? If true, the transmitted Y coordinate will be overwritten by the layer boundaries.
|
||||||
|
---@param weightFactor number? The coefficient by which the reduction in the impact of regional noise on generation will be calculated. If 0, there will be no reduction.
|
||||||
function MapGen:RegisterRegion(layerName, minPos, maxPos, multinoise, regionIs2D, weightFactor)
|
function MapGen:RegisterRegion(layerName, minPos, maxPos, multinoise, regionIs2D, weightFactor)
|
||||||
---@type MapGen.Layer
|
---@type MapGen.Layer
|
||||||
local layer = self.layersByName[layerName]
|
local layer = self.layersByName[layerName]
|
||||||
@@ -106,6 +113,8 @@ function MapGen:RegisterRegion(layerName, minPos, maxPos, multinoise, regionIs2D
|
|||||||
maxPos.y = layer.maxY
|
maxPos.y = layer.maxY
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--TODO: Добавить проверку, что регион не выходит за границы слоя или/и автоматически обрубать регион до слоя
|
||||||
|
|
||||||
if weightFactor == nil then
|
if weightFactor == nil then
|
||||||
weightFactor = 1
|
weightFactor = 1
|
||||||
end
|
end
|
||||||
@@ -131,9 +140,18 @@ function MapGen:initRegionsMultinoise()
|
|||||||
self.multinoiseInitialized = true
|
self.multinoiseInitialized = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Calculate the weight for noise based on
|
||||||
|
---the distance of the point from the center of the region.
|
||||||
|
---
|
||||||
|
---If the `weightFactor` is `0`, then the region's
|
||||||
|
---weight is not calculated and is always equal to `1`.
|
||||||
|
---@param minPos vector
|
||||||
|
---@param maxPos vector
|
||||||
|
---@param x number
|
||||||
|
---@param z number
|
||||||
|
---@param weightFactor number
|
||||||
---@return number
|
---@return number
|
||||||
local function calculateWeight(minPos, maxPos, x, z, weightFactor)
|
local function calculateWeight2D(minPos, maxPos, x, z, weightFactor)
|
||||||
if weightFactor == 0 then
|
if weightFactor == 0 then
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
@@ -187,7 +205,7 @@ local function generatorHandler(mapGenerator, data, index, x, y, z)
|
|||||||
local noise = region:getMultinoise().landscapeNoise
|
local noise = region:getMultinoise().landscapeNoise
|
||||||
|
|
||||||
-- The further a point is from the center of a region, the less noise affects it.
|
-- The further a point is from the center of a region, the less noise affects it.
|
||||||
local weight = calculateWeight(region:getMinPos(), region:getMaxPos(), x, z, region.getWeightFactor())
|
local weight = calculateWeight2D(region:getMinPos(), region:getMaxPos(), x, z, region.getWeightFactor())
|
||||||
|
|
||||||
noiseHeightValue = noiseHeightValue + ( noise:get_2d({x = x, y = z}) * weight )
|
noiseHeightValue = noiseHeightValue + ( noise:get_2d({x = x, y = z}) * weight )
|
||||||
end
|
end
|
||||||
@@ -232,9 +250,12 @@ function MapGen:onMapGenerated(minPos, maxPos, blockseed)
|
|||||||
voxelManip:write_to_map()
|
voxelManip:write_to_map()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Run world generation through this mapgen object
|
||||||
|
---
|
||||||
|
---Note: only one instance of a `MapGen` class can be running.
|
||||||
function MapGen:run()
|
function MapGen:run()
|
||||||
if MapGen.isRunning then
|
if MapGen.isRunning then
|
||||||
error('Only one instance of a `MapGen` class can be used.')
|
error('Only one instance of a `MapGen` class can be running.')
|
||||||
end
|
end
|
||||||
|
|
||||||
core.register_on_generated(function(...)
|
core.register_on_generated(function(...)
|
||||||
|
|||||||
@@ -30,12 +30,14 @@ end
|
|||||||
---@param xPos number
|
---@param xPos number
|
||||||
---@param yPos number
|
---@param yPos number
|
||||||
---@param zPos number
|
---@param zPos number
|
||||||
---@return table
|
---@return MapGen.Region[]
|
||||||
function Layer:getRegionsByPos(xPos, yPos, zPos)
|
function Layer:getRegionsByPos(xPos, yPos, zPos)
|
||||||
--- TODO: возможно здесь получится сделать более оптимизированный алгоритм
|
-- TODO: возможно здесь получится сделать более оптимизированный алгоритм
|
||||||
--- учитывая тот факт, что эта функция вызывается для каждой ноды в on_generated
|
-- учитывая тот факт, что эта функция вызывается для каждой ноды в on_generated
|
||||||
--- и может быть даже не один раз
|
-- и может быть даже не один раз
|
||||||
--- Можно подумать над тем, чтобы использовать сортированный список
|
-- Можно подумать над тем, чтобы использовать сортированный список
|
||||||
|
|
||||||
|
---@type MapGen.Region[]
|
||||||
local regions = {}
|
local regions = {}
|
||||||
|
|
||||||
---@param region MapGen.Region
|
---@param region MapGen.Region
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
-- TODO: replace `table` with `vector` for minPos and maxPos
|
|
||||||
---@class MapGen.Region
|
---@class MapGen.Region
|
||||||
|
---@field getMinPos fun():vector
|
||||||
|
---@field getMaxPos fun():vector
|
||||||
|
---@field getMultinoiseParams fun():MapGen.Region.MultinoiseParams
|
||||||
|
---@field getMultinoise fun():MapGen.Region.Multinoise
|
||||||
|
---@field initMultinoise fun()
|
||||||
|
---@field getWeightFactor fun():number
|
||||||
local Region = {}
|
local Region = {}
|
||||||
|
|
||||||
---@param multinoiseParams MapGen.Region.MultinoiseParams -- ??? TODO: should be it's own class in EmmyLua
|
---@param multinoiseParams MapGen.Region.MultinoiseParams
|
||||||
---@return MapGen.Region.Multinoise
|
---@return MapGen.Region.Multinoise
|
||||||
local function multinoiseParamsToMultinoise(multinoiseParams)
|
local function multinoiseParamsToMultinoise(multinoiseParams)
|
||||||
---@type MapGen.Region.Multinoise
|
---@type MapGen.Region.Multinoise
|
||||||
@@ -15,37 +20,43 @@ local function multinoiseParamsToMultinoise(multinoiseParams)
|
|||||||
return multinoise
|
return multinoise
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param minPos table
|
---@param minPos vector
|
||||||
---@param maxPos table
|
---@param maxPos vector
|
||||||
---@param multinoiseParams MapGen.Region.MultinoiseParams
|
---@param multinoiseParams MapGen.Region.MultinoiseParams
|
||||||
---@param weightFactor number
|
---@param weightFactor number
|
||||||
---@return MapGen.Region
|
---@return MapGen.Region
|
||||||
function Region:new(minPos, maxPos, multinoiseParams, weightFactor)
|
function Region:new(minPos, maxPos, multinoiseParams, weightFactor)
|
||||||
|
|
||||||
|
---@type vector
|
||||||
local _minPos = minPos
|
local _minPos = minPos
|
||||||
|
---@type vector
|
||||||
local _maxPos = maxPos
|
local _maxPos = maxPos
|
||||||
|
---@type MapGen.Region.MultinoiseParams
|
||||||
local _multinoiseParams = multinoiseParams
|
local _multinoiseParams = multinoiseParams
|
||||||
|
|
||||||
if weightFactor < 0 then
|
if weightFactor < 0 then
|
||||||
weightFactor = 1
|
weightFactor = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@type MapGen.Region.Multinoise
|
||||||
local _multinoise = {}
|
local _multinoise = {}
|
||||||
|
|
||||||
|
---@type MapGen.Region
|
||||||
local instance = setmetatable({}, {__index = self})
|
local instance = setmetatable({}, {__index = self})
|
||||||
|
|
||||||
---@return {x:number, y:number, z:number}
|
|
||||||
function instance:getMinPos()
|
function instance:getMinPos()
|
||||||
return _minPos
|
return _minPos
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@return vector
|
||||||
function instance:getMaxPos()
|
function instance:getMaxPos()
|
||||||
return _maxPos
|
return _maxPos
|
||||||
end
|
end
|
||||||
|
|
||||||
function instance:getMultinoiseParams()
|
function instance:getMultinoiseParams()
|
||||||
return _multinoiseParams
|
return _multinoiseParams
|
||||||
end
|
end
|
||||||
|
|
||||||
---@return MapGen.Region.Multinoise
|
|
||||||
function instance:getMultinoise()
|
function instance:getMultinoise()
|
||||||
return _multinoise
|
return _multinoise
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
---For EmmyLua only
|
---For EmmyLua only
|
||||||
|
|
||||||
|
-- TODO: Когда в хелпер добавятся аннотации шумов, надо будет удалить этот класс и заменить его на хелперский
|
||||||
---@class MapGen.Region.NoiseParams
|
---@class MapGen.Region.NoiseParams
|
||||||
---@field offset number
|
---@field offset number
|
||||||
---@field scale number
|
---@field scale number
|
||||||
---@field spread vector -- TODO: describe vector class from Luanti (push Alek)
|
---@field spread vector
|
||||||
---@field seed number
|
---@field seed number
|
||||||
---@field octaves number
|
---@field octaves number
|
||||||
---@field persistence number
|
---@field persistence number
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
---@type Item.Callbacks
|
---@type Item.Callbacks
|
||||||
local ItemCallbacks = Core.Item.require('Item.Callbacks')
|
local ItemCallbacks = Core.Item.require('Item.Callbacks')
|
||||||
|
|
||||||
|
-- TODO: Разобраться с дубликатами аннотаций полей. Приоритетно брать аннотации из util/ide-helper
|
||||||
|
|
||||||
---@class Node.Callbacks : Item.Callbacks
|
---@class Node.Callbacks : Item.Callbacks
|
||||||
local Callbacks = Mod:getClassExtended(ItemCallbacks, {})
|
local Callbacks = Mod:getClassExtended(ItemCallbacks, {})
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
---@type Item.Settings
|
---@type Item.Settings
|
||||||
local ItemSettings = Core.Item.require('Item.Settings')
|
local ItemSettings = Core.Item.require('Item.Settings')
|
||||||
|
|
||||||
|
-- TODO: Разобраться с дубликатами аннотаций полей. Приоритетно брать аннотации из util/ide-helper
|
||||||
|
|
||||||
---@class Node.Settings : Item.Settings
|
---@class Node.Settings : Item.Settings
|
||||||
local Settings = Mod:getClassExtended(ItemSettings, {})
|
local Settings = Mod:getClassExtended(ItemSettings, {})
|
||||||
|
|
||||||
|
|||||||
@@ -9,12 +9,15 @@ local TileSheet = {}
|
|||||||
---@param height number Number of tiles in the table vertically
|
---@param height number Number of tiles in the table vertically
|
||||||
---@return TileSheet
|
---@return TileSheet
|
||||||
function TileSheet:new(image, width, height)
|
function TileSheet:new(image, width, height)
|
||||||
|
---@type TileSheet
|
||||||
local instance = setmetatable({
|
local instance = setmetatable({
|
||||||
image = image,
|
image = image,
|
||||||
width = width,
|
width = width,
|
||||||
height = height,
|
height = height,
|
||||||
}, {__index = self})
|
}, {__index = self})
|
||||||
|
|
||||||
|
-- TODO возможно будет лучше сделать автоматическое определение высоты и ширины по разрешению текстуры
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -28,7 +31,7 @@ function TileSheet:getTextureName(x, y)
|
|||||||
return textureName
|
return textureName
|
||||||
end
|
end
|
||||||
|
|
||||||
---Aleas for `TileSheet:getTextureName`.
|
---Alias for `TileSheet:getTextureName`.
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@return string
|
---@return string
|
||||||
|
|||||||
Reference in New Issue
Block a user