"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PostFamiliarStateChanged = 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 PostFamiliarStateChanged extends CustomCallback_1.CustomCallback {
    v = v;
    constructor() {
        super();
        this.callbacksUsed = [
            // 6
            [isaac_typescript_definitions_1.ModCallback.POST_FAMILIAR_UPDATE, this.postFamiliarUpdate],
        ];
    }
    shouldFire = shouldFire_1.shouldFireFamiliar;
    // ModCallback.POST_FAMILIAR_UPDATE (6)
    postFamiliarUpdate = (familiar) => {
        const ptrHash = GetPtrHash(familiar);
        const previousState = v.run.stateMap.getAndSetDefault(ptrHash, familiar.State);
        const currentState = familiar.State;
        v.run.stateMap.set(ptrHash, currentState);
        if (previousState !== currentState) {
            this.fire(familiar, previousState, currentState);
        }
    };
}
exports.PostFamiliarStateChanged = PostFamiliarStateChanged;
