"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setHasNPC = exports.setDeleteNPC = exports.setAddNPC = exports.mapSetNPC = exports.mapHasNPC = exports.mapGetNPC = exports.mapDeleteNPC = exports.defaultMapSetNPC = exports.defaultMapGetNPC = void 0;
/**
 * Helper function to make using default maps with an index of `PtrHash` easier. Use this instead of
 * the `DefaultMap.getAndSetDefault` method if you have a default map of this type.
 *
 * For example:
 *
 * ```ts
 * const v = {
 *   run: {
 *     npcsSpeedBoost: new DefaultMap<PtrHash, int>(0),
 *   },
 * };
 *
 * function npcUpdate(npc: EntityNPC) {
 *   const speedBoost = defaultMapGetNPC(v.run.npcsSpeedBoost, npc);
 *   // Do something with the speed boost.
 * }
 * ```
 *
 * Note that not all NPCs should be stored in a map with a `PtrHash` as an index, so only use this
 * in the situations where that would be okay. (For example, Dark Esau should never be stored in a
 * map like this, because the scope of `PtrHash` is per room and Dark Esau is persistent between
 * rooms.)
 */
function defaultMapGetNPC(map, npc, ...extraArgs) {
    const ptrHash = GetPtrHash(npc);
    return map.getAndSetDefault(ptrHash, ...extraArgs);
}
exports.defaultMapGetNPC = defaultMapGetNPC;
/**
 * Helper function to make using maps with an index of `PtrHash` easier. Use this instead of the
 * `Map.set` method if you have a map of this type.
 *
 * Since `Map` and `DefaultMap` set values in the same way, this function is simply an alias for the
 * `mapSetNPC` helper function.
 */
function defaultMapSetNPC(
// eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
map, npc, value) {
    mapSetNPC(map, npc, value);
}
exports.defaultMapSetNPC = defaultMapSetNPC;
/**
 * Helper function to make using maps with an type of `PtrHash` easier. Use this instead of the
 * `Map.delete` method if you have a set of this type.
 */
function mapDeleteNPC(
// eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
map, npc) {
    const ptrHash = GetPtrHash(npc);
    return map.delete(ptrHash);
}
exports.mapDeleteNPC = mapDeleteNPC;
/**
 * Helper function to make using maps with an index of `PtrHash` easier. Use this instead of the
 * `Map.get` method if you have a map of this type.
 *
 * For example:
 *
 * ```ts
 * const v = {
 *   run: {
 *     npcsSpeedBoost: new Map<PtrHash, int>(),
 *   },
 * };
 *
 * function incrementSpeedBoost(npc: EntityNPC) {
 *   const oldSpeedBoost = mapGetNPC(v.run.npcsSpeedBoost, npc);
 *   const newSpeedBoost = oldSpeedBoost + 0.1;
 *   mapSetNPC(v.run.npcsSpeedBoost, npc);
 * }
 * ```
 */
function mapGetNPC(map, npc) {
    const ptrHash = GetPtrHash(npc);
    return map.get(ptrHash);
}
exports.mapGetNPC = mapGetNPC;
/**
 * Helper function to make using maps with an index of `PtrHash` easier. Use this instead of the
 * `Map.has` method if you have a map of this type.
 */
function mapHasNPC(map, npc) {
    const ptrHash = GetPtrHash(npc);
    return map.has(ptrHash);
}
exports.mapHasNPC = mapHasNPC;
/**
 * Helper function to make using maps with an index of `PtrHash` easier. Use this instead of the
 * `Map.set` method if you have a map of this type.
 *
 * For example:
 *
 * ```ts
 * const v = {
 *   run: {
 *     npcsSpeedBoost: new Map<PtrHash, int>(),
 *   },
 * };
 *
 * function incrementSpeedBoost(npc: EntityNPC) {
 *   const oldSpeedBoost = mapGetNPC(v.run.npcsSpeedBoost, npc);
 *   const newSpeedBoost = oldSpeedBoost + 0.1;
 *   mapSetNPC(v.run.npcsSpeedBoost, npc);
 * }
 * ```
 */
function mapSetNPC(
// eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
map, npc, value) {
    const ptrHash = GetPtrHash(npc);
    map.set(ptrHash, value);
}
exports.mapSetNPC = mapSetNPC;
/**
 * Helper function to make using sets with an type of `PtrHash` easier. Use this instead of the
 * `Set.add` method if you have a set of this type.
 */
// eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
function setAddNPC(set, npc) {
    const ptrHash = GetPtrHash(npc);
    set.add(ptrHash);
}
exports.setAddNPC = setAddNPC;
/**
 * Helper function to make using sets with an type of `PtrHash` easier. Use this instead of the
 * `Set.delete` method if you have a set of this type.
 */
// eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
function setDeleteNPC(set, npc) {
    const ptrHash = GetPtrHash(npc);
    return set.delete(ptrHash);
}
exports.setDeleteNPC = setDeleteNPC;
/**
 * Helper function to make using sets with an type of `PtrHash` easier. Use this instead of the
 * `Set.has` method if you have a set of this type.
 */
function setHasNPC(set, npc) {
    const ptrHash = GetPtrHash(npc);
    return set.has(ptrHash);
}
exports.setHasNPC = setHasNPC;
