HelperLib: remove immersiveCraftData stuff

This commit is contained in:
Van
2026-05-20 21:18:02 +03:00
parent c578e6d5b1
commit bdef2fffaf
2 changed files with 0 additions and 95 deletions

View File

@@ -6,7 +6,6 @@ local require = modInfo.require
require('Lib.activeFormspecs')
require('Lib.globalStep')
require('Lib.color')
require('Lib.immersiveCraftData')
require('Lib.itemStackInventory')
require('Lib.getObjectByGUID')
require('Lib.receiveFields')

View File

@@ -1,94 +0,0 @@
local EMPTY_FLAG = 'EMPTY_FLAG'
---@class ImmersiveStageData
---@class ImmersiveCraftData
---@field playerName string The name of the player who started the craft.
---@field craftName string
---@field stageName string
---@field amount integer
---@field stageData ImmersiveStageData?
---Returns craft data for immersive crafting, which is stored in the desktop metadata.
---@param meta NodeMetaRef
---@return ImmersiveCraftData?
function Smc.getCraftDataByMeta(meta)
local dataString = meta:get_string('craft_data')
if dataString == EMPTY_FLAG then
return
end
return core.deserialize(dataString)
end
---Sets craft data for immersive crafting that is stored in the work station metadata.
---
---If `data` is `nil`, the data is cleared.
---@param meta NodeMetaRef
---@param craftData ImmersiveCraftData?
function Smc.setCraftDataByMeta(meta, craftData)
if craftData == nil then
meta:set_string('craft_data', EMPTY_FLAG)
end
meta:set_string('craft_data', core.serialize(craftData))
end
---Returns craft data for immersive crafting, which is stored in the work station metadata.
---@param pos MapPosition
---@return ImmersiveCraftData?
function Smc.getCraftDataByPos(pos)
local meta = core.get_meta(pos)
return Smc.getCraftDataByMeta(meta)
end
---Sets craft data for immersive crafting that is stored in the work station metadata.
---
---If `data` is `nil`, the data is cleared.
---@param pos MapPosition
---@param craftData ImmersiveCraftData?
function Smc.setCraftDataByPos(pos, craftData)
local meta = core.get_meta(pos)
Smc.setCraftDataByMeta(meta, craftData)
end
---Returns stage data for immersive crafting, which is stored in the work station metadata.
---
---**Note**: If the workbench does not have crafting data, an error will be thrown.
---@param pos MapPosition
---@return ImmersiveStageData?
function Smc.getStageDataByPos(pos)
local craftData = Smc.getCraftDataByPos(pos)
assert(craftData ~= nil, 'Immersive crafting data is empty.')
return craftData.stageData
end
---Sets stage data for immersive crafting that is stored in the work station metadata.
---@param pos MapPosition
---@param stageData ImmersiveStageData
function Smc.setStageDataByPos(pos, stageData)
local craftData = Smc.getCraftDataByPos(pos)
assert(craftData ~= nil, 'Immersive crafting data is empty.')
craftData.stageData = stageData
Smc.setCraftDataByPos(pos, craftData)
end
---Checks if the workstation is busy or free for new crafting.
---
---The verification is based on `ImmersiveCraftData`.
---@param pos MapPosition
---@return boolean
function Smc.workStationIsFree(pos)
local data = Smc.getCraftDataByPos(pos)
if data == nil then
return true
else
return false
end
end