From d9f9bd7a6c4908698e29ef3142d3d60713599242 Mon Sep 17 00:00:00 2001 From: Vanic Date: Sat, 10 Jan 2026 12:31:19 +0300 Subject: [PATCH] Separate peaks, add layer colors --- mods/CORE/MapGen/src/MapGen/Layer.lua | 46 ++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/mods/CORE/MapGen/src/MapGen/Layer.lua b/mods/CORE/MapGen/src/MapGen/Layer.lua index 7bca95e..96aabb6 100644 --- a/mods/CORE/MapGen/src/MapGen/Layer.lua +++ b/mods/CORE/MapGen/src/MapGen/Layer.lua @@ -9,7 +9,8 @@ ---@field waterLevel number ---@field calcTemp fun(self:MapGen.Layer, value:number, height:number):number ---@field calcHumidity fun(self:MapGen.Layer, value:number, height:number):number ----@field peaksList MapGen.Peak[] +---@field peaksList {['landscape']:MapGen.Peak[],['temp']:MapGen.Peak[],['humidity']:MapGen.Peak[]} +---@field colorsList {['landscape']:table,['temp']:table,['humidity']:table} ---@field biomesByName table ---@field biomesList MapGen.Biome[] ---@field biomesDiagram table @@ -20,7 +21,16 @@ ---@field trianglesList MapGen.Triangle[] ---@field tetrahedronsList MapGen.Tetrahedron[] local Layer = { - peaksList = {}, + peaksList = { + landscape = {}, + temp = {}, + humidity = {}, + }, + colorsList = { + landscape = {}, + temp = {}, + humidity = {}, + }, biomesByName = {}, biomesList = {}, biomesDiagram = {}, @@ -88,9 +98,35 @@ function Layer:new(name, def) end ---Adds a peak to the `Layer.peaksList` ----@param peak MapGen.Peak -function Layer:addPeak(peak) - table.insert(self.peaksList, peak) +---@param category 'landscape'|'temp'|'humidity' +---@param peak MapGen.Peak +function Layer:addPeak(category, peak) + if category == 'landscape' then + table.insert(self.peaksList.landscape, peak) + elseif category == 'temp' then + table.insert(self.peaksList.temp, peak) + elseif category == 'humidity' then + table.insert(self.peaksList.humidity, peak) + else + error(('There is no peak category named %s.'):format(category)) + end +end + +---Adds a color to the `Layer.colorsList` +---@param category 'landscape'|'temp'|'humidity' +---@param color ColorString +function Layer:addColor(category, color) + color = core.colorspec_to_colorstring(core.colorspec_to_table(color)) + + if category == 'landscape' then + table.insert(self.colorsList.landscape, color) + elseif category == 'temp' then + table.insert(self.colorsList.temp, color) + elseif category == 'humidity' then + table.insert(self.colorsList.humidity, color) + else + error(('There is no color category named %s.'):format(category)) + end end ---Adds a biome to the `Layer.biomesByName` & `Layer.biomesList`