More refactoring
This commit is contained in:
@@ -10,6 +10,9 @@ local dump = require("Cyka.dump")
|
|||||||
-- So we will just hardcode tools and their whitelisted magazines
|
-- So we will just hardcode tools and their whitelisted magazines
|
||||||
---@type table<string, table<string, boolean>>
|
---@type table<string, table<string, boolean>>
|
||||||
local LOAD_MAP = {
|
local LOAD_MAP = {
|
||||||
|
plasmacutter = {
|
||||||
|
oxygentank = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
---@param inventory Barotrauma.ItemInventory
|
---@param inventory Barotrauma.ItemInventory
|
||||||
@@ -67,12 +70,24 @@ local function getPermissibleItemsPerSlot(movableBySlot)
|
|||||||
for inventorySlot, items in pairs(movableBySlot) do
|
for inventorySlot, items in pairs(movableBySlot) do
|
||||||
for _, ititem in ipairs(items) do
|
for _, ititem in ipairs(items) do
|
||||||
local thisone = tostring(ititem.Prefab.Identifier.Value)
|
local thisone = tostring(ititem.Prefab.Identifier.Value)
|
||||||
|
permissibleItemsPerSlot[inventorySlot] = permissibleItemsPerSlot[inventorySlot] or {}
|
||||||
permissibleItemsPerSlot[inventorySlot][thisone] = true
|
permissibleItemsPerSlot[inventorySlot][thisone] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return permissibleItemsPerSlot
|
return permissibleItemsPerSlot
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param movableBySlot table<InventorySlot, Barotrauma.Item[]>
|
||||||
|
local function printPermissibleItems(movableBySlot)
|
||||||
|
local permissibleItemsPerSlot = getPermissibleItemsPerSlot(movableBySlot)
|
||||||
|
MyModGlobal.debugPrint("Can load:")
|
||||||
|
for _, loadableItems in pairs(permissibleItemsPerSlot) do
|
||||||
|
for loadableItem, _ in pairs(loadableItems) do
|
||||||
|
MyModGlobal.debugPrint(" " .. loadableItem)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
---@param slot InventorySlot
|
---@param slot InventorySlot
|
||||||
---@param preferMinCondition boolean
|
---@param preferMinCondition boolean
|
||||||
@@ -112,10 +127,8 @@ local function tryReloadSlot(slot, preferMinCondition)
|
|||||||
|
|
||||||
local permissibleItems = LOAD_MAP[tostring(item.Prefab.Identifier.Value)]
|
local permissibleItems = LOAD_MAP[tostring(item.Prefab.Identifier.Value)]
|
||||||
if not permissibleItems then
|
if not permissibleItems then
|
||||||
MyModGlobal.debugPrint("No permissible items for item")
|
MyModGlobal.debugPrint("No permissible items for " .. tostring(item.Prefab.Identifier.Value))
|
||||||
local permissibleItemsPerSlot = getPermissibleItemsPerSlot(movableBySlot)
|
printPermissibleItems(movableBySlot)
|
||||||
MyModGlobal.debugPrint("Can load per slot:")
|
|
||||||
dump(permissibleItemsPerSlot)
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user