Rename MapGenV -> MapGen; Fix name of a MapGen instance

This commit is contained in:
2025-09-25 22:11:25 +07:00
parent 3ce1e3786c
commit bb530451d5
6 changed files with 28 additions and 28 deletions

View File

@@ -6,12 +6,12 @@ Api.addModToGlobalSpace(MapGen, 'Core.MapGen')
-- DEBUG MAPGEN
---@type MapGenV
local MapGen = MapGen.Class:new()
---@type MapGen
local mapGenerator = MapGen.Class:new()
MapGen:RegisterLayer("world", -1000, 500)
mapGenerator:RegisterLayer("world", -1000, 500)
MapGen:RegisterRegion("world",
mapGenerator:RegisterRegion("world",
{x = -1000, y = 0, z = -1000},
{x = 1000, y = 0, z = 1000},
{
@@ -27,4 +27,4 @@ MapGen:RegisterRegion("world",
},
true)
MapGen:enable()
mapGenerator:enable()

View File

@@ -17,13 +17,13 @@ local require = modInfo.require
-- -@type MapGen.Utils
---local MapGenUtils = require("MapGen.Utils")
---@type MapGenV.Layer
---@type MapGen.Layer
local Layer = require("MapGen.Layer")
---@type MapGenV.Region
---@type MapGen.Region
local Region= require("MapGen.Region")
---@class MapGenV
---@class MapGen
---@field layersByName table
---@field layersList table
---@field isEnable boolean A static field that guarantees that only one instance of the `MapGen` class will work.
@@ -43,14 +43,14 @@ function MapGen:new()
end
---@param yPos number
---@return MapGenV.Layer?
---@return MapGen.Layer?
function MapGen:getLayerByHeight(yPos)
--- TODO: возможно здесь получится сделать более оптимизированный алгоритм
--- учитывая тот факт, что эта функция вызывается для каждой ноды в on_generated
--- и может быть даже не один раз
--- Можно подумать над тем, чтобы использовать сортированный список
---@param layer MapGenV.Layer
---@param layer MapGen.Layer
for _, layer in ipairs(self.layersList) do
if yPos >= layer.minY and yPos <= layer.maxY then
@@ -69,7 +69,7 @@ function MapGen:RegisterLayer(name, minY, maxY)
error('Registered layers must not overlap!')
end
---@type MapGenV.Layer
---@type MapGen.Layer
local layer = Layer:new(name, minY, maxY)
self.layersByName[name] = layer
@@ -87,7 +87,7 @@ end
---@param noises table
---@param regionIs2D boolean?
function MapGen:RegisterRegion(layerName, minPos, maxPos, noises, regionIs2D)
---@type MapGenV.Layer
---@type MapGen.Layer
local layer = self.layersByName[layerName]
if not layer then
@@ -99,7 +99,7 @@ function MapGen:RegisterRegion(layerName, minPos, maxPos, noises, regionIs2D)
maxPos.y = layer.maxY
end
---@type MapGenV.Region
---@type MapGen.Region
local region = Region:new(minPos, maxPos, noises)
--TODO: реализовать регистрацию допольнительных регионов для сглаживания шумов
@@ -129,7 +129,7 @@ function MapGen:landscapeGeneration(data, area, x, y, z)
local noiseHeightValue = 0
-- The height noise values ​​of all regions that a node is part of are added together...
---@param region MapGenV.Region
---@param region MapGen.Region
for _, region in ipairs(regions) do
if region.noises.landscapeNoise ~= nil then
local noise = core.get_value_noise(region.noises.landscapeNoise)

View File

@@ -1,4 +1,4 @@
---@class MapGenV.Layer
---@class MapGen.Layer
---@field name string
---@field minY number
---@field maxY number
@@ -10,9 +10,9 @@ local Layer = {
---@param name string
---@param minY number
---@param maxY number
---@return MapGenV.Layer
---@return MapGen.Layer
function Layer:new(name, minY, maxY)
---@type MapGenV.Layer
---@type MapGen.Layer
local instance = setmetatable({
name = name,
minY = minY,
@@ -22,7 +22,7 @@ function Layer:new(name, minY, maxY)
return instance
end
---@param region MapGenV.Region
---@param region MapGen.Region
function Layer:addRegion(region)
table.insert(self.regionsList, region)
end
@@ -38,7 +38,7 @@ function Layer:getRegionsByPos(xPos, yPos, zPos)
--- Можно подумать над тем, чтобы использовать сортированный список
local regions = {}
---@param region MapGenV.Region
---@param region MapGen.Region
for _, region in ipairs(self.regionsList) do
if (

View File

@@ -1,13 +1,13 @@
---@class MapGenV.Region
---@class MapGen.Region
---@field minPos table
---@field maxPos table
---@field noises MapGenV.Region.Noises
---@field noises MapGen.Region.Noises
local Region = {}
---@param noisesParams MapGenV.Region.Noises
---@return MapGenV.Region.Noises
---@param noisesParams MapGen.Region.Noises
---@return MapGen.Region.Noises
local function paramsToNoises(noisesParams)
---@type MapGenV.Region.Noises
---@type MapGen.Region.Noises
local noises = {}
for noiseName, noiseParams in pairs(noisesParams) do
@@ -19,10 +19,10 @@ end
---@param minPos table
---@param maxPos table
---@param noisesParams MapGenV.Region.Noises
---@return MapGenV.Region
---@param noisesParams MapGen.Region.Noises
---@return MapGen.Region
function Region:new(minPos, maxPos, noisesParams)
---@type MapGenV.Region
---@type MapGen.Region
local instance = setmetatable({
minPos = minPos,
maxPos = maxPos,

View File

@@ -1,5 +1,5 @@
---Only for EmmyLua
---@class MapGenV.Region.Noises
---@class MapGen.Region.Noises
---@field landscapeNoise table?
---@field tempNoise table?
---@field humidityNoise table?