Using repentogon better callbacks if available

This commit is contained in:
theo@manjaro 2024-01-05 15:09:08 +01:00
parent eeba233fc8
commit d0b2db92f2
1 changed files with 37 additions and 22 deletions

View File

@ -9,11 +9,14 @@ local save = savegen:new()
local json = include("json") local json = include("json")
local DEBUG = false local DEBUG = false
local getgamedata = Isaac.GetPersistentGameData -- Repentogon exclusive local getgamedata = Isaac.GetPersistentGameData -- Repentogon exclusive
local isrepentogon = getgamedata ~= nil
isrepentogon = false
mod.font = Font() mod.font = Font()
mod.font:Load("font/terminus.fnt") mod.font:Load("font/terminus.fnt")
function mod:isCurseBlind() function mod:isCurseBlind(pickupEntity)
if isrepentogon then return pickupEntity:IsBlind() end
return mod.game:GetLevel():GetCurses() & LevelCurse.CURSE_OF_BLIND > 0 return mod.game:GetLevel():GetCurses() & LevelCurse.CURSE_OF_BLIND > 0
end end
@ -22,28 +25,27 @@ function mod.isIdNotTakenAlready(id)
-- Always returns seen if on a challenge -- Always returns seen if on a challenge
if Isaac.GetChallenge() ~= 0 then return false end if Isaac.GetChallenge() ~= 0 then return false end
-- Check using REPENTOGON if id > save.settings.maxid then
if getgamedata then if save.settings.showonmodded then
if getgamedata():IsItemInCollection(id) then local itemconfig = Isaac.GetItemConfig():GetCollectible(id)
if not save.seen[id] then if itemconfig then
save:touchid(id) local name = itemconfig.Name
mod:save() return not save.seenmodded[name]
end end
return false
end end
end else
-- Check using REPENTOGON
if id <= save.settings.maxid then return not save.seen[id] end if isrepentogon then
if getgamedata():IsItemInCollection(id) then
if id > save.settings.maxid and save.settings.showonmodded then if not save.seen[id] then
local itemconfig = Isaac.GetItemConfig():GetCollectible(id) mod.registerTouched(id)
if itemconfig then end
local name = itemconfig.Name return false
return not save.seenmodded[name] end
end end
end
return false return not save.seen[id]
end
else else
return false -- Don't show on empty pedestals return false -- Don't show on empty pedestals
end end
@ -123,7 +125,7 @@ end
-- Used to draw the ! sign -- Used to draw the ! sign
function mod:PickupDrawCallback(pickupEntity, _) function mod:PickupDrawCallback(pickupEntity, _)
if save.settings.visual and if save.settings.visual and
(not mod:isCurseBlind() or save.settings.showonblind) then (not (mod:isCurseBlind(pickupEntity)) or save.settings.showonblind) then
if pickupEntity.Variant == PickupVariant.PICKUP_COLLECTIBLE then if pickupEntity.Variant == PickupVariant.PICKUP_COLLECTIBLE then
if mod.isIdNotTakenAlready(pickupEntity.SubType) then if mod.isIdNotTakenAlready(pickupEntity.SubType) then
local v = Isaac.WorldToScreen( local v = Isaac.WorldToScreen(
@ -166,7 +168,20 @@ function mod:save() mod:SaveData(save:dump(json)) end
mod:AddCallback(ModCallbacks.MC_POST_GAME_END, mod.save) mod:AddCallback(ModCallbacks.MC_POST_GAME_END, mod.save)
mod:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, mod.newrun) mod:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, mod.newrun)
mod:AddCallback(ModCallbacks.MC_POST_UPDATE, mod.update) if not isrepentogon then
-- Used to check for new items
mod:AddCallback(ModCallbacks.MC_POST_UPDATE, mod.update)
else
function mod.addCollectibleCallaback(_, id, _, _, _, _)
print(id)
mod.registerTouched(id)
end
-- This is not a vanilla callback, it is from repentogon
mod:AddCallback(ModCallbacks.MC_POST_ADD_COLLECTIBLE,
mod.addCollectibleCallaback)
end
-- Used to draw indicators
mod:AddCallback(ModCallbacks.MC_POST_PICKUP_RENDER, mod.PickupDrawCallback) mod:AddCallback(ModCallbacks.MC_POST_PICKUP_RENDER, mod.PickupDrawCallback)
if EID then if EID then