diff --git a/mods/CORE/MapGen/src/MapGen.lua b/mods/CORE/MapGen/src/MapGen.lua index 09bdd51..394094d 100644 --- a/mods/CORE/MapGen/src/MapGen.lua +++ b/mods/CORE/MapGen/src/MapGen.lua @@ -132,7 +132,7 @@ end --- ---Note: layers must not overlap. ---@param name string The name that will be assigned to the layer. The name must be unique for each layer. ----@param def MapGen.LayerDef Layer description table, see details `MapGen.LayerDef` +---@param def MapGen.LayerDef Layer description table, see details `MapGen.LayerDef`. function MapGen:registerLayer(name, def) -- Layers with the same name cannot exist. assert(self.layersByName[name] == nil, ('A layer named `%s` is already registered.'):format(name)) @@ -152,10 +152,11 @@ function MapGen:registerLayer(name, def) end) end ----@param layerName string ----@param category MapGen.Layer.Category TODO: описание ----@param color ColorString TODO: описание ----@param noiseParams NoiseParams +---Register the color and the noise parameters that correspond to it. +---@param layerName string The name of the layer for which the color will be registered. +---@param category MapGen.Layer.Category Category indicating what will be generated by noise. +---@param color ColorString Noise color. Must be unique. +---@param noiseParams NoiseParams Fractal noise parameters. function MapGen:registerLayerNoiseColor(layerName, category, color, noiseParams) ---@type MapGen.Layer local layer = self.layersByName[layerName] @@ -168,8 +169,8 @@ end ---Mark the world area between two heights as a `MapGen.StaticLayer`. --- ---Note: layers must not overlap. ----@param name string The name that will be assigned to the static layer. The name must be unique for each layer. ----@param def MapGen.StaticLayerDef Static layer description table, see details `MapGen.StaticLayerDef` +---@param name string The name that will be assigned to the static layer. The name must be unique for each layer. +---@param def MapGen.StaticLayerDef Static layer description table, see details `MapGen.StaticLayerDef`. function MapGen:registerStaticLayer(name, def) -- Static layer with the same name cannot exist. assert(self.staticsByName[name] == nil, ('A static layer named `%s` is already registered.'):format(name)) @@ -189,12 +190,12 @@ function MapGen:registerStaticLayer(name, def) end) end ----Mark a world point as `MapGen.Peak` and assign it a specific noise that will affect the generation. +---Mark a world point as `MapGen.Peak` and assign it a specific color that will affect the generation. --- ---Note: The peaks shouldn't overlap. This won't cause any errors, but it might ruin the generation. ----@param layerName string The name of the layer in which the new peak will be included. ----@param category MapGen.Layer.Category TODO: описание ----@param def MapGen.PeakDef +---@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 def MapGen.PeakDef Peak description table, see details `MapGen.PeakDef`. function MapGen:registerPeak(layerName, category, def) ---@type MapGen.Layer local layer = self.layersByName[layerName] @@ -209,13 +210,13 @@ function MapGen:registerPeak(layerName, category, def) layer:addPeak(category, peak) end ----Mark a world point as `MapGen.Peak` and assign it a specific noise that will affect the generation. +---Mark a world point as `MapGen.Peak` and assign it a specific color that will affect the generation. ---The Y coordinate will be forced to zero, and the `is2d` group will be added to the groups field. --- ---Note: The peaks shouldn't overlap. This won't cause any errors, but it might ruin the generation. ----@param layerName string The name of the layer in which the new peak will be included. ----@param category MapGen.Layer.Category TODO: описание ----@param def MapGen.PeakDef +---@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 def MapGen.PeakDef Peak description table, see details `MapGen.PeakDef`. function MapGen:register2DPeak(layerName, category, def) def = table.copy_with_metatables(def) @@ -234,22 +235,22 @@ end ---The Y coordinate will be forced to zero, and the `is2d` group will be added to the groups field. --- ---Note: The peaks shouldn't overlap. This won't cause any errors, but it might ruin the generation. ----@param layerName string The name of the layer in which the new peaks will be included. ----@param category MapGen.Layer.Category TODO: описание ----@param defs MapGen.PeakDef[] +---@param layerName string The name of the layer in which the new peaks will be included. +---@param category MapGen.Layer.Category Category indicating what will be generated by peaks. +---@param defs MapGen.PeakDef[] Peaks description table, see details `MapGen.PeakDef`. function MapGen:register2DPeaks(layerName,category, defs) for _, def in ipairs(defs) do self:register2DPeak(layerName, category, def) end end ----TODO: описание +---Extract the `MapGen.Peak` from the image and assign them all a specific color that will affect the generation. ---@param layerName string The name of the layer in which the new peaks will be included. ----@param map string TODO: описание ----@param scale number TODO: описание ----@param zeroPos Position2d TODO: описание ----@param category MapGen.Layer.Category TODO: описание ----@param groups? table +---@param map string The name of the image from which the peaks will be extracted. It should be located in the `/textures/maps` folder and have the following format `.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 zeroPos Position2d 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 groups? table Groups that will be added to all peaks. function MapGen:register2DPeaksFromFile(layerName, map, scale,zeroPos, category, groups) local modPath = core.get_modpath(core.get_current_modname()) local peaks = ff2luat(modPath .. '/textures/maps/' .. map) @@ -315,6 +316,7 @@ function MapGen:initLayersTriangultaion() end end +---Initialize all layer noises. This should be called after the map object is loaded. function MapGen:initLayersNoises() ---@param layer MapGen.Layer for _, layer in ipairs(self.layersList) do diff --git a/mods/CORE/MapGen/src/MapGen/Layer.lua b/mods/CORE/MapGen/src/MapGen/Layer.lua index ed5551e..481e320 100644 --- a/mods/CORE/MapGen/src/MapGen/Layer.lua +++ b/mods/CORE/MapGen/src/MapGen/Layer.lua @@ -107,11 +107,12 @@ function Layer:new(name, def) return instance end +---A category of noise that affects specific map generation objects. ---@alias MapGen.Layer.Category 'landscape'|'temp'|'humidity' ---Adds a peak to the `Layer.peaksList` ----@param category MapGen.Layer.Category TODO: описание ----@param peak MapGen.Peak TODO: описание +---@param category MapGen.Layer.Category +---@param peak MapGen.Peak function Layer:addPeak(category, peak) if category == 'landscape' then table.insert(self.peaksList.landscape, peak) @@ -125,8 +126,8 @@ function Layer:addPeak(category, peak) end ---Adds a NoiseParams color to the `Layer.noisesParamsByColor` ----@param category MapGen.Layer.Category TODO: описание ----@param color ColorString TODO: описание +---@param category MapGen.Layer.Category +---@param color ColorString ---@param noiseParams NoiseParams function Layer:addNoiseParamsColor(category, color, noiseParams) color = core.colorspec_to_colorstring(core.colorspec_to_table(color)) @@ -148,8 +149,8 @@ function Layer:addNoiseParamsColor(category, color, noiseParams) end ---Returns noise corresponding to a color. ----@param category MapGen.Layer.Category TODO: описание ----@param color ColorString TODO: описание +---@param category MapGen.Layer.Category +---@param color ColorString ---@return ValueNoise function Layer:getNoiseByColor(category, color) color = core.colorspec_to_colorstring(core.colorspec_to_table(color))