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

@@ -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
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
depends = smc__api__system
depends = smc__api__api_loader

View File

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

View File

@@ -1,2 +1,2 @@
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
local function itemDefToLuantiDef(itemDef)
---@diagnostic disable-next-line: undefined-field
itemDef = table.copy(itemDef)
local s = itemDef.settings
local c = itemDef.callbacks

View File

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

View File

@@ -1,2 +1,2 @@
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 require = modInfo.require
-- -@type MapGen.Utils
---local MapGenUtils = require("MapGen.Utils")
---@type MapGen.Layer
local Layer = require("MapGen.Layer")
local Layer = require("MapGen.Layer")
---@type MapGen.Region
local Region= require("MapGen.Region")
local Region = require("MapGen.Region")
---@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.
---@field isRunning boolean A static field that guarantees that only one instance of the `MapGen` class will work.
local MapGen = {
isEnable = false,
isRunning = false,
}
---@return MapGen
@@ -195,8 +192,8 @@ function MapGen:onMapGenerated(minPos, maxPos, blockseed)
voxelManip:write_to_map()
end
function MapGen:enable()
if MapGen.isEnable then
function MapGen:run()
if MapGen.isRunning then
error('Only one instance of a `MapGen` class can be used.')
end
@@ -204,7 +201,7 @@ function MapGen:enable()
self:onMapGenerated(...)
end)
MapGen.isEnable = true
MapGen.isRunning = true
end
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
---@field minPos table
---@field maxPos table
---@field noises MapGen.Region.Noises
---@field noisesParams MapGen.Region.Noises -- ??? TODO: should be it's own class in EmmyLua
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
local function paramsToNoises(noisesParams)
---@type MapGen.Region.Noises
@@ -17,17 +29,28 @@ local function paramsToNoises(noisesParams)
return noises
end
---@param minPos table
---@param maxPos table
---@param noisesParams MapGen.Region.Noises
---@param minPos table
---@param maxPos table
---@param noisesParams MapGen.Region.Noises
---@return MapGen.Region
function Region:new(minPos, maxPos, noisesParams)
---@type MapGen.Region
local instance = setmetatable({
minPos = minPos,
maxPos = maxPos,
noises = noisesParams --paramsToNoises(noisesParams)
}, {__index = self})
local _minPos = minPos
local _maxPos = maxPos
local _noisesParams = noisesParams
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
end

View File

@@ -1,2 +1,2 @@
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