local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
local ____exports = {}
local dequeue
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
local ____constants = require("core.constants")
local VectorZero = ____constants.VectorZero
local ____ModCallbackCustom = require("enums.ModCallbackCustom")
local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
local ____array = require("functions.array")
local emptyArray = ____array.emptyArray
local ____playerIndex = require("functions.playerIndex")
local getPlayerFromIndex = ____playerIndex.getPlayerFromIndex
local getPlayerIndex = ____playerIndex.getPlayerIndex
local ____Feature = require("classes.private.Feature")
local Feature = ____Feature.Feature
function dequeue(self, queue, fireFunc)
    for ____, element in ipairs(queue) do
        local playerIndex = element.playerIndex
        local renderOffset = element.renderOffset
        local player = getPlayerFromIndex(nil, playerIndex)
        if player ~= nil then
            fireFunc(nil, player, renderOffset)
        end
    end
    emptyArray(nil, queue)
end
local v = {run = {postGameStartedFiredOnThisRun = false, postPEffectUpdateQueue = {}, postPlayerUpdateQueue = {}, postPlayerRenderQueue = {}}}
____exports.PlayerReorderedCallbacks = __TS__Class()
local PlayerReorderedCallbacks = ____exports.PlayerReorderedCallbacks
PlayerReorderedCallbacks.name = "PlayerReorderedCallbacks"
__TS__ClassExtends(PlayerReorderedCallbacks, Feature)
function PlayerReorderedCallbacks.prototype.____constructor(self, postPEffectUpdateReordered, postPlayerRenderReordered, postPlayerUpdateReordered)
    Feature.prototype.____constructor(self)
    self.v = v
    self.postPEffectUpdate = function(____, player)
        if v.run.postGameStartedFiredOnThisRun then
            self.postPEffectUpdateReordered:fire(player)
        else
            local playerIndex = getPlayerIndex(nil, player)
            local ____v_run_postPEffectUpdateQueue_0 = v.run.postPEffectUpdateQueue
            ____v_run_postPEffectUpdateQueue_0[#____v_run_postPEffectUpdateQueue_0 + 1] = {playerIndex = playerIndex, renderOffset = VectorZero}
        end
    end
    self.postPlayerUpdate = function(____, player)
        if v.run.postGameStartedFiredOnThisRun then
            self.postPlayerUpdateReordered:fire(player)
        else
            local playerIndex = getPlayerIndex(nil, player)
            local ____v_run_postPlayerUpdateQueue_1 = v.run.postPlayerUpdateQueue
            ____v_run_postPlayerUpdateQueue_1[#____v_run_postPlayerUpdateQueue_1 + 1] = {playerIndex = playerIndex, renderOffset = VectorZero}
        end
    end
    self.postPlayerRender = function(____, player, renderOffset)
        if v.run.postGameStartedFiredOnThisRun then
            self.postPlayerRenderReordered:fire(player, renderOffset)
        else
            local playerIndex = getPlayerIndex(nil, player)
            local ____v_run_postPlayerRenderQueue_2 = v.run.postPlayerRenderQueue
            ____v_run_postPlayerRenderQueue_2[#____v_run_postPlayerRenderQueue_2 + 1] = {playerIndex = playerIndex, renderOffset = renderOffset}
        end
    end
    self.postGameStartedReorderedLast = function()
        v.run.postGameStartedFiredOnThisRun = true
        dequeue(nil, v.run.postPEffectUpdateQueue, self.postPEffectUpdateReordered.fire)
        dequeue(nil, v.run.postPlayerUpdateQueue, self.postPlayerUpdateReordered.fire)
        dequeue(nil, v.run.postPlayerRenderQueue, self.postPlayerRenderReordered.fire)
    end
    self.callbacksUsed = {{ModCallback.POST_PEFFECT_UPDATE, self.postPEffectUpdate}, {ModCallback.POST_PLAYER_UPDATE, self.postPlayerUpdate}, {ModCallback.POST_PLAYER_RENDER, self.postPlayerRender}}
    self.customCallbacksUsed = {{ModCallbackCustom.POST_GAME_STARTED_REORDERED_LAST, self.postGameStartedReorderedLast}}
    self.postPEffectUpdateReordered = postPEffectUpdateReordered
    self.postPlayerRenderReordered = postPlayerRenderReordered
    self.postPlayerUpdateReordered = postPlayerUpdateReordered
end
return ____exports
