use ItemConfig:IsAvailable
This commit is contained in:
1 parent
b5b7ce4c48
commit
ffa1685a9e
1 file changed
+17
-45
+17
-45
@@ -1229,57 +1229,29 @@ function EID:DetectModdedItems()
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function EID:isCollectibleUnlocked(collectibleID, itemPoolOfItem)
|
function EID:isCollectibleUnlocked(collectibleID)
|
||||||
local itemPool = game:GetItemPool()
|
--THIS FUNCTION IS FOR REPENTANCE ONLY due to using ItemConfig.IsAvailable
|
||||||
if maxCollectibleID == nil then maxCollectibleID = EID:GetMaxCollectibleID() end
|
|
||||||
for i= 1, maxCollectibleID do
|
|
||||||
if ItemConfig.Config.IsValidCollectible(i) and i ~= collectibleID then
|
|
||||||
itemPool:AddRoomBlacklist(i)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local isUnlocked = false
|
|
||||||
for _ = 0, 1 do -- some samples to make sure
|
|
||||||
local collID = itemPool:GetCollectible(itemPoolOfItem, false, 1)
|
|
||||||
if collID == collectibleID then
|
|
||||||
isUnlocked = true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
itemPool:ResetRoomBlacklist()
|
|
||||||
return isUnlocked
|
|
||||||
end
|
|
||||||
|
|
||||||
function EID:isCollectibleUnlockedAnyPool(collectibleID)
|
|
||||||
--THIS FUNCTION IS FOR REPENTANCE ONLY due to using Repentance XML data
|
|
||||||
--Currently used by the Achievement Check, Spindown Dice, and Bag of Crafting
|
--Currently used by the Achievement Check, Spindown Dice, and Bag of Crafting
|
||||||
if not REPENTANCE or EID:PlayersHaveCollectible(CollectibleType.COLLECTIBLE_TMTRAINER) then return true end
|
--Check the itemUnlockStates table first to maybe help speed up BoC slightly
|
||||||
local item = EID.itemConfig:GetCollectible(collectibleID)
|
if EID.itemUnlockStates[collectibleID] ~= nil then
|
||||||
if item == nil then return false end
|
return EID.itemUnlockStates[collectibleID]
|
||||||
if EID.itemUnlockStates[collectibleID] == nil then
|
elseif not REPENTANCE then
|
||||||
--whitelist all quest items and items with no associated achievement
|
EID.itemUnlockStates[collectibleID] = true
|
||||||
if item.AchievementID == -1 or (item.Tags and item.Tags & ItemConfig.TAG_QUEST == ItemConfig.TAG_QUEST) then
|
return true
|
||||||
|
else
|
||||||
|
local item = EID.itemConfig:GetCollectible(collectibleID)
|
||||||
|
if item == nil then return false
|
||||||
|
-- Use the Repentance update function to determine unlock status if it exists
|
||||||
|
elseif item.IsAvailable then
|
||||||
|
EID.itemUnlockStates[collectibleID] = item:IsAvailable()
|
||||||
|
return EID.itemUnlockStates[collectibleID]
|
||||||
|
else
|
||||||
EID.itemUnlockStates[collectibleID] = true
|
EID.itemUnlockStates[collectibleID] = true
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
--blacklist all hidden items
|
|
||||||
if item.Hidden then
|
|
||||||
EID.itemUnlockStates[collectibleID] = false
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
--iterate through the pools this item can be in
|
|
||||||
for _,itemPoolID in ipairs(EID.XMLItemIsInPools[collectibleID]) do
|
|
||||||
if (itemPoolID < ItemPoolType.NUM_ITEMPOOLS and EID:isCollectibleUnlocked(collectibleID, itemPoolID)) then
|
|
||||||
EID.itemUnlockStates[collectibleID] = true
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
--note: some items will still be missed by this, if they've been taken out of their pools (especially when in Greed Mode)
|
|
||||||
EID.itemUnlockStates[collectibleID] = false
|
|
||||||
return false
|
|
||||||
else
|
|
||||||
return EID.itemUnlockStates[collectibleID]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
EID.isCollectibleUnlockedAnyPool = EID.isCollectibleUnlocked -- old name before ItemConfig:IsAvailable was added
|
||||||
|
|
||||||
-- Achievements Locked Check (do we have Cube of Meat or Book of Revelations unlocked?)
|
-- Achievements Locked Check (do we have Cube of Meat or Book of Revelations unlocked?)
|
||||||
function EID:AreAchievementsAllowed()
|
function EID:AreAchievementsAllowed()
|
||||||
|
|||||||
Reference in new issue
Block a user