Submodules: update ide-helper and fix mapgen annotations

This commit is contained in:
Van
2026-02-13 21:22:48 +03:00
parent 9c56db6ac4
commit 8fb4e4db00
4 changed files with 18 additions and 17 deletions

View File

@@ -133,7 +133,7 @@ end
---Returns the `MapGen.Peak` at the coordinates. If there is no peak at these coordinates, it returns `nil`. ---Returns the `MapGen.Peak` at the coordinates. If there is no peak at these coordinates, it returns `nil`.
---@param layer string|MapGen.Layer The layer or name of the layer in which the peak is located. ---@param layer string|MapGen.Layer The layer or name of the layer in which the peak is located.
---@param category MapGen.Layer.Category The category in which the peak is located. ---@param category MapGen.Layer.Category The category in which the peak is located.
---@param pos Position Coordinate of the desired peak. ---@param pos MapPosition Coordinate of the desired peak.
---@return MapGen.Peak? ---@return MapGen.Peak?
function MapGen:getPeakByPos(layer, category, pos) function MapGen:getPeakByPos(layer, category, pos)
if type(layer) == 'string' then if type(layer) == 'string' then
@@ -177,7 +177,7 @@ end
---**Important:** works only in the XZ plane. ---**Important:** works only in the XZ plane.
---@param layer string|MapGen.Layer The layer or name of the layer the triangle is in. ---@param layer string|MapGen.Layer The layer or name of the layer the triangle is in.
---@param category MapGen.Layer.Category The category in which the triangle is in. ---@param category MapGen.Layer.Category The category in which the triangle is in.
---@param pos Position Coordinate of the desired peak. ---@param pos MapPosition Coordinate of the desired peak.
---@return MapGen.Triangle? ---@return MapGen.Triangle?
function MapGen:getTriangleByPos2D(layer, category, pos) function MapGen:getTriangleByPos2D(layer, category, pos)
if type(layer) == 'string' then if type(layer) == 'string' then
@@ -196,7 +196,7 @@ end
---If the point is inside the region, it will also return the distance to the nearest border. ---If the point is inside the region, it will also return the distance to the nearest border.
---@param layer MapGen.Layer The name of the layer in which the region is located. ---@param layer MapGen.Layer The name of the layer in which the region is located.
---@param regionName string The name of the region in which the location of the point is checked. ---@param regionName string The name of the region in which the location of the point is checked.
---@param point Position Point position. ---@param point MapPosition Point position.
---@return boolean, number? ---@return boolean, number?
function MapGen:pointInRegion2D(layer, regionName, point) function MapGen:pointInRegion2D(layer, regionName, point)
local region = layer.regionsByName[regionName] local region = layer.regionsByName[regionName]
@@ -315,7 +315,7 @@ function MapGen:getTriangulateBoundaryVertices(triangles)
end end
-- Walk along boundary edges to create ordered vertex list -- Walk along boundary edges to create ordered vertex list
---@type Position[] ---@type MapPosition[]
local boundary = {} local boundary = {}
---@type table<string, boolean> ---@type table<string, boolean>
local visited = {} local visited = {}
@@ -473,7 +473,7 @@ end
---@param layerName string The name of the layer in which the new peaks will be included. ---@param layerName string The name of the layer in which the new peaks will be included.
---@param map string The name of the image from which the peaks will be extracted. It should be located in the `<mod_name>/textures/maps` folder and have the following format `<image_name>.ff` ---@param map string The name of the image from which the peaks will be extracted. It should be located in the `<mod_name>/textures/maps` folder and have the following format `<image_name>.ff`
---@param scale number Multiplier of how many blocks (nodes) will be between image pixels. It is not recommended to set the value below 50 for performance reasons. ---@param scale number Multiplier of how many blocks (nodes) will be between image pixels. It is not recommended to set the value below 50 for performance reasons.
---@param zeroPos Position2d The position in pixels where the zero world coordinate will be in the image. ---@param zeroPos IntegerPosition2d The position in pixels where the zero world coordinate will be in the image.
---@param category MapGen.Layer.Category Category indicating what will be generated by peaks. ---@param category MapGen.Layer.Category Category indicating what will be generated by peaks.
---@param groups? table<string, number> Groups that will be added to all peaks. ---@param groups? table<string, number> Groups that will be added to all peaks.
function MapGen:register2DPeaksFromFile(layerName, map, scale,zeroPos, category, groups) function MapGen:register2DPeaksFromFile(layerName, map, scale,zeroPos, category, groups)
@@ -495,16 +495,17 @@ function MapGen:register2DPeaksFromFile(layerName, map, scale,zeroPos, category,
for color, peaksPos in pairs(peaks) do for color, peaksPos in pairs(peaks) do
for _, peakPos in ipairs(peaksPos) do for _, peakPos in ipairs(peaksPos) do
---@type integer, integer
x, z = (peakPos.x - zeroPos.x - 1) * scale, (peakPos.y - zeroPos.y - 1) * -scale x, z = (peakPos.x - zeroPos.x - 1) * scale, (peakPos.y - zeroPos.y - 1) * -scale
-- Converting a rectangular grid into an isometric-like one. -- Converting a rectangular grid into an isometric-like one.
if peakPos.y % 2 == 1 then if peakPos.y % 2 == 1 then
x = x + (scale/2) x = mathRound(x + (scale/2))
end end
---@type MapGen.PeakDef ---@type MapGen.PeakDef
local def = { local def = {
pos = vector.new(x, 0, z), pos = {x=x, y=0, z=z},
color = color, color = color,
groups = groups, groups = groups,
} }
@@ -518,7 +519,7 @@ end
---If the peak does not exist, an error will be raised. ---If the peak does not exist, an error will be raised.
---@param layerName string The name of the layer in which the new peak will be included. ---@param layerName string The name of the layer in which the new peak will be included.
---@param category MapGen.Layer.Category Category indicating what will be generated by peak. ---@param category MapGen.Layer.Category Category indicating what will be generated by peak.
---@param pos Position The position of the peak to which the group should be added. ---@param pos MapPosition The position of the peak to which the group should be added.
---@param groups table<string, number> Groups to be added. ---@param groups table<string, number> Groups to be added.
function MapGen:addGroupsToPeakByPos(layerName, category, pos, groups) function MapGen:addGroupsToPeakByPos(layerName, category, pos, groups)
local layer = self:getLayerByName(layerName) local layer = self:getLayerByName(layerName)
@@ -546,7 +547,7 @@ end
---@param layerName string The name of the layer in which the new cavern will be included. ---@param layerName string The name of the layer in which the new cavern will be included.
---@param cavernName string The name to be assigned to the cavern. The name must be unique for each cavern. ---@param cavernName string The name to be assigned to the cavern. The name must be unique for each cavern.
---@param def MapGen.CavernDef Cavern description table, see details `MapGen.CavernDef` ---@param def MapGen.CavernDef Cavern description table, see details `MapGen.CavernDef`
---@param regionVertices Position[]? The region to which the cave generation will be limited. ---@param regionVertices MapPosition[]? The region to which the cave generation will be limited.
function MapGen:registerCavern(layerName, cavernName, def, regionVertices) function MapGen:registerCavern(layerName, cavernName, def, regionVertices)
local layer = self:getLayerByName(layerName) local layer = self:getLayerByName(layerName)
@@ -1023,8 +1024,8 @@ end
---Chunk generation handler. ---Chunk generation handler.
---@param voxelManip VoxelManip ---@param voxelManip VoxelManip
---@param minPos Position ---@param minPos MapPosition
---@param maxPos Position ---@param maxPos MapPosition
---@param blockseed number ---@param blockseed number
function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed) function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed)
-- We obtain a generation area for further manipulations -- We obtain a generation area for further manipulations

View File

@@ -16,14 +16,14 @@ local Peak = {
--- ---
---**Only for EmmyLua.** ---**Only for EmmyLua.**
---@class MapGen.PeakDef ---@class MapGen.PeakDef
---@field pos vector ---@field pos MapPosition
---@field color ColorString ---@field color ColorString
---@field groups? table<string, number> ---@field groups? table<string, number>
---@param def MapGen.PeakDef ---@param def MapGen.PeakDef
---@return MapGen.Peak ---@return MapGen.Peak
function Peak:new(def) function Peak:new(def)
local _pos = def.pos local _pos = vector.new(def.pos)
local _color = def.color local _color = def.color
local _groups local _groups

View File

@@ -4,11 +4,11 @@ local getInstance = Class.getInstance
---@class MapGen.Region ---@class MapGen.Region
---@field name string ---@field name string
---@field vertices Position[] ---@field vertices MapPosition[]
local Region = {} local Region = {}
---@class MapGen.RegionDef ---@class MapGen.RegionDef
---@field vertices Position[] ---@field vertices MapPosition[]
---@param def MapGen.RegionDef ---@param def MapGen.RegionDef
---@return MapGen.Region ---@return MapGen.Region
@@ -50,7 +50,7 @@ local function calcDistanceSq(px, pz, x1, z1, x2, z2)
end end
---Checks if a point is inside a `MapGen.Region` (2D check using x and z coordinates). ---Checks if a point is inside a `MapGen.Region` (2D check using x and z coordinates).
---@param point Position ---@param point MapPosition
---@return boolean, number? ---@return boolean, number?
function Region:pointInRegion(point) function Region:pointInRegion(point)
local vertices = self.vertices local vertices = self.vertices