local ____lualib = require("lualib_bundle")
local __TS__New = ____lualib.__TS__New
local __TS__Class = ____lualib.__TS__Class
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
local ____exports = {}
local ____ModCallbackCustom = require("enums.ModCallbackCustom")
local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
local ____sprites = require("functions.sprites")
local getLastFrameOfAnimation = ____sprites.getLastFrameOfAnimation
local ____stage = require("functions.stage")
local getEffectiveStage = ____stage.getEffectiveStage
local ____ReadonlySet = require("types.ReadonlySet")
local ReadonlySet = ____ReadonlySet.ReadonlySet
local ____CustomCallback = require("classes.private.CustomCallback")
local CustomCallback = ____CustomCallback.CustomCallback
local TRAVELING_TO_NEXT_FLOOR_ANIMATIONS = __TS__New(ReadonlySet, {"Trapdoor", "LightTravel"})
local v = {run = {firedOnStage = nil}}
____exports.PreNewLevel = __TS__Class()
local PreNewLevel = ____exports.PreNewLevel
PreNewLevel.name = "PreNewLevel"
__TS__ClassExtends(PreNewLevel, CustomCallback)
function PreNewLevel.prototype.____constructor(self)
    CustomCallback.prototype.____constructor(self)
    self.v = v
    self.postPlayerRenderReordered = function(____, player)
        local effectiveStage = getEffectiveStage(nil)
        if effectiveStage == v.run.firedOnStage then
            return
        end
        local sprite = player:GetSprite()
        local animation = sprite:GetAnimation()
        if not TRAVELING_TO_NEXT_FLOOR_ANIMATIONS:has(animation) then
            return
        end
        local frame = sprite:GetFrame()
        local finalFrame = getLastFrameOfAnimation(nil, sprite)
        if frame == finalFrame then
            v.run.firedOnStage = effectiveStage
            self:fire(player)
        end
    end
    self.customCallbacksUsed = {{ModCallbackCustom.POST_PLAYER_RENDER_REORDERED, self.postPlayerRenderReordered}}
end
return ____exports
