local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
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 __TS__ArraySome = ____lualib.__TS__ArraySome
local ____exports = {}
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
local EntityFlag = ____isaac_2Dtypescript_2Ddefinitions.EntityFlag
local ____decorators = require("decorators")
local Exported = ____decorators.Exported
local ____ModCallbackCustom = require("enums.ModCallbackCustom")
local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
local ____flag = require("functions.flag")
local hasFlag = ____flag.hasFlag
local ____playerDataStructures = require("functions.playerDataStructures")
local setAddPlayer = ____playerDataStructures.setAddPlayer
local setDeletePlayer = ____playerDataStructures.setDeletePlayer
local setHasPlayer = ____playerDataStructures.setHasPlayer
local ____playerIndex = require("functions.playerIndex")
local getPlayers = ____playerIndex.getPlayers
local ____Feature = require("classes.private.Feature")
local Feature = ____Feature.Feature
local FLAGS_WHEN_PONY_IS_ACTIVE = {EntityFlag.NO_KNOCKBACK, EntityFlag.NO_PHYSICS_KNOCKBACK, EntityFlag.NO_DAMAGE_BLINK}
local v = {run = {playersIsPonyActive = __TS__New(Set)}}
____exports.PonyDetection = __TS__Class()
local PonyDetection = ____exports.PonyDetection
PonyDetection.name = "PonyDetection"
__TS__ClassExtends(PonyDetection, Feature)
function PonyDetection.prototype.____constructor(self)
    Feature.prototype.____constructor(self)
    self.v = v
    self.postPEffectUpdateReordered = function(____, player)
        local effects = player:GetEffects()
        local entityFlags = player:GetEntityFlags()
        local hasPonyCollectibleEffect = effects:HasCollectibleEffect(CollectibleType.PONY) or effects:HasCollectibleEffect(CollectibleType.WHITE_PONY)
        local isPonyActiveOnPreviousFrame = setHasPlayer(nil, v.run.playersIsPonyActive, player)
        local hasPonyFlags = hasFlag(
            nil,
            entityFlags,
            table.unpack(FLAGS_WHEN_PONY_IS_ACTIVE)
        )
        local isPonyActiveNow = hasPonyCollectibleEffect or isPonyActiveOnPreviousFrame and hasPonyFlags
        if isPonyActiveNow then
            setAddPlayer(nil, v.run.playersIsPonyActive, player)
        else
            setDeletePlayer(nil, v.run.playersIsPonyActive, player)
        end
    end
    self.customCallbacksUsed = {{ModCallbackCustom.POST_PEFFECT_UPDATE_REORDERED, self.postPEffectUpdateReordered}}
end
function PonyDetection.prototype.isPlayerUsingPony(self, player)
    return setHasPlayer(nil, v.run.playersIsPonyActive, player)
end
__TS__DecorateLegacy({Exported}, PonyDetection.prototype, "isPlayerUsingPony", true)
function PonyDetection.prototype.anyPlayerUsingPony(self)
    local players = getPlayers(nil)
    return __TS__ArraySome(
        players,
        function(____, player) return self:isPlayerUsingPony(player) end
    )
end
__TS__DecorateLegacy({Exported}, PonyDetection.prototype, "anyPlayerUsingPony", true)
return ____exports
