"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PostEffectStateChanged = void 0;
const isaac_typescript_definitions_1 = require("isaac-typescript-definitions");
const shouldFire_1 = require("../../shouldFire");
const DefaultMap_1 = require("../DefaultMap");
const CustomCallback_1 = require("../private/CustomCallback");
const v = {
    run: {
        stateMap: new DefaultMap_1.DefaultMap((state) => state),
    },
};
class PostEffectStateChanged extends CustomCallback_1.CustomCallback {
    v = v;
    constructor() {
        super();
        this.callbacksUsed = [
            // 55
            [isaac_typescript_definitions_1.ModCallback.POST_EFFECT_UPDATE, this.postEffectUpdate],
        ];
    }
    shouldFire = shouldFire_1.shouldFireEffect;
    // ModCallback.POST_EFFECT_UPDATE (55)
    postEffectUpdate = (effect) => {
        const ptrHash = GetPtrHash(effect);
        const previousState = v.run.stateMap.getAndSetDefault(ptrHash, effect.State);
        const currentState = effect.State;
        v.run.stateMap.set(ptrHash, currentState);
        if (previousState !== currentState) {
            this.fire(effect, previousState, currentState);
        }
    };
}
exports.PostEffectStateChanged = PostEffectStateChanged;
