Fix the damn fabricator recipes not
This commit is contained in:
@@ -547,14 +547,19 @@ Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptab
|
||||
-- For recipes that have multiple prefabs
|
||||
-- But then again what if it has 3 items with 4 prefabs each..
|
||||
-- Is that 4 iterations or 3*4 iterations?
|
||||
-- We can not use #toFind because we can remove 0th item
|
||||
-- Which means it's no longer contiguous
|
||||
-- Which means #toFind returns 0
|
||||
local toFind = recipe.requiredItems
|
||||
local remaining = #toFind
|
||||
---@type Barotrauma.Item[]
|
||||
local toGet = {}
|
||||
---@type fun(item: Barotrauma.Item): boolean, boolean
|
||||
local filter = function(item)
|
||||
local found = false
|
||||
-- DumpTable(toFind)
|
||||
-- toFind are all items we need to find
|
||||
for i, itemInfo in ipairs(toFind) do
|
||||
for i, itemInfo in pairs(toFind) do
|
||||
-- prefabs are all items that satisfy the requirements
|
||||
for _, prefab in ipairs(itemInfo.prefabs) do
|
||||
-- debugPrint(string.format("Checking %s against %s", item.Prefab.Identifier.Value, prefab))
|
||||
@@ -566,11 +571,16 @@ Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptab
|
||||
break
|
||||
end
|
||||
end
|
||||
if itemInfo.amount <= 0 then toFind[i] = nil end
|
||||
if itemInfo.amount <= 0 then
|
||||
-- debugPrint(string.format("Removing %s from toFind", itemInfo.prefabs[1]))
|
||||
toFind[i] = nil
|
||||
remaining = remaining - 1
|
||||
end
|
||||
if found then break end
|
||||
end
|
||||
-- debugPrint(string.format("Found %s %s", item.Prefab.Identifier.Value, tostring(#toFind)))
|
||||
return found, #toFind == 0
|
||||
-- DumpTable(toFind)
|
||||
-- debugPrint(string.format("Found %s %s", item.Prefab.Identifier.Value, tostring(remaining)))
|
||||
return found, remaining == 0
|
||||
end
|
||||
-- DumpTable(toGet)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user