local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local __TS__Class = ____lualib.__TS__Class
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
local __TS__DecorateLegacy = ____lualib.__TS__DecorateLegacy
local ____exports = {}
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
local ____decorators = require("decorators")
local Exported = ____decorators.Exported
local ____log = require("functions.log")
local logError = ____log.logError
local ____Feature = require("classes.private.Feature")
local Feature = ____Feature.Feature
local v = {run = {
    queuedTaintedLazarus = {},
    queuedDeadTaintedLazarus = {},
    subPlayerMap = __TS__New(Map)
}}
--- This feature provides a way for end-users to get the `EntityPlayer` object for the other Tainted
-- Lazarus.
____exports.TaintedLazarusPlayers = __TS__Class()
local TaintedLazarusPlayers = ____exports.TaintedLazarusPlayers
TaintedLazarusPlayers.name = "TaintedLazarusPlayers"
__TS__ClassExtends(TaintedLazarusPlayers, Feature)
function TaintedLazarusPlayers.prototype.____constructor(self)
    Feature.prototype.____constructor(self)
    self.v = v
    self.vConditionalFunc = function() return false end
    self.postPlayerInit = function(____, player)
        local character = player:GetPlayerType()
        if character == PlayerType.LAZARUS_B then
            local ____v_run_queuedTaintedLazarus_0 = v.run.queuedTaintedLazarus
            ____v_run_queuedTaintedLazarus_0[#____v_run_queuedTaintedLazarus_0 + 1] = player
        elseif character == PlayerType.LAZARUS_2_B then
            local ____v_run_queuedDeadTaintedLazarus_1 = v.run.queuedDeadTaintedLazarus
            ____v_run_queuedDeadTaintedLazarus_1[#____v_run_queuedDeadTaintedLazarus_1 + 1] = player
        else
            return
        end
        self:checkDequeue()
    end
    self.callbacksUsed = {{ModCallback.POST_PLAYER_INIT, self.postPlayerInit}}
end
function TaintedLazarusPlayers.prototype.checkDequeue(self)
    if #v.run.queuedTaintedLazarus == 0 or #v.run.queuedDeadTaintedLazarus == 0 then
        return
    end
    local taintedLazarus = table.remove(v.run.queuedTaintedLazarus, 1)
    local deadTaintedLazarus = table.remove(v.run.queuedDeadTaintedLazarus, 1)
    if taintedLazarus == nil or deadTaintedLazarus == nil then
        return
    end
    local taintedLazarusPtrHash = GetPtrHash(taintedLazarus)
    local deadTaintedLazarusPtrHash = GetPtrHash(deadTaintedLazarus)
    if taintedLazarusPtrHash == deadTaintedLazarusPtrHash then
        logError("Failed to cache the Tainted Lazarus player objects, since the hash for Tainted Lazarus and Dead Tainted Lazarus were the same.")
        return
    end
    v.run.subPlayerMap:set(taintedLazarusPtrHash, deadTaintedLazarus)
    v.run.subPlayerMap:set(deadTaintedLazarusPtrHash, taintedLazarus)
end
function TaintedLazarusPlayers.prototype.getTaintedLazarusSubPlayer(self, player)
    local ptrHash = GetPtrHash(player)
    return v.run.subPlayerMap:get(ptrHash)
end
__TS__DecorateLegacy({Exported}, TaintedLazarusPlayers.prototype, "getTaintedLazarusSubPlayer", true)
return ____exports
