MapGen: fix annotations warnings
This commit is contained in:
@@ -5,9 +5,9 @@ local mathAbs, mathRound, mathMin, mathMax, id
|
|||||||
local pastCalcNoiseValue = {
|
local pastCalcNoiseValue = {
|
||||||
---@type MapGen.Triangle?
|
---@type MapGen.Triangle?
|
||||||
triangle = nil,
|
triangle = nil,
|
||||||
---@type number?
|
---@type integer?
|
||||||
x = nil,
|
x = nil,
|
||||||
---@type number?
|
---@type integer?
|
||||||
z = nil,
|
z = nil,
|
||||||
---@type number?
|
---@type number?
|
||||||
noiseValue = nil,
|
noiseValue = nil,
|
||||||
@@ -353,9 +353,9 @@ end
|
|||||||
|
|
||||||
---Returns `true` if there is a cavern at the specified coordinates.
|
---Returns `true` if there is a cavern at the specified coordinates.
|
||||||
---@param layer MapGen.Layer
|
---@param layer MapGen.Layer
|
||||||
---@param x number
|
---@param x integer
|
||||||
---@param y number
|
---@param y integer
|
||||||
---@param z number
|
---@param z integer
|
||||||
---@return boolean
|
---@return boolean
|
||||||
local function isCavern(layer, x, y, z)
|
local function isCavern(layer, x, y, z)
|
||||||
for _, cavern in ipairs(layer.cavernsList) do
|
for _, cavern in ipairs(layer.cavernsList) do
|
||||||
@@ -376,9 +376,9 @@ end
|
|||||||
---@param humidity number
|
---@param humidity number
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x integer
|
||||||
---@param y number
|
---@param y integer
|
||||||
---@param z number
|
---@param z integer
|
||||||
local function generateNode(mapGenerator, layer, height, temp, humidity, data, index, x, y, z)
|
local function generateNode(mapGenerator, layer, height, temp, humidity, data, index, x, y, z)
|
||||||
local ids = mapGenerator.nodeIDs
|
local ids = mapGenerator.nodeIDs
|
||||||
local waterLevel = layer.waterLevel
|
local waterLevel = layer.waterLevel
|
||||||
@@ -388,6 +388,7 @@ local function generateNode(mapGenerator, layer, height, temp, humidity, data, i
|
|||||||
local scatteringVertical = layer.biomesVerticalScattering or 0
|
local scatteringVertical = layer.biomesVerticalScattering or 0
|
||||||
local scattTemp = temp
|
local scattTemp = temp
|
||||||
local scattHumidity = humidity
|
local scattHumidity = humidity
|
||||||
|
---@type number
|
||||||
local scattHeight = y
|
local scattHeight = y
|
||||||
|
|
||||||
if scatteringGorizontal ~= 0 then
|
if scatteringGorizontal ~= 0 then
|
||||||
@@ -467,9 +468,9 @@ end
|
|||||||
---the triangle's height and specifying the distance to the peak
|
---the triangle's height and specifying the distance to the peak
|
||||||
---for which the weight is calculated.
|
---for which the weight is calculated.
|
||||||
---@param height MapGen.Triangulation.Edge
|
---@param height MapGen.Triangulation.Edge
|
||||||
---@param x number
|
---@param x integer
|
||||||
---@param y number
|
---@param y integer
|
||||||
---@param z number
|
---@param z integer
|
||||||
---@return number
|
---@return number
|
||||||
local function calcWeight(height, x, y, z)
|
local function calcWeight(height, x, y, z)
|
||||||
local pos1 = vector.new(x, y, z)
|
local pos1 = vector.new(x, y, z)
|
||||||
@@ -491,8 +492,8 @@ end
|
|||||||
|
|
||||||
---Returns `true` if the point is within the triangle's region.
|
---Returns `true` if the point is within the triangle's region.
|
||||||
---The barycentric coordinate method is used.
|
---The barycentric coordinate method is used.
|
||||||
---@param px number
|
---@param px integer
|
||||||
---@param pz number
|
---@param pz integer
|
||||||
---@param triangle MapGen.Triangle
|
---@param triangle MapGen.Triangle
|
||||||
local function pointInTriangle(px, pz, triangle)
|
local function pointInTriangle(px, pz, triangle)
|
||||||
local posP = vector.new(px, 0, pz)
|
local posP = vector.new(px, 0, pz)
|
||||||
@@ -521,9 +522,9 @@ end
|
|||||||
---@param category MapGen.Layer.Category
|
---@param category MapGen.Layer.Category
|
||||||
---@param layer MapGen.Layer
|
---@param layer MapGen.Layer
|
||||||
---@param triangle MapGen.Triangle
|
---@param triangle MapGen.Triangle
|
||||||
---@param x number
|
---@param x integer
|
||||||
---@param y number
|
---@param y integer
|
||||||
---@param z number
|
---@param z integer
|
||||||
---@return number
|
---@return number
|
||||||
local function calcNoise2dValue(category, layer, triangle, x, y, z)
|
local function calcNoise2dValue(category, layer, triangle, x, y, z)
|
||||||
local peak1 = triangle.p1
|
local peak1 = triangle.p1
|
||||||
@@ -561,9 +562,9 @@ end
|
|||||||
---Returns `nil` if the point is not included in any triangle.
|
---Returns `nil` if the point is not included in any triangle.
|
||||||
---@param category MapGen.Layer.Category
|
---@param category MapGen.Layer.Category
|
||||||
---@param layer MapGen.Layer
|
---@param layer MapGen.Layer
|
||||||
---@param x number
|
---@param x integer
|
||||||
---@param y number
|
---@param y integer
|
||||||
---@param z number
|
---@param z integer
|
||||||
---@return number?
|
---@return number?
|
||||||
function MapGen:getNoises2dValue(category, layer, x, y, z)
|
function MapGen:getNoises2dValue(category, layer, x, y, z)
|
||||||
---@type MapGen.PastCalcNoiseValue
|
---@type MapGen.PastCalcNoiseValue
|
||||||
@@ -696,9 +697,9 @@ end
|
|||||||
---@param mapGenerator MapGen
|
---@param mapGenerator MapGen
|
||||||
---@param data number[]
|
---@param data number[]
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param x number
|
---@param x integer
|
||||||
---@param y number
|
---@param y integer
|
||||||
---@param z number
|
---@param z integer
|
||||||
local function generatorHandler(mapGenerator, data, index, x, y, z)
|
local function generatorHandler(mapGenerator, data, index, x, y, z)
|
||||||
-- If the node belongs to a static layer, then a static node is generated.
|
-- If the node belongs to a static layer, then a static node is generated.
|
||||||
local static = mapGenerator:getStaticByHeight(y)
|
local static = mapGenerator:getStaticByHeight(y)
|
||||||
@@ -732,8 +733,8 @@ end
|
|||||||
|
|
||||||
---Chunk generation handler.
|
---Chunk generation handler.
|
||||||
---@param voxelManip VoxelManip
|
---@param voxelManip VoxelManip
|
||||||
---@param minPos table
|
---@param minPos Position
|
||||||
---@param maxPos table
|
---@param maxPos Position
|
||||||
---@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
|
||||||
@@ -795,6 +796,7 @@ function MapGen:run()
|
|||||||
error('Only one instance of a `MapGen` class can be running.')
|
error('Only one instance of a `MapGen` class can be running.')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param ... VoxelManip
|
||||||
core.register_on_generated(function(...)
|
core.register_on_generated(function(...)
|
||||||
self:onMapGenerated(...)
|
self:onMapGenerated(...)
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -90,9 +90,9 @@ local function calcCavernWeight(y, smoothDistance, minY, maxY)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---Returns `true` if there is a cavern at the specified coordinates.
|
---Returns `true` if there is a cavern at the specified coordinates.
|
||||||
---@param x number
|
---@param x integer
|
||||||
---@param y number
|
---@param y integer
|
||||||
---@param z number
|
---@param z integer
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function Cavern:isCavern(x, y, z)
|
function Cavern:isCavern(x, y, z)
|
||||||
local minY, maxY = self.minY, self.maxY
|
local minY, maxY = self.minY, self.maxY
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
---@class MapGen.Layer
|
---@class MapGen.Layer
|
||||||
---@field name string
|
---@field name string
|
||||||
---@field minY number
|
---@field minY integer
|
||||||
---@field maxY number
|
---@field maxY integer
|
||||||
---@field minTemp number
|
---@field minTemp integer
|
||||||
---@field maxTemp number
|
---@field maxTemp integer
|
||||||
---@field minHumidity number
|
---@field minHumidity integer
|
||||||
---@field maxHumidity number
|
---@field maxHumidity integer
|
||||||
---@field waterLevel number
|
---@field waterLevel integer
|
||||||
---@field calcTemp fun(self:MapGen.Layer, value:number, height:number):number
|
---@field calcTemp fun(self:MapGen.Layer, value:number, height:number):number
|
||||||
---@field calcHumidity fun(self:MapGen.Layer, value:number, height:number):number
|
---@field calcHumidity fun(self:MapGen.Layer, value:number, height:number):number
|
||||||
---@field peaksList {['landscape']:MapGen.Peak[],['temp']:MapGen.Peak[],['humidity']:MapGen.Peak[]}
|
---@field peaksList {['landscape']:MapGen.Peak[],['temp']:MapGen.Peak[],['humidity']:MapGen.Peak[]}
|
||||||
@@ -15,8 +15,8 @@
|
|||||||
---@field biomesByName table<string, MapGen.Biome>
|
---@field biomesByName table<string, MapGen.Biome>
|
||||||
---@field biomesList MapGen.Biome[]
|
---@field biomesList MapGen.Biome[]
|
||||||
---@field biomesDiagram table
|
---@field biomesDiagram table
|
||||||
---@field biomesGorizontalScattering number
|
---@field biomesGorizontalScattering integer
|
||||||
---@field biomesVerticalScattering number
|
---@field biomesVerticalScattering integer
|
||||||
---@field cavernsByName table<string, MapGen.Cavern>
|
---@field cavernsByName table<string, MapGen.Cavern>
|
||||||
---@field cavernsList MapGen.Cavern[]
|
---@field cavernsList MapGen.Cavern[]
|
||||||
---@field trianglesList {['landscape']:MapGen.Triangle[],['temp']:MapGen.Triangle[],['humidity']:MapGen.Triangle[]}
|
---@field trianglesList {['landscape']:MapGen.Triangle[],['temp']:MapGen.Triangle[],['humidity']:MapGen.Triangle[]}
|
||||||
@@ -130,7 +130,7 @@ end
|
|||||||
---@param color ColorString
|
---@param color ColorString
|
||||||
---@param noiseParams NoiseParams
|
---@param noiseParams NoiseParams
|
||||||
function Layer:addNoiseParamsColor(category, color, noiseParams)
|
function Layer:addNoiseParamsColor(category, color, noiseParams)
|
||||||
color = core.colorspec_to_colorstring(core.colorspec_to_table(color))
|
color = Smc.fixColorString(color)
|
||||||
|
|
||||||
local noisesParams = self.noisesParamsByColor
|
local noisesParams = self.noisesParamsByColor
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ end
|
|||||||
---@param color ColorString
|
---@param color ColorString
|
||||||
---@return ValueNoise
|
---@return ValueNoise
|
||||||
function Layer:getNoiseByColor(category, color)
|
function Layer:getNoiseByColor(category, color)
|
||||||
color = core.colorspec_to_colorstring(core.colorspec_to_table(color))
|
color = Smc.fixColorString(color)
|
||||||
|
|
||||||
local noises = self.noisesByColor
|
local noises = self.noisesByColor
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ local function ff2luat(filepath, backgroundColor)
|
|||||||
|
|
||||||
if not backgroundColor then backgroundColor = '#000000FF' end
|
if not backgroundColor then backgroundColor = '#000000FF' end
|
||||||
--HACK: normalizing colorstring for future string comparison ('#000' -> '#000000FF')
|
--HACK: normalizing colorstring for future string comparison ('#000' -> '#000000FF')
|
||||||
backgroundColor = core.colorspec_to_colorstring(core.colorspec_to_table(backgroundColor))
|
backgroundColor = Smc.fixColorString(backgroundColor)
|
||||||
|
|
||||||
---@type ColoredDotsTable
|
---@type ColoredDotsTable
|
||||||
local dots = { size = { w = uintb2num(ff:sub(9,12)), h = uintb2num(ff:sub(13,16)) } }
|
local dots = { size = { w = uintb2num(ff:sub(9,12)), h = uintb2num(ff:sub(13,16)) } }
|
||||||
@@ -83,7 +83,7 @@ local function ff2luat(filepath, backgroundColor)
|
|||||||
}
|
}
|
||||||
|
|
||||||
---@type string @ColorString
|
---@type string @ColorString
|
||||||
local color = core.colorspec_to_colorstring(colorT)
|
local color = core.colorspec_to_colorstring(colorT) or ''
|
||||||
|
|
||||||
if color ~= backgroundColor then
|
if color ~= backgroundColor then
|
||||||
if not dots[color] then
|
if not dots[color] then
|
||||||
|
|||||||
Reference in New Issue
Block a user