Some changes regarding MapGen and other modes

This commit is contained in:
2025-09-26 06:42:53 +07:00
parent bb530451d5
commit 330a847888
15 changed files with 56 additions and 28 deletions

View File

@@ -17,7 +17,8 @@
"core", "core",
"table", "table",
"VoxelArea", "VoxelArea",
"VoxelManip", "VoxelManip",
"vector",
"Ensure", "Ensure",
"string", "string",
"string_utf8" "string_utf8"

View File

@@ -1,3 +1,3 @@
name = smc__api__system name = smc__api__api_loader
description = Include this mod in your `depends` to ensure all necessary APIs are loaded for your mod description = Include this mod in your `depends` to ensure all necessary APIs are loaded for your mod
depends = smc__api__ensure, smc__api__math, smc__api__mod, smc__api__require, smc__api__table, smc__api__string, smc__api__utf8, depends = smc__api__ensure, smc__api__math, smc__api__mod, smc__api__require, smc__api__table, smc__api__string, smc__api__utf8,

View File

@@ -1,2 +1,2 @@
name = smc__core__enum name = smc__core__enum
depends = smc__api__system depends = smc__api__api_loader

View File

@@ -1,2 +1,2 @@
name = smc__core__factory name = smc__core__factory
depends = smc__api__system depends = smc__api__api_loader

View File

@@ -1,2 +1,2 @@
name = smc__core__item name = smc__core__item
depends = smc__api__system, smc__core__enum, smc__core__factory depends = smc__api__api_loader, smc__core__enum, smc__core__factory

View File

@@ -21,6 +21,7 @@ local Item = {
---@param itemDef Item.ItemDefinition ---@param itemDef Item.ItemDefinition
local function itemDefToLuantiDef(itemDef) local function itemDefToLuantiDef(itemDef)
---@diagnostic disable-next-line: undefined-field
itemDef = table.copy(itemDef) itemDef = table.copy(itemDef)
local s = itemDef.settings local s = itemDef.settings
local c = itemDef.callbacks local c = itemDef.callbacks

View File

@@ -27,4 +27,4 @@ mapGenerator:RegisterRegion("world",
}, },
true) true)
mapGenerator:enable() mapGenerator:run()

View File

@@ -1,2 +1,2 @@
name = smc__core__map_gen name = smc__core__map_gen
depends = smc__api__system depends = smc__api__api_loader

View File

@@ -14,21 +14,18 @@ local id_air = id("air")
local modInfo = Mod.getInfo() local modInfo = Mod.getInfo()
local require = modInfo.require local require = modInfo.require
-- -@type MapGen.Utils
---local MapGenUtils = require("MapGen.Utils")
---@type MapGen.Layer ---@type MapGen.Layer
local Layer = require("MapGen.Layer") local Layer = require("MapGen.Layer")
---@type MapGen.Region ---@type MapGen.Region
local Region= require("MapGen.Region") local Region = require("MapGen.Region")
---@class MapGen ---@class MapGen
---@field layersByName table ---@field layersByName table
---@field layersList table ---@field layersList table
---@field isEnable boolean A static field that guarantees that only one instance of the `MapGen` class will work. ---@field isRunning boolean A static field that guarantees that only one instance of the `MapGen` class will work.
local MapGen = { local MapGen = {
isEnable = false, isRunning = false,
} }
---@return MapGen ---@return MapGen
@@ -195,8 +192,8 @@ function MapGen:onMapGenerated(minPos, maxPos, blockseed)
voxelManip:write_to_map() voxelManip:write_to_map()
end end
function MapGen:enable() function MapGen:run()
if MapGen.isEnable then if MapGen.isRunning then
error('Only one instance of a `MapGen` class can be used.') error('Only one instance of a `MapGen` class can be used.')
end end
@@ -204,7 +201,7 @@ function MapGen:enable()
self:onMapGenerated(...) self:onMapGenerated(...)
end) end)
MapGen.isEnable = true MapGen.isRunning = true
end end
return MapGen return MapGen

View File

@@ -1,10 +1,22 @@
--============================================================
--=======================WARNING!!!===========================
--============================================================
--======================THIS=FILE=IS==========================
--=======================STILL==WIP===========================
--=========================BY==ME=============================
--============================================================
--===================================Doloment=================
--============================================================
-- TODO: replace `table` with `vector` for minPos and maxPos
---@class MapGen.Region ---@class MapGen.Region
---@field minPos table ---@field minPos table
---@field maxPos table ---@field maxPos table
---@field noises MapGen.Region.Noises ---@field noises MapGen.Region.Noises
---@field noisesParams MapGen.Region.Noises -- ??? TODO: should be it's own class in EmmyLua
local Region = {} local Region = {}
---@param noisesParams MapGen.Region.Noises ---@param noisesParams MapGen.Region.Noises -- ??? TODO: should be it's own class in EmmyLua
---@return MapGen.Region.Noises ---@return MapGen.Region.Noises
local function paramsToNoises(noisesParams) local function paramsToNoises(noisesParams)
---@type MapGen.Region.Noises ---@type MapGen.Region.Noises
@@ -17,17 +29,28 @@ local function paramsToNoises(noisesParams)
return noises return noises
end end
---@param minPos table ---@param minPos table
---@param maxPos table ---@param maxPos table
---@param noisesParams MapGen.Region.Noises ---@param noisesParams MapGen.Region.Noises
---@return MapGen.Region ---@return MapGen.Region
function Region:new(minPos, maxPos, noisesParams) function Region:new(minPos, maxPos, noisesParams)
---@type MapGen.Region
local instance = setmetatable({ local _minPos = minPos
minPos = minPos, local _maxPos = maxPos
maxPos = maxPos, local _noisesParams = noisesParams
noises = noisesParams --paramsToNoises(noisesParams)
}, {__index = self}) local _noises = {}
local instance = setmetatable({}, {__index = self})
function instance:getMinPos() return _minPos end
function instance:getMaxPos() return _maxPos end
function instance:getNoisesParams() return _noisesParams end
function instance:getNoises() return _noises end
function instance:initNoises()
_noises = paramsToNoises(_noisesParams)
end
return instance return instance
end end

View File

@@ -1,2 +1,2 @@
name = smc__core__tilesheet name = smc__core__tilesheet
depends = smc__api__system depends = smc__api__api_loader

View File

@@ -0,0 +1,3 @@
name = smc__game__items__items_loader
description = Include this mod in your `depends` to ensure all items are registered
depends = smc__game__items__rocks, smc__game__items__log,

View File

@@ -0,0 +1 @@
print(":)")

View File

@@ -0,0 +1,2 @@
name = smc__game__items__log
depends = smc__core__node