rocks: Change of registration of rocks

This commit is contained in:
Van
2026-04-19 19:48:04 +03:00
parent 31d66277ae
commit 99093493c0
2 changed files with 165 additions and 80 deletions

View File

@@ -2,88 +2,173 @@ local Node, TileSheet = Smc.requireNode(), Smc.requireTileSheet()
local PrimitiveCraftHandler = Smc.requireCraftSystemPrimitiveCraftHandler()
---@type Node.NodeDefinition
local defaultRockDef = {
settings = {
name = '',
tiles = {},
groups = {
dig_immediate = 2,
}
},
}
---@type Node
local defaultRock = Node:getExtended(defaultRockDef)
local rockFactory = defaultRock:getFactory()
---@type TileSheet
local ts = TileSheet:new("rocks_sheet.png", 16, 16)
local rocksTileSheet = TileSheet:new("rocks_sheet.png", 16, 16)
local function registerRocksTypes(postfix, x)
rockFactory:registerNodesByShortDef({
{"sylite"..postfix, {ts:t(x, 0)}},
{"sylite_gray"..postfix, {ts:t(x, 1)}},
{"sylite_black"..postfix, {ts:t(x, 2)}},
{"tauitite_light"..postfix, {ts:t(x, 3)}},
{"tauitite_pink"..postfix, {ts:t(x, 4)}},
{"tauitite"..postfix, {ts:t(x, 5)}},
{"falmyte_light"..postfix, {ts:t(x, 6)}},
{"falmyte_yellow"..postfix, {ts:t(x, 7)}},
{"falmyte_red"..postfix, {ts:t(x, 8)}},
{"falmyte_dark"..postfix, {ts:t(x, 9)}},
{"iyellite"..postfix, {ts:t(x, 14)}},
{"falmyte"..postfix, {ts:t(x, 14)}},
{"hapcoryte"..postfix, {ts:t(x, 14)}},
{"burcite"..postfix, {ts:t(x, 14)}},
{"felhor"..postfix, {ts:t(x, 14)}},
{"malachite"..postfix, {ts:t(x, 14)}}
---@class RockDef
---@field rarity Item.Rarity?
local function registerSegmentsCrafts(name, craftGroup)
PrimitiveCraftHandler:registerCraft(name..'_slab', {
recipe = {name},
output = name..'_slab',
group = craftGroup
})
PrimitiveCraftHandler:registerCraft(name..'_stair', {
recipe = {name},
output = name..'_stair',
group = craftGroup
})
end
local function registerPilarStaff(rock, y)
local columnTop = ts:t(9, y)
---@param name string
---@param y number
---@param def RockDef?
---@param staff {block:boolean?,bricks:boolean?,pillar:boolean?}
local function registerRock(name, y, def, staff)
if def == nil then
def = {}
end
rockFactory:registerNodesByShortDef({
{rock..'_fluted_column', {columnTop, columnTop, ts:t(6, y)}},
{rock..'_ionic_chapiter', {
ts:t(3, y),
columnTop,
ts:t(7, y),
ts:t(7, y),
ts:t(8, y),
ts:t(8, y)}},
local modPrefix = Mod.getInfo().shortName..':'
local craftGroup = 'rocks_'..name..'_staff'
-- Default rock
local defaultRock = Node:getExtended({
settings = {
name = '',
_rarity = def.rarity,
groups = {
rocks = 1,
dig_immediate = 2,
}
}
})
-- Solid rock
defaultRock:new({
settings = {
name = name,
tiles = { rocksTileSheet:t(0, y) },
groups = {
segments = 3
}
}
})
registerSegmentsCrafts(modPrefix..name, craftGroup)
-- Chipped rock
local chippedRockName = name..'_chipped'
defaultRock:new({
settings = {
name = chippedRockName,
tiles = { rocksTileSheet:t(1, y) },
groups = {
segments = 3
}
}
})
registerSegmentsCrafts(modPrefix..chippedRockName, craftGroup)
if staff.block == true then
-- Solid rock block
local blockName = name..'_block'
defaultRock:new({
settings = {
name = name..'_block',
tiles = { rocksTileSheet:t(3, y) },
groups = {
segments = 3
}
}
})
registerSegmentsCrafts(modPrefix..blockName, craftGroup)
PrimitiveCraftHandler:registerCraft(blockName, {
recipe = {modPrefix..name},
output = modPrefix..blockName,
group = craftGroup,
})
end
if staff.bricks == true then
-- Solid rock bricks
local bricksName = name..'_bricks'
defaultRock:new({
settings = {
name = bricksName,
tiles = { rocksTileSheet:t(4, y) },
groups = {
segments = 3
}
}
})
registerSegmentsCrafts(modPrefix..bricksName, craftGroup)
PrimitiveCraftHandler:registerCraft(bricksName, {
recipe = {modPrefix..name},
output = modPrefix..bricksName,
group = craftGroup,
})
end
if staff.pillar == true then
local columnTopTexture = rocksTileSheet:t(9, y)
-- Fluted column
defaultRock:new({
settings = {
name = name..'_fluted_column',
tiles = {
columnTopTexture,
columnTopTexture,
rocksTileSheet:t(6, y)
},
}
})
-- Ionic chapiter
defaultRock:new({
settings = {
name = name..'_ionic_chapiter',
tiles = {
rocksTileSheet:t(3, y),
columnTopTexture,
rocksTileSheet:t(7, y),
rocksTileSheet:t(7, y),
rocksTileSheet:t(8, y),
rocksTileSheet:t(8, y)
}
}
})
end
end
registerPilarStaff('sylite', 0)
registerPilarStaff('sylite_gray', 1)
registerPilarStaff('sylite_black', 2)
-- Sylite group
registerRock('sylite', 0, {}, {block = true, bricks = true, pillar = true})
registerRock('sylite_gray', 1, {}, {block = true, bricks = true, pillar = true})
registerRock('sylite_black', 2, {}, {block = true, bricks = true, pillar = true})
registerRocksTypes('', 0)
registerRocksTypes('_chipped', 1)
registerRocksTypes('_block', 3)
registerRocksTypes('_bricks', 4)
registerRocksTypes('_bricks_2', 5)
-- Tauitite group
registerRock('tauitite_light', 3, {}, {block = true, bricks = true})
registerRock('tauitite_pink', 4, {}, {block = true, bricks = true})
registerRock('tauitite_black', 5, {}, {block = true, bricks = true})
PrimitiveCraftHandler:registerCraft('rocks:sylite_fluted_column', {
recipe = {
'rocks:sylite'
},
output = 'rocks:sylite_fluted_column',
})
-- Falmyte group
registerRock('falmyte_light', 6, {}, {block = true, bricks = true})
registerRock('falmyte_yellow', 7, {}, {block = true, bricks = true})
registerRock('falmyte_red', 8, {}, {block = true, bricks = true})
registerRock('falmyte_dark', 9, {}, {block = true, bricks = true})
PrimitiveCraftHandler:registerCraft('rocks:sylite_ionic_chapiter', {
recipe = {
'rocks:sylite'
},
output = 'rocks:sylite_ionic_chapiter',
})
PrimitiveCraftHandler:registerCraft('rocks:sylite_bricks_2', {
recipe = {
'rocks:sylite'
},
output = 'rocks:sylite_bricks_2',
})
-- TODO:
-- iyellite
-- falmyte
-- hapcoryte
-- burcite
-- felhor
-- malachite