Bunch of updates (29.08.2025)
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
-- TODO: ANNOTATE!!!!!!!!!!
|
||||||
Mod = {}
|
Mod = {}
|
||||||
|
|
||||||
function Mod.getInfo()
|
function Mod.getInfo()
|
||||||
@@ -8,6 +9,10 @@ function Mod.getInfo()
|
|||||||
return {name = name, path = path, require = require}
|
return {name = name, path = path, require = require}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Mod.
|
||||||
|
|
||||||
|
-- Mod Extend
|
||||||
|
|
||||||
function Mod:new()
|
function Mod:new()
|
||||||
local mod = Mod.getInfo()
|
local mod = Mod.getInfo()
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ local allowedDomains = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
--- Adds a mod to the global space under specified domain structure
|
--- Adds a mod to the global space under specified domain structure
|
||||||
---@param mod table The mod table containing functionality to expose -- TODO: !!!Make a Mod class!!!
|
---@param mod table The mod table containing functionality to expose -- TODO: !!!Describe a Mod class to EmmyLua!!!
|
||||||
---@param location string Dot-separated path within domain structure (e.g. "Items.Log")
|
---@param location string Dot-separated path within domain structure (e.g. "Items.Log")
|
||||||
---@param force boolean? Whether to overwrite the target location.
|
---@param force boolean? Whether to overwrite the target location.
|
||||||
Api.addModToGlobalSpace = function(mod, location, force)
|
Api.addModToGlobalSpace = function(mod, location, force)
|
||||||
|
|||||||
@@ -3,3 +3,5 @@ local Item = Mod:new()
|
|||||||
Item.Class = Item.require('Item')
|
Item.Class = Item.require('Item')
|
||||||
|
|
||||||
Api.addModToGlobalSpace(Item, 'Core.Item')
|
Api.addModToGlobalSpace(Item, 'Core.Item')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,41 +1,52 @@
|
|||||||
local Item = {}
|
local Item = {}
|
||||||
|
|
||||||
--- @class ItemDefinition
|
|
||||||
--- @field settings table
|
|
||||||
local ItemDefinition = {
|
|
||||||
settings = {
|
|
||||||
name = '',
|
|
||||||
title = '',
|
|
||||||
description = '',
|
|
||||||
visual = '', -- '3d' | 'flat'
|
|
||||||
},
|
|
||||||
callbacks = {
|
|
||||||
...
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
--- @param itemDef ItemDefinition
|
--- @param itemDef ItemDefinition
|
||||||
local function itemDefToLuantiDef(itemDef)
|
local function itemDefToLuantiDef(itemDef)
|
||||||
|
itemDef = table.copy(itemDef)
|
||||||
local s = itemDef.settings
|
local s = itemDef.settings
|
||||||
local c = itemDef.callbacks
|
local c = itemDef.callbacks
|
||||||
local luantiDef = table.copy(c)
|
local description = s.title .. "\n" .. s.description
|
||||||
|
s.title, s.description = nil, description
|
||||||
|
|
||||||
|
local luantiDef = table.merge(s, c)
|
||||||
|
|
||||||
return luantiDef
|
return luantiDef
|
||||||
end
|
end
|
||||||
|
|
||||||
local function register3dItem(luantiDef)
|
local function register3dItem(luantiDef)
|
||||||
local ld = luantiDef
|
local ld = luantiDef
|
||||||
core.register_node(ld.name, {
|
local name = ld.name
|
||||||
description = ld.description
|
ld.name = nil
|
||||||
})
|
core.register_node(':'..name, luantiDef)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function registerFlatItem(luantiDef)
|
local function registerFlatItem(luantiDef)
|
||||||
|
local ld = luantiDef
|
||||||
|
local name = ld.name
|
||||||
|
ld.name = nil
|
||||||
|
core.register_craftitem(':'..name, luantiDef)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Item:new(itemDef)
|
function Item:new(itemDef)
|
||||||
local item = {}
|
local instance = {}
|
||||||
|
local luantiDef = itemDefToLuantiDef(itemDef)
|
||||||
|
local visual = itemDef.settings.visual
|
||||||
|
itemDef.settings.visual = nil
|
||||||
|
|
||||||
|
if visual == '3d' then
|
||||||
|
register3dItem(luantiDef)
|
||||||
|
else
|
||||||
|
visual = 'flat'
|
||||||
|
registerFlatItem(luantiDef)
|
||||||
|
end
|
||||||
|
|
||||||
|
function instance:getVisual()
|
||||||
|
return visual
|
||||||
|
end
|
||||||
|
|
||||||
|
instance.itemDef = itemDef
|
||||||
|
instance.luantiDef = luantiDef
|
||||||
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return Item
|
||||||
|
|||||||
15
mods/CORE/Item/src/ItemDefinition.lua
Normal file
15
mods/CORE/Item/src/ItemDefinition.lua
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
--- @class ItemDefinition
|
||||||
|
--- @field settings table
|
||||||
|
local ItemDefinition = {
|
||||||
|
settings = {
|
||||||
|
name = '',
|
||||||
|
title = '', -- 1st line of item description
|
||||||
|
description = '', -- the rest of item description
|
||||||
|
visual = '', -- '3d' | 'flat'
|
||||||
|
...
|
||||||
|
},
|
||||||
|
callbacks = {
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return ItemDefinition
|
||||||
7
mods/CORE/MapGen/init.lua
Normal file
7
mods/CORE/MapGen/init.lua
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
local MapGen = Mod:new()
|
||||||
|
local require = MapGen.require
|
||||||
|
|
||||||
|
MapGen.Class = require('MapGen')
|
||||||
|
MapGen.Class:enable()
|
||||||
|
|
||||||
|
Api.addModToGlobalSpace(MapGen, 'Core.MapGen')
|
||||||
2
mods/CORE/MapGen/mod.conf
Normal file
2
mods/CORE/MapGen/mod.conf
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
name = smc__core__map_gen
|
||||||
|
depends = smc__api__system
|
||||||
@@ -1,19 +1,18 @@
|
|||||||
local modInfo = Mod.getInfo()
|
local modInfo = Mod.getInfo()
|
||||||
local require = modInfo.require
|
local require = modInfo.require
|
||||||
local MapGenUtils = require("MapGenUtils")
|
local MapGenUtils = require("MapGen.Utils")
|
||||||
local Layer = require("Layer")
|
local Layer = require("MapGen.Layer")
|
||||||
local Region2D = require("Region2D")
|
local Region2D = require("MapGen.Region.Region2D")
|
||||||
local Region3D = require("Region3D")
|
local Region3D = require("MapGen.Region.Region3D")
|
||||||
|
|
||||||
local core, table, math = core, table, math
|
local core, table, math = core, table, math
|
||||||
local pairs, ipairs = pairs, ipairs
|
local ipairs = pairs, ipairs
|
||||||
|
|
||||||
|
-- Main MapGen class
|
||||||
|
local MapGen = {}
|
||||||
|
MapGen.__index = MapGen
|
||||||
|
|
||||||
-- Main MapGenerator class
|
function MapGen:new()
|
||||||
local MapGenerator = {}
|
|
||||||
MapGenerator.__index = MapGenerator
|
|
||||||
|
|
||||||
function MapGenerator:new()
|
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
layersByName = {},
|
layersByName = {},
|
||||||
layersList = {},
|
layersList = {},
|
||||||
@@ -26,35 +25,35 @@ function MapGenerator:new()
|
|||||||
}, self)
|
}, self)
|
||||||
end
|
end
|
||||||
|
|
||||||
function MapGenerator:registerLayer(name, minY, maxY)
|
function MapGen:registerLayer(name, minY, maxY)
|
||||||
local layer = Layer:new(name, minY, maxY)
|
local layer = Layer:new(name, minY, maxY)
|
||||||
self.layersByName[name] = layer
|
self.layersByName[name] = layer
|
||||||
table.insert(self.layersList, layer)
|
table.insert(self.layersList, layer)
|
||||||
return layer
|
return layer
|
||||||
end
|
end
|
||||||
|
|
||||||
function MapGenerator:register2DRegion(params)
|
function MapGen:register2DRegion(params)
|
||||||
local region = Region2D:new(params)
|
local region = Region2D:new(params)
|
||||||
local layer = self.layersByName[params.layerName]
|
local layer = self.layersByName[params.layerName]
|
||||||
if not layer then error("Invalid layer: " .. params.layerName) end
|
if not layer then error("Invalid layer: " .. params.layerName) end
|
||||||
layer:add2DRegion(region)
|
layer:add2DRegion(region)
|
||||||
end
|
end
|
||||||
|
|
||||||
function MapGenerator:register3DRegion(params)
|
function MapGen:register3DRegion(params)
|
||||||
local region = Region3D:new(params)
|
local region = Region3D:new(params)
|
||||||
local layer = self.layersByName[params.layerName]
|
local layer = self.layersByName[params.layerName]
|
||||||
if not layer then error("Invalid layer: " .. params.layerName) end
|
if not layer then error("Invalid layer: " .. params.layerName) end
|
||||||
layer:add3DRegion(region)
|
layer:add3DRegion(region)
|
||||||
end
|
end
|
||||||
|
|
||||||
function MapGenerator:enable()
|
function MapGen:enable()
|
||||||
core.register_on_generated(function(...)
|
core.register_on_generated(function(...)
|
||||||
self:onMapGenerated(...)
|
self:onMapGenerated(...)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Main generation logic
|
-- Main generation logic
|
||||||
function MapGenerator:onMapGenerated(minp, maxp, seed)
|
function MapGen:onMapGenerated(minp, maxp, seed)
|
||||||
local vm, emin, emax = core.get_mapgen_object("voxelmanip")
|
local vm, emin, emax = core.get_mapgen_object("voxelmanip")
|
||||||
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
||||||
local data = vm:get_data()
|
local data = vm:get_data()
|
||||||
@@ -72,7 +71,7 @@ function MapGenerator:onMapGenerated(minp, maxp, seed)
|
|||||||
vm:write_to_map()
|
vm:write_to_map()
|
||||||
end
|
end
|
||||||
|
|
||||||
function MapGenerator:process2DRegions(minp, maxp)
|
function MapGen:process2DRegions(minp, maxp)
|
||||||
local cache = {}
|
local cache = {}
|
||||||
local width = maxp.x - minp.x + 1
|
local width = maxp.x - minp.x + 1
|
||||||
local zSize = maxp.z - minp.z + 1
|
local zSize = maxp.z - minp.z + 1
|
||||||
@@ -140,7 +139,7 @@ function MapGenerator:process2DRegions(minp, maxp)
|
|||||||
return cache
|
return cache
|
||||||
end
|
end
|
||||||
|
|
||||||
function MapGenerator:process3DRegions(minp, maxp, data, area, terrainCache)
|
function MapGen:process3DRegions(minp, maxp, data, area, terrainCache)
|
||||||
-- Precompute 3D noise for regions
|
-- Precompute 3D noise for regions
|
||||||
local region3DNoise = {}
|
local region3DNoise = {}
|
||||||
for _, layer in ipairs(self.layersList) do
|
for _, layer in ipairs(self.layersList) do
|
||||||
@@ -220,4 +219,4 @@ function MapGenerator:process3DRegions(minp, maxp, data, area, terrainCache)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return MapGenerator
|
return MapGen
|
||||||
@@ -20,3 +20,23 @@ end
|
|||||||
function Layer:add3DRegion(region)
|
function Layer:add3DRegion(region)
|
||||||
table.insert(self.regions3D, region)
|
table.insert(self.regions3D, region)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Layer:contains(x, y, z)
|
||||||
|
if y < self.minY or y > self.maxY then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, region in ipairs(self.regions2D) do
|
||||||
|
if region:contains2D(x, z) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, region in ipairs(self.regions3D) do
|
||||||
|
if region:contains3D(x, y, z) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
7
mods/CORE/MapGen2/init.lua
Normal file
7
mods/CORE/MapGen2/init.lua
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
local MapGen = Mod:new()
|
||||||
|
local require = MapGen.require
|
||||||
|
|
||||||
|
MapGen.Class = require('MapGen')
|
||||||
|
MapGen.Class:enable()
|
||||||
|
|
||||||
|
Api.addModToGlobalSpace(MapGen, 'Core.MapGen')
|
||||||
2
mods/CORE/MapGen2/mod.conf
Normal file
2
mods/CORE/MapGen2/mod.conf
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
name = smc__core__map_gen
|
||||||
|
depends = smc__api__system
|
||||||
40
mods/CORE/MapGen2/src/MapGen.lua
Normal file
40
mods/CORE/MapGen2/src/MapGen.lua
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
local MapGen = {}
|
||||||
|
MapGen.__index = MapGen
|
||||||
|
|
||||||
|
function MapGen:new()
|
||||||
|
local instance = setmetatable({}, self)
|
||||||
|
instance.layers = {}
|
||||||
|
return instance
|
||||||
|
end
|
||||||
|
|
||||||
|
function MapGen:RegisterLayer(layer)
|
||||||
|
Ensure.argNotNil(layer, 1, "MapGen:RegisterLayer")
|
||||||
|
Ensure.argType(layer.minHeight, "number", 1, "MapGen:RegisterLayer")
|
||||||
|
Ensure.argType(layer.maxHeight, "number", 2, "MapGen:RegisterLayer")
|
||||||
|
assert(layer.minHeight < layer.maxHeight, "minHeight must be less than maxHeight")
|
||||||
|
|
||||||
|
table.insert(self.layers, layer)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MapGen:GenerateMap()
|
||||||
|
for _, layer in ipairs(self.layers) do
|
||||||
|
self:GenerateLayer(layer)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function MapGen:GenerateLayer(layer)
|
||||||
|
-- Implement layer generation logic here
|
||||||
|
-- This will include processing 2D and 3D regions
|
||||||
|
end
|
||||||
|
|
||||||
|
function MapGen:RegisterRegion2D(region)
|
||||||
|
Ensure.argNotNil(region, 1, "MapGen:RegisterRegion2D")
|
||||||
|
-- Additional validation and registration logic for 2D regions
|
||||||
|
end
|
||||||
|
|
||||||
|
function MapGen:RegisterRegion3D(region)
|
||||||
|
Ensure.argNotNil(region, 1, "MapGen:RegisterRegion3D")
|
||||||
|
-- Additional validation and registration logic for 3D regions
|
||||||
|
end
|
||||||
|
|
||||||
|
return MapGen
|
||||||
42
mods/CORE/MapGen2/src/MapGen/Layer.lua
Normal file
42
mods/CORE/MapGen2/src/MapGen/Layer.lua
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
local Layer = {}
|
||||||
|
Layer.__index = Layer
|
||||||
|
|
||||||
|
function Layer:new(minHeight, maxHeight)
|
||||||
|
Ensure.argType(minHeight, 'number', 1, 'Layer:new')
|
||||||
|
Ensure.argType(maxHeight, 'number', 2, 'Layer:new')
|
||||||
|
Ensure.argNotNil(minHeight, 1, 'Layer:new')
|
||||||
|
Ensure.argNotNil(maxHeight, 2, 'Layer:new')
|
||||||
|
assert(minHeight < maxHeight, 'minHeight must be less than maxHeight')
|
||||||
|
|
||||||
|
local layer = {
|
||||||
|
minHeight = minHeight,
|
||||||
|
maxHeight = maxHeight,
|
||||||
|
region2DList = {},
|
||||||
|
region3DList = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
setmetatable(layer, self)
|
||||||
|
return layer
|
||||||
|
end
|
||||||
|
|
||||||
|
function Layer:RegisterRegion2D(region2D)
|
||||||
|
Ensure.argNotNil(region2D, 1, 'Layer:RegisterRegion2D')
|
||||||
|
assert(region2D.minHeight >= self.minHeight and region2D.maxHeight <= self.maxHeight, 'Region2D height must be within layer boundaries')
|
||||||
|
table.insert(self.region2DList, region2D)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Layer:RegisterRegion3D(region3D)
|
||||||
|
Ensure.argNotNil(region3D, 1, 'Layer:RegisterRegion3D')
|
||||||
|
assert(region3D.minHeight >= self.minHeight and region3D.maxHeight <= self.maxHeight, 'Region3D height must be within layer boundaries')
|
||||||
|
table.insert(self.region3DList, region3D)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Layer:GetRegions2D()
|
||||||
|
return self.region2DList
|
||||||
|
end
|
||||||
|
|
||||||
|
function Layer:GetRegions3D()
|
||||||
|
return self.region3DList
|
||||||
|
end
|
||||||
|
|
||||||
|
return Layer
|
||||||
34
mods/CORE/MapGen2/src/MapGen/Region.lua
Normal file
34
mods/CORE/MapGen2/src/MapGen/Region.lua
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
local Region = {}
|
||||||
|
Region.__index = Region
|
||||||
|
|
||||||
|
function Region:new(name, layer, allowedBiomes)
|
||||||
|
Ensure.stringArgNotEmpty(name, 1, "Region:new")
|
||||||
|
Ensure.argNotNil(layer, 2, "Region:new")
|
||||||
|
Ensure.argNotNil(allowedBiomes, 3, "Region:new")
|
||||||
|
|
||||||
|
local instance = setmetatable({}, self)
|
||||||
|
instance.name = name
|
||||||
|
instance.layer = layer
|
||||||
|
instance.allowedBiomes = allowedBiomes
|
||||||
|
|
||||||
|
return instance
|
||||||
|
end
|
||||||
|
|
||||||
|
function Region:GetName()
|
||||||
|
return self.name
|
||||||
|
end
|
||||||
|
|
||||||
|
function Region:GetLayer()
|
||||||
|
return self.layer
|
||||||
|
end
|
||||||
|
|
||||||
|
function Region:GetAllowedBiomes()
|
||||||
|
return self.allowedBiomes
|
||||||
|
end
|
||||||
|
|
||||||
|
function Region:IsBiomeAllowed(biome)
|
||||||
|
Ensure.stringArgNotEmpty(biome, 1, "Region:IsBiomeAllowed")
|
||||||
|
return self.allowedBiomes[biome] == true
|
||||||
|
end
|
||||||
|
|
||||||
|
return Region
|
||||||
41
mods/CORE/MapGen2/src/MapGen/Region/Region2D.lua
Normal file
41
mods/CORE/MapGen2/src/MapGen/Region/Region2D.lua
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
local modInfo = Mod.getInfo()
|
||||||
|
local require = modInfo.require
|
||||||
|
local Ensure = require("MapGen.Utils.Ensure")
|
||||||
|
|
||||||
|
local Region2D = {}
|
||||||
|
Region2D.__index = Region2D
|
||||||
|
|
||||||
|
function Region2D:new(name, layer, allowedBiomes, heightNoise, temperatureNoise, humidityNoise, heightVariance, temperatureVariance, humidityVariance)
|
||||||
|
Ensure.stringArgNotEmpty(name, 1, "Region2D:new")
|
||||||
|
Ensure.argNotNil(layer, 2, "Region2D:new")
|
||||||
|
Ensure.argType(allowedBiomes, "table", 3, "Region2D:new")
|
||||||
|
Ensure.argType(heightNoise, "table", 4, "Region2D:new")
|
||||||
|
Ensure.argType(temperatureNoise, "table", 5, "Region2D:new")
|
||||||
|
Ensure.argType(humidityNoise, "table", 6, "Region2D:new")
|
||||||
|
Ensure.argType(heightVariance, "table", 7, "Region2D:new")
|
||||||
|
Ensure.argType(temperatureVariance, "table", 8, "Region2D:new")
|
||||||
|
Ensure.argType(humidityVariance, "table", 9, "Region2D:new")
|
||||||
|
|
||||||
|
local instance = setmetatable({}, self)
|
||||||
|
instance.name = name
|
||||||
|
instance.layer = layer
|
||||||
|
instance.allowedBiomes = allowedBiomes
|
||||||
|
instance.heightNoise = heightNoise
|
||||||
|
instance.temperatureNoise = temperatureNoise
|
||||||
|
instance.humidityNoise = humidityNoise
|
||||||
|
instance.heightVariance = heightVariance
|
||||||
|
instance.temperatureVariance = temperatureVariance
|
||||||
|
instance.humidityVariance = humidityVariance
|
||||||
|
|
||||||
|
return instance
|
||||||
|
end
|
||||||
|
|
||||||
|
function Region2D:GenerateTerrain(x, z)
|
||||||
|
-- Implement terrain generation logic based on noise and variances
|
||||||
|
end
|
||||||
|
|
||||||
|
function Region2D:CheckBounds(y)
|
||||||
|
-- Implement boundary checking logic for the layer
|
||||||
|
end
|
||||||
|
|
||||||
|
return Region2D
|
||||||
46
mods/CORE/MapGen2/src/MapGen/Region/Region3D.lua
Normal file
46
mods/CORE/MapGen2/src/MapGen/Region/Region3D.lua
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
local Ensure = require("MapGen.Utils.Ensure")
|
||||||
|
|
||||||
|
local Region3D = {}
|
||||||
|
Region3D.__index = Region3D
|
||||||
|
|
||||||
|
function Region3D:new(name, layer, allowedBiomes, caveNoise, temperatureNoise, humidityNoise, temperatureVariance, humidityVariance)
|
||||||
|
Ensure.stringArgNotEmpty(name, 1, "Region3D:new")
|
||||||
|
Ensure.argNotNil(layer, 2, "Region3D:new")
|
||||||
|
Ensure.argType(allowedBiomes, "table", 3, "Region3D:new")
|
||||||
|
Ensure.argType(caveNoise, "table", 4, "Region3D:new")
|
||||||
|
Ensure.argType(temperatureNoise, "table", 5, "Region3D:new")
|
||||||
|
Ensure.argType(humidityNoise, "table", 6, "Region3D:new")
|
||||||
|
Ensure.argType(temperatureVariance, "table", 7, "Region3D:new")
|
||||||
|
Ensure.argType(humidityVariance, "table", 8, "Region3D:new")
|
||||||
|
|
||||||
|
local instance = setmetatable({
|
||||||
|
name = name,
|
||||||
|
layer = layer,
|
||||||
|
allowedBiomes = allowedBiomes,
|
||||||
|
caveNoise = caveNoise,
|
||||||
|
temperatureNoise = temperatureNoise,
|
||||||
|
humidityNoise = humidityNoise,
|
||||||
|
temperatureVariance = temperatureVariance,
|
||||||
|
humidityVariance = humidityVariance,
|
||||||
|
}, self)
|
||||||
|
|
||||||
|
return instance
|
||||||
|
end
|
||||||
|
|
||||||
|
function Region3D:Register()
|
||||||
|
-- Logic to register the 3D region within the specified layer
|
||||||
|
end
|
||||||
|
|
||||||
|
function Region3D:ValidateBounds(minHeight, maxHeight)
|
||||||
|
-- Logic to validate that the region does not exceed the layer boundaries
|
||||||
|
end
|
||||||
|
|
||||||
|
function Region3D:GenerateCaves()
|
||||||
|
-- Logic to generate caves based on the cave noise
|
||||||
|
end
|
||||||
|
|
||||||
|
function Region3D:GenerateContents()
|
||||||
|
-- Logic to populate the region with contents based on temperature and humidity
|
||||||
|
end
|
||||||
|
|
||||||
|
return Region3D
|
||||||
31
mods/CORE/MapGen2/src/MapGen/Utils.lua
Normal file
31
mods/CORE/MapGen2/src/MapGen/Utils.lua
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
local Utils = {}
|
||||||
|
|
||||||
|
function Utils.Clamp(value, min, max)
|
||||||
|
if value < min then
|
||||||
|
return min
|
||||||
|
elseif value > max then
|
||||||
|
return max
|
||||||
|
else
|
||||||
|
return value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Utils.Lerp(a, b, t)
|
||||||
|
return a + (b - a) * t
|
||||||
|
end
|
||||||
|
|
||||||
|
function Utils.GenerateNoise(seed, x, y, scale)
|
||||||
|
local noise = core.get_perlin(seed, scale, 1, 0)
|
||||||
|
return noise:get2d({x, y})
|
||||||
|
end
|
||||||
|
|
||||||
|
function Utils.ValidateBiome(biome, allowedBiomes)
|
||||||
|
for _, allowedBiome in ipairs(allowedBiomes) do
|
||||||
|
if biome == allowedBiome then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
return Utils
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
---local Node = Core.Item:extend()
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
local MapGen = Mod:new()
|
|
||||||
|
|
||||||
MapGen.Class = MapGen.require('MapGen')
|
|
||||||
|
|
||||||
Api.addModToGlobalSpace(MapGen, 'Core.MapGen')
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
name = smc__environment__map_gen
|
|
||||||
depends = smc__api__system
|
|
||||||
Reference in New Issue
Block a user