Some changes regarding MapGen and other modes
This commit is contained in:
@@ -27,4 +27,4 @@ mapGenerator:RegisterRegion("world",
|
||||
},
|
||||
true)
|
||||
|
||||
mapGenerator:enable()
|
||||
mapGenerator:run()
|
||||
@@ -1,2 +1,2 @@
|
||||
name = smc__core__map_gen
|
||||
depends = smc__api__system
|
||||
depends = smc__api__api_loader
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user