From bb530451d568738a665a6ac450375cf81f3ae3bf Mon Sep 17 00:00:00 2001 From: Doloment Date: Thu, 25 Sep 2025 22:11:25 +0700 Subject: [PATCH] Rename MapGenV -> MapGen; Fix name of a MapGen instance --- mods/CORE/{MapGenV => MapGen}/init.lua | 10 +++++----- mods/CORE/{MapGenV => MapGen}/mod.conf | 0 mods/CORE/{MapGenV => MapGen}/src/MapGen.lua | 18 +++++++++--------- .../{MapGenV => MapGen}/src/MapGen/Layer.lua | 10 +++++----- .../{MapGenV => MapGen}/src/MapGen/Region.lua | 16 ++++++++-------- .../src/MapGen/Region/Noises.lua | 2 +- 6 files changed, 28 insertions(+), 28 deletions(-) rename mods/CORE/{MapGenV => MapGen}/init.lua (69%) rename mods/CORE/{MapGenV => MapGen}/mod.conf (100%) rename mods/CORE/{MapGenV => MapGen}/src/MapGen.lua (95%) rename mods/CORE/{MapGenV => MapGen}/src/MapGen/Layer.lua (90%) rename mods/CORE/{MapGenV => MapGen}/src/MapGen/Region.lua (65%) rename mods/CORE/{MapGenV => MapGen}/src/MapGen/Region/Noises.lua (82%) diff --git a/mods/CORE/MapGenV/init.lua b/mods/CORE/MapGen/init.lua similarity index 69% rename from mods/CORE/MapGenV/init.lua rename to mods/CORE/MapGen/init.lua index f420bb3..3565958 100644 --- a/mods/CORE/MapGenV/init.lua +++ b/mods/CORE/MapGen/init.lua @@ -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() \ No newline at end of file +mapGenerator:enable() \ No newline at end of file diff --git a/mods/CORE/MapGenV/mod.conf b/mods/CORE/MapGen/mod.conf similarity index 100% rename from mods/CORE/MapGenV/mod.conf rename to mods/CORE/MapGen/mod.conf diff --git a/mods/CORE/MapGenV/src/MapGen.lua b/mods/CORE/MapGen/src/MapGen.lua similarity index 95% rename from mods/CORE/MapGenV/src/MapGen.lua rename to mods/CORE/MapGen/src/MapGen.lua index 493ab94..b298483 100644 --- a/mods/CORE/MapGenV/src/MapGen.lua +++ b/mods/CORE/MapGen/src/MapGen.lua @@ -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) diff --git a/mods/CORE/MapGenV/src/MapGen/Layer.lua b/mods/CORE/MapGen/src/MapGen/Layer.lua similarity index 90% rename from mods/CORE/MapGenV/src/MapGen/Layer.lua rename to mods/CORE/MapGen/src/MapGen/Layer.lua index 84adfe0..cd0954d 100644 --- a/mods/CORE/MapGenV/src/MapGen/Layer.lua +++ b/mods/CORE/MapGen/src/MapGen/Layer.lua @@ -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 ( diff --git a/mods/CORE/MapGenV/src/MapGen/Region.lua b/mods/CORE/MapGen/src/MapGen/Region.lua similarity index 65% rename from mods/CORE/MapGenV/src/MapGen/Region.lua rename to mods/CORE/MapGen/src/MapGen/Region.lua index 1b23318..c4e6567 100644 --- a/mods/CORE/MapGenV/src/MapGen/Region.lua +++ b/mods/CORE/MapGen/src/MapGen/Region.lua @@ -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, diff --git a/mods/CORE/MapGenV/src/MapGen/Region/Noises.lua b/mods/CORE/MapGen/src/MapGen/Region/Noises.lua similarity index 82% rename from mods/CORE/MapGenV/src/MapGen/Region/Noises.lua rename to mods/CORE/MapGen/src/MapGen/Region/Noises.lua index 00bd35c..25abb33 100644 --- a/mods/CORE/MapGenV/src/MapGen/Region/Noises.lua +++ b/mods/CORE/MapGen/src/MapGen/Region/Noises.lua @@ -1,5 +1,5 @@ ---Only for EmmyLua ----@class MapGenV.Region.Noises +---@class MapGen.Region.Noises ---@field landscapeNoise table? ---@field tempNoise table? ---@field humidityNoise table?