Remove GlobalSpace, domains and extends methods in Mod
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
local Enum = Mod:new()
|
||||
local modInfo = Mod.getInfo('smc__core__enum')
|
||||
local require = modInfo.require
|
||||
|
||||
Enum.Class = Enum.require('Enum')
|
||||
return require('Enum')
|
||||
|
||||
Api.addModToGlobalSpace(Enum, 'Core.Enum')
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
---@class Enum
|
||||
local Enum = {}
|
||||
|
||||
---@param enum table[]
|
||||
---@param enum string[]
|
||||
---@return Enum
|
||||
function Enum:new(enum)
|
||||
local metaEnum = {}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
local Item = Mod:new()
|
||||
local modInfo = Mod.getInfo('smc__core__item')
|
||||
local require = modInfo.require
|
||||
|
||||
Item.Class = Item.require('Item')
|
||||
|
||||
Api.addModToGlobalSpace(Item, 'Core.Item')
|
||||
return require('Item')
|
||||
@@ -1,8 +1,10 @@
|
||||
local modInfo = Mod.getInfo()
|
||||
local modInfo = Mod.getInfo('smc__core__item')
|
||||
local require = modInfo.require
|
||||
|
||||
local VisualEnum = require('Item.VisualEnum')
|
||||
|
||||
local ItemFactory = Mod.getInfo('smc__core__item_factory').require('ItemFactory')
|
||||
|
||||
---@class Item
|
||||
---@field itemDef Item.ItemDefinition
|
||||
---@field luantiDef table
|
||||
@@ -61,7 +63,7 @@ local defMerge = function(...)
|
||||
return table.merge(...)
|
||||
end
|
||||
|
||||
---@param itemDef Item.ItemDefinition
|
||||
---@param itemDef Item.ItemDefinition|Node.NodeDefinition
|
||||
---@return Item
|
||||
function Item:new(itemDef)
|
||||
---Adding default parameters
|
||||
@@ -103,7 +105,7 @@ end
|
||||
---@return Item
|
||||
function Item:getExtended(defaultDef)
|
||||
---@type Item
|
||||
local ChildClass = Mod:getClassExtended(self, {
|
||||
local ChildClass = Class.extend(self, {
|
||||
defaultDef = defaultDef,
|
||||
})
|
||||
|
||||
@@ -119,7 +121,7 @@ function Item:getFactory(defaultDef)
|
||||
end
|
||||
|
||||
---@type ItemFactory
|
||||
local instance = Core.ItemFactory():new(self, defaultDef)
|
||||
local instance = ItemFactory:new(self, defaultDef)
|
||||
|
||||
return instance
|
||||
end
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
---@type Enum
|
||||
local Enum = Mod.getInfo('smc__core__enum').require('Enum')
|
||||
|
||||
---@class Item.VisualEnum : Enum
|
||||
---@field ITEM_2D Enum.EnumKey
|
||||
---@field ITEM_3D Enum.EnumKey
|
||||
local VisualEnum = Core.Enum:getModClassInstance({
|
||||
local VisualEnum = Enum:new({
|
||||
'ITEM_2D',
|
||||
'ITEM_3D',
|
||||
})
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
local ItemFactory = Mod:new()
|
||||
local modInfo = Mod.getInfo('smc__core__item_factory')
|
||||
local require = modInfo.require
|
||||
|
||||
ItemFactory.Class = ItemFactory.require('ItemFactory')
|
||||
|
||||
Api.addModToGlobalSpace(ItemFactory, 'Core.ItemFactory')
|
||||
return require('ItemFactory')
|
||||
@@ -1,5 +1,4 @@
|
||||
local MapGen = Mod:new()
|
||||
local modInfo = Mod.getInfo('smc__core__map_gen')
|
||||
local require = modInfo.require
|
||||
|
||||
MapGen.Class = MapGen.require('MapGen')
|
||||
|
||||
Api.addModToGlobalSpace(MapGen, 'Core.MapGen')
|
||||
return require('MapGen')
|
||||
@@ -664,8 +664,6 @@ function MapGen:onMapGenerated(voxelManip, minPos, maxPos, blockseed)
|
||||
-- local param2_data = voxelManip:get_param2_data()
|
||||
local area = VoxelArea:new({MinEdge = eMin, MaxEdge = eMax})
|
||||
|
||||
data[area:index(0,50,0)] = core.get_content_id('rocks:malachite')
|
||||
|
||||
local index
|
||||
-- Initial generation: landscape
|
||||
for z = minPos.z, maxPos.z do
|
||||
|
||||
@@ -10,7 +10,7 @@ local Peak = require('MapGen.Peak')
|
||||
---@class MapGen.Triangulation.FakePeak : MapGen.Peak
|
||||
---@field id number
|
||||
---@field getPeakPos fun():vector
|
||||
local FakePeak = Mod:getClassExtended(Peak, {})
|
||||
local FakePeak = Class.extend(Peak, {})
|
||||
|
||||
---Returns a fake `MapGen.Peak` that has no noise parameters.
|
||||
---Note that the initialized peak should not be used in generation.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
local Node = Mod:new()
|
||||
local modInfo = Mod.getInfo('smc__core__node')
|
||||
local require = modInfo.require
|
||||
|
||||
Node.Class = Node.require('Node')
|
||||
|
||||
Api.addModToGlobalSpace(Node, 'Core.Node')
|
||||
return require('Node')
|
||||
@@ -1,9 +1,17 @@
|
||||
local itemRequire = Mod.getInfo('smc__core__item').require
|
||||
|
||||
---@type Item
|
||||
local Item = itemRequire('Item')
|
||||
|
||||
---@type Item.VisualEnum
|
||||
local VisualEnum = Core.Item.require('Item.VisualEnum')
|
||||
local VisualEnum = itemRequire('Item.VisualEnum')
|
||||
|
||||
---@type ItemFactory
|
||||
local ItemFactory = Mod.getInfo('smc__core__item_factory').require('ItemFactory')
|
||||
|
||||
---@class Node : Item
|
||||
---@field defaultDef Node.NodeDefinition
|
||||
local Node = Core.Item:getModClassExtended({})
|
||||
local Node = Class.extend(Item, {})
|
||||
|
||||
---@param nodeDef Node.NodeDefinition
|
||||
---@return Node
|
||||
@@ -11,7 +19,7 @@ function Node:new(nodeDef)
|
||||
nodeDef.settings.visual = VisualEnum.ITEM_3D
|
||||
|
||||
---@type Node
|
||||
local instance = Core.Item:getModClassInstance(nodeDef)
|
||||
local instance = Item:new(nodeDef)
|
||||
|
||||
return instance
|
||||
end
|
||||
@@ -23,7 +31,7 @@ end
|
||||
---@return Node
|
||||
function Node:getExtended(defaultDef)
|
||||
---@type Node
|
||||
local ChildClass = Mod:getClassExtended(self, {
|
||||
local ChildClass = Class.extend(self, {
|
||||
defaultDef = defaultDef,
|
||||
})
|
||||
|
||||
@@ -39,7 +47,7 @@ function Node:getFactory(defaultDef)
|
||||
end
|
||||
|
||||
---@type ItemFactory
|
||||
local instance = Core.ItemFactory:getModClassInstance(self, defaultDef)
|
||||
local instance = ItemFactory:new(self, defaultDef)
|
||||
|
||||
return instance
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
---@type Item.Callbacks
|
||||
local ItemCallbacks = Core.Item.require('Item.Callbacks')
|
||||
local ItemCallbacks = Mod.getInfo('smc__core__item').require('Item.Callbacks')
|
||||
|
||||
---@class Node.Callbacks : Item.Callbacks
|
||||
local Callbacks = Mod:getClassExtended(ItemCallbacks, {})
|
||||
local Callbacks = Class.extend(ItemCallbacks, {})
|
||||
|
||||
---Node constructor; called after adding node.
|
||||
---Can set up metadata and stuff like that.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
---@type Item.Settings
|
||||
local ItemSettings = Core.Item.require('Item.Settings')
|
||||
local ItemSettings = Mod.getInfo('smc__core__item').require('Item.Settings')
|
||||
|
||||
---@class Node.Settings : Item.Settings
|
||||
local Settings = Mod:getClassExtended(ItemSettings, {})
|
||||
local Settings = Class.extend(ItemSettings, {})
|
||||
|
||||
---See "Node drawtypes"
|
||||
---@type string?
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
local TileSheet = Mod:new()
|
||||
local modInfo = Mod.getInfo('smc__core__tilesheet')
|
||||
local require = modInfo.require
|
||||
|
||||
TileSheet.Class = TileSheet.require('TileSheet')
|
||||
|
||||
Api.addModToGlobalSpace(TileSheet, 'Core.TileSheet')
|
||||
return require('TileSheet')
|
||||
Reference in New Issue
Block a user