Lua 函数:清理超出范围的战利品 (cleanup_outofscope_loot)
这段 Lua 代码定义了一个名为 'cleanup_outofscope_loot' 的本地函数,用于清理超出范围的战利品。该函数会遍历 'inst._loot' 表中的所有元素,如果战利品不存在、无效、在虚空中或距离 'inst' 太远,则将其从 'inst._loot' 表中移除。其中 'TUNING.MONKEYISLAND_PORTAL_LOOTMAXDST' 是一个常量,表示战利品和 'inst' 之间的最大距离。
local function cleanup_outofscope_loot(inst)
-- If loot has gone invalid or too far away, remove it.
for i = #inst._loot, 1, -1 do
local loot = inst._loot[i]
if loot == nil or not loot:IsValid()
or loot:IsInLimbo()
or not inst:IsNear(loot, TUNING.MONKEYISLAND_PORTAL_LOOTMAXDST) then
table.remove(inst._loot, i)
end
end
end
原文地址: https://www.cveoy.top/t/topic/mLmp 著作权归作者所有。请勿转载和采集!