isaacscript-common
Version:
Helper functions and features for IsaacScript mods.
376 lines (375 loc) • 19.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBatteries = getBatteries;
exports.getBombPickups = getBombPickups;
exports.getCards = getCards;
exports.getChests = getChests;
exports.getCoins = getCoins;
exports.getCollectibles = getCollectibles;
exports.getHearts = getHearts;
exports.getKeys = getKeys;
exports.getPills = getPills;
exports.getSacks = getSacks;
exports.getTrinkets = getTrinkets;
exports.removeAllBatteries = removeAllBatteries;
exports.removeAllBombPickups = removeAllBombPickups;
exports.removeAllCards = removeAllCards;
exports.removeAllChests = removeAllChests;
exports.removeAllCoins = removeAllCoins;
exports.removeAllCollectibles = removeAllCollectibles;
exports.removeAllHearts = removeAllHearts;
exports.removeAllKeys = removeAllKeys;
exports.removeAllPills = removeAllPills;
exports.removeAllSacks = removeAllSacks;
exports.removeAllTrinkets = removeAllTrinkets;
exports.spawnBattery = spawnBattery;
exports.spawnBatteryWithSeed = spawnBatteryWithSeed;
exports.spawnBombPickup = spawnBombPickup;
exports.spawnBombPickupWithSeed = spawnBombPickupWithSeed;
exports.spawnCard = spawnCard;
exports.spawnCardWithSeed = spawnCardWithSeed;
exports.spawnCoin = spawnCoin;
exports.spawnCoinWithSeed = spawnCoinWithSeed;
exports.spawnHeart = spawnHeart;
exports.spawnHeartWithSeed = spawnHeartWithSeed;
exports.spawnKey = spawnKey;
exports.spawnKeyWithSeed = spawnKeyWithSeed;
exports.spawnPill = spawnPill;
exports.spawnPillWithSeed = spawnPillWithSeed;
exports.spawnSack = spawnSack;
exports.spawnSackWithSeed = spawnSackWithSeed;
exports.spawnTrinket = spawnTrinket;
exports.spawnTrinketWithSeed = spawnTrinketWithSeed;
const isaac_typescript_definitions_1 = require("isaac-typescript-definitions");
const constants_1 = require("../core/constants");
const entities_1 = require("./entities");
const entitiesSpecific_1 = require("./entitiesSpecific");
/**
* Helper function to get all of the battery entities in the room.
*
* @param batterySubType Optional. If specified, will only get the batteries that match the
* sub-type. Default is -1, which matches every sub-type.
*/
function getBatteries(batterySubType = -1) {
return (0, entitiesSpecific_1.getPickups)(isaac_typescript_definitions_1.PickupVariant.LIL_BATTERY, batterySubType);
}
/**
* Helper function to get all of the bomb entities in the room. (Specifically, this refers to bomb
* pickups, not the `EntityBomb` class.)
*
* @param bombSubType Optional. If specified, will only get the bombs that match the sub-type.
* Default is -1, which matches every sub-type.
*/
function getBombPickups(bombSubType = -1) {
return (0, entitiesSpecific_1.getPickups)(isaac_typescript_definitions_1.PickupVariant.BOMB, bombSubType);
}
/**
* Helper function to get all of the card entities in the room.
*
* @param cardType Optional. If specified, will only get the cards that match the sub-type. Default
* is -1, which matches every sub-type.
*/
function getCards(cardType = -1) {
return (0, entitiesSpecific_1.getPickups)(isaac_typescript_definitions_1.PickupVariant.CARD, cardType);
}
/**
* Helper function to get all of the chest entities in the room. Specifically, this is all of the
* pickups with a variant in the `CHEST_PICKUP_VARIANTS` constant.
*
* @param subType Optional. If specified, will only get the chests that match the sub-type. Default
* is -1, which matches every sub-type.
*/
function getChests(subType = -1) {
const chests = [];
for (const pickupVariant of constants_1.CHEST_PICKUP_VARIANTS) {
const pickups = (0, entitiesSpecific_1.getPickups)(pickupVariant, subType);
chests.push(...pickups);
}
return chests;
}
/**
* Helper function to get all of the coin pickup entities in the room.
*
* @param coinSubType Optional. If specified, will only get the coins that match the sub-type.
* Default is -1, which matches every sub-type.
*/
function getCoins(coinSubType = -1) {
return (0, entitiesSpecific_1.getPickups)(isaac_typescript_definitions_1.PickupVariant.COIN, coinSubType);
}
/**
* Helper function to get all of the collectible entities in the room.
*
* @param collectibleType Optional. If specified, will only get the collectibles that match the
* sub-type. Default is -1, which matches every sub-type.
*/
function getCollectibles(collectibleType = -1) {
return (0, entitiesSpecific_1.getPickups)(isaac_typescript_definitions_1.PickupVariant.COLLECTIBLE, collectibleType);
}
/**
* Helper function to get all of the heart pickup entities in the room.
*
* @param heartSubType Optional. If specified, will only get the hearts that match the sub-type.
* Default is -1, which matches every sub-type.
*/
function getHearts(heartSubType = -1) {
return (0, entitiesSpecific_1.getPickups)(isaac_typescript_definitions_1.PickupVariant.HEART, heartSubType);
}
/**
* Helper function to get all of the key pickup entities in the room.
*
* @param keySubType Optional. If specified, will only get the keys that match the sub-type. Default
* is -1, which matches every sub-type.
*/
function getKeys(keySubType = -1) {
return (0, entitiesSpecific_1.getPickups)(isaac_typescript_definitions_1.PickupVariant.KEY, keySubType);
}
/**
* Helper function to get all of the pill entities in the room.
*
* @param pillColor Optional. If specified, will only get the pills that match the sub-type. Default
* is -1, which matches every sub-type.
*/
function getPills(pillColor = -1) {
return (0, entitiesSpecific_1.getPickups)(isaac_typescript_definitions_1.PickupVariant.PILL, pillColor);
}
/**
* Helper function to get all of the sack (i.e. grab bag) entities in the room.
*
* @param sackSubType Optional. If specified, will only get the sacks that match the sub-type.
* Default is -1, which matches every sub-type.
*/
function getSacks(sackSubType = -1) {
return (0, entitiesSpecific_1.getPickups)(isaac_typescript_definitions_1.PickupVariant.SACK, sackSubType);
}
/**
* Helper function to get all of the trinket entities in the room.
*
* @param trinketType Optional. If specified, will only get the trinkets that match the sub-type.
* Default is -1, which matches every sub-type.
*/
function getTrinkets(trinketType = -1) {
return (0, entitiesSpecific_1.getPickups)(isaac_typescript_definitions_1.PickupVariant.TRINKET, trinketType);
}
/**
* Helper function to remove all of the batteries in the room.
*
* @param batterySubType Optional. If specified, will only remove the batteries that match this
* sub-type. Default is -1, which matches every sub-type.
* @param cap Optional. If specified, will only remove the given amount of cards.
* @returns The batteries that were removed.
*/
function removeAllBatteries(batterySubType = -1, cap) {
return (0, entitiesSpecific_1.removeAllPickups)(isaac_typescript_definitions_1.PickupVariant.LIL_BATTERY, batterySubType, cap);
}
/**
* Helper function to remove all of the bomb pickups in the room. (Specifically, this refers to bomb
* pickups, not the `EntityBomb` class.)
*
* @param bombSubType Optional. If specified, will only remove bombs that match this sub-type.
* Default is -1, which matches every sub-type.
* @param cap Optional. If specified, will only remove the given amount of bombs.
* @returns The bombs that were removed.
*/
function removeAllBombPickups(bombSubType = -1, cap) {
return (0, entitiesSpecific_1.removeAllPickups)(isaac_typescript_definitions_1.PickupVariant.BOMB, bombSubType, cap);
}
/**
* Helper function to remove all of the cards in the room.
*
* @param cardType Optional. If specified, will only remove cards that match this sub-type. Default
* is -1, which matches every sub-type.
* @param cap Optional. If specified, will only remove the given amount of cards.
* @returns The cards that were removed.
*/
function removeAllCards(cardType = -1, cap) {
return (0, entitiesSpecific_1.removeAllPickups)(isaac_typescript_definitions_1.PickupVariant.CARD, cardType, cap);
}
/**
* Helper function to remove all of the chests in the room. Specifically, this is all of the pickups
* with a variant in the `CHEST_PICKUP_VARIANTS` constant.
*
* @param subType Optional. If specified, will only remove chests that match this sub-type. Default
* is -1, which matches every sub-type.
* @param cap Optional. If specified, will only remove the given amount of chests.
* @returns The chests that were removed.
*/
function removeAllChests(subType = -1, cap) {
const chests = getChests(subType);
return (0, entities_1.removeEntities)(chests, cap);
}
/**
* Helper function to remove all of the coins in the room.
*
* @param coinSubType Optional. If specified, will only remove coins that match this sub-type.
* Default is -1, which matches every sub-type.
* @param cap Optional. If specified, will only remove the given amount of coins.
* @returns The coins that were removed.
*/
function removeAllCoins(coinSubType, cap) {
return (0, entitiesSpecific_1.removeAllPickups)(isaac_typescript_definitions_1.PickupVariant.COIN, coinSubType, cap);
}
/**
* Helper function to remove all of the collectibles in the room.
*
* @param collectibleType Optional. If specified, will only remove collectibles that match this
* sub-type. Default is -1, which matches every sub-type.
* @param cap Optional. If specified, will only remove the given amount of collectibles.
* @returns The collectibles that were removed.
*/
function removeAllCollectibles(collectibleType, cap) {
return (0, entitiesSpecific_1.removeAllPickups)(isaac_typescript_definitions_1.PickupVariant.COLLECTIBLE, collectibleType, cap);
}
/**
* Helper function to remove all of the heart pickup entities in the room.
*
* @param heartSubType Optional. If specified, will only remove hearts that match this sub-type.
* Default is -1, which matches every sub-type.
* @param cap Optional. If specified, will only remove the given amount of hearts.
* @returns The hearts that were removed.
*/
function removeAllHearts(heartSubType, cap) {
return (0, entitiesSpecific_1.removeAllPickups)(isaac_typescript_definitions_1.PickupVariant.HEART, heartSubType, cap);
}
/**
* Helper function to remove all of the keys in the room.
*
* @param keySubType Optional. If specified, will only remove keys that match this sub-type. Default
* is -1, which matches every sub-type.
* @param cap Optional. If specified, will only remove the given amount of keys.
* @returns The keys that were removed.
*/
function removeAllKeys(keySubType, cap) {
return (0, entitiesSpecific_1.removeAllPickups)(isaac_typescript_definitions_1.PickupVariant.KEY, keySubType, cap);
}
/**
* Helper function to remove all of the pills in the room.
*
* @param pillColor Optional. If specified, will only remove pills that match this sub-type. Default
* is -1, which matches every sub-type.
* @param cap Optional. If specified, will only remove the given amount of pills.
* @returns The pills that were removed.
*/
function removeAllPills(pillColor, cap) {
return (0, entitiesSpecific_1.removeAllPickups)(isaac_typescript_definitions_1.PickupVariant.PILL, pillColor, cap);
}
/**
* Helper function to remove all of the sacks (i.e. grab bags) in the room.
*
* @param sackSubType Optional. If specified, will only remove sacks that match this sub-type.
* Default is -1, which matches every sub-type.
* @param cap Optional. If specified, will only remove the given amount of sacks.
* @returns The sacks that were removed.
*/
function removeAllSacks(sackSubType, cap) {
return (0, entitiesSpecific_1.removeAllPickups)(isaac_typescript_definitions_1.PickupVariant.SACK, sackSubType, cap);
}
/**
* Helper function to remove all of the trinkets in the room.
*
* @param trinketType Optional. If specified, will only remove trinkets that match this sub-type.
* Default is -1, which matches every sub-type.
* @param cap Optional. If specified, will only remove the given amount of trinkets.
* @returns The trinkets that were removed.
*/
function removeAllTrinkets(trinketType, cap) {
return (0, entitiesSpecific_1.removeAllPickups)(isaac_typescript_definitions_1.PickupVariant.TRINKET, trinketType, cap);
}
/**
* Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.LIL_BATTERY` (90).
*/
function spawnBattery(batterySubType, positionOrGridIndex, velocity = constants_1.VectorZero, spawner = undefined, seedOrRNG = undefined) {
return (0, entitiesSpecific_1.spawnPickup)(isaac_typescript_definitions_1.PickupVariant.LIL_BATTERY, batterySubType, positionOrGridIndex, velocity, spawner, seedOrRNG);
}
/**
* Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.LIL_BATTERY` (90)
* and a specific seed.
*/
function spawnBatteryWithSeed(batterySubType, positionOrGridIndex, seedOrRNG, velocity = constants_1.VectorZero, spawner = undefined) {
return spawnBattery(batterySubType, positionOrGridIndex, velocity, spawner, seedOrRNG);
}
/** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.BOMB` (40). */
function spawnBombPickup(bombSubType, positionOrGridIndex, velocity = constants_1.VectorZero, spawner = undefined, seedOrRNG = undefined) {
return (0, entitiesSpecific_1.spawnPickup)(isaac_typescript_definitions_1.PickupVariant.BOMB, bombSubType, positionOrGridIndex, velocity, spawner, seedOrRNG);
}
/**
* Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.BOMB` (40) and a
* specific seed.
*/
function spawnBombPickupWithSeed(bombSubType, positionOrGridIndex, seedOrRNG, velocity = constants_1.VectorZero, spawner = undefined) {
return spawnBombPickup(bombSubType, positionOrGridIndex, velocity, spawner, seedOrRNG);
}
/** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.CARD` (300). */
function spawnCard(cardType, positionOrGridIndex, velocity = constants_1.VectorZero, spawner = undefined, seedOrRNG = undefined) {
return (0, entitiesSpecific_1.spawnPickup)(isaac_typescript_definitions_1.PickupVariant.CARD, cardType, positionOrGridIndex, velocity, spawner, seedOrRNG);
}
/**
* Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.CARD` (300) and a
* specific seed.
*/
function spawnCardWithSeed(cardType, positionOrGridIndex, seedOrRNG, velocity = constants_1.VectorZero, spawner = undefined) {
return spawnCard(cardType, positionOrGridIndex, velocity, spawner, seedOrRNG);
}
/** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.COIN` (20). */
function spawnCoin(coinSubType, positionOrGridIndex, velocity = constants_1.VectorZero, spawner = undefined, seedOrRNG = undefined) {
return (0, entitiesSpecific_1.spawnPickup)(isaac_typescript_definitions_1.PickupVariant.COIN, coinSubType, positionOrGridIndex, velocity, spawner, seedOrRNG);
}
/**
* Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.COIN` (20) and a
* specific seed.
*/
function spawnCoinWithSeed(coinSubType, positionOrGridIndex, seedOrRNG, velocity = constants_1.VectorZero, spawner = undefined) {
return spawnCoin(coinSubType, positionOrGridIndex, velocity, spawner, seedOrRNG);
}
/** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.HEART` (10). */
function spawnHeart(heartSubType, positionOrGridIndex, velocity = constants_1.VectorZero, spawner = undefined, seedOrRNG = undefined) {
return (0, entitiesSpecific_1.spawnPickup)(isaac_typescript_definitions_1.PickupVariant.HEART, heartSubType, positionOrGridIndex, velocity, spawner, seedOrRNG);
}
function spawnHeartWithSeed(heartSubType, positionOrGridIndex, seedOrRNG, velocity = constants_1.VectorZero, spawner = undefined) {
return spawnHeart(heartSubType, positionOrGridIndex, velocity, spawner, seedOrRNG);
}
/** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.KEY` (30). */
function spawnKey(keySubType, positionOrGridIndex, velocity = constants_1.VectorZero, spawner = undefined, seedOrRNG = undefined) {
return (0, entitiesSpecific_1.spawnPickup)(isaac_typescript_definitions_1.PickupVariant.KEY, keySubType, positionOrGridIndex, velocity, spawner, seedOrRNG);
}
/**
* Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.KEY` (30) and a
* specific seed.
*/
function spawnKeyWithSeed(keySubType, positionOrGridIndex, seedOrRNG, velocity = constants_1.VectorZero, spawner = undefined) {
return spawnKey(keySubType, positionOrGridIndex, velocity, spawner, seedOrRNG);
}
/** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.PILL` (70). */
function spawnPill(pillColor, positionOrGridIndex, velocity = constants_1.VectorZero, spawner = undefined, seedOrRNG = undefined) {
return (0, entitiesSpecific_1.spawnPickup)(isaac_typescript_definitions_1.PickupVariant.PILL, pillColor, positionOrGridIndex, velocity, spawner, seedOrRNG);
}
/**
* Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.PILL` (70) and a
* specific seed.
*/
function spawnPillWithSeed(pillColor, positionOrGridIndex, seedOrRNG, velocity = constants_1.VectorZero, spawner = undefined) {
return spawnPill(pillColor, positionOrGridIndex, velocity, spawner, seedOrRNG);
}
/** Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.SACK` (69). */
function spawnSack(sackSubType, positionOrGridIndex, velocity = constants_1.VectorZero, spawner = undefined, seedOrRNG = undefined) {
return (0, entitiesSpecific_1.spawnPickup)(isaac_typescript_definitions_1.PickupVariant.SACK, sackSubType, positionOrGridIndex, velocity, spawner, seedOrRNG);
}
/**
* Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.SACK` (69) and a
* specific seed.
*/
function spawnSackWithSeed(sackSubType, positionOrGridIndex, seedOrRNG, velocity = constants_1.VectorZero, spawner = undefined) {
return spawnSack(sackSubType, positionOrGridIndex, velocity, spawner, seedOrRNG);
}
/**
* Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.TRINKET` (350).
*/
function spawnTrinket(trinketType, positionOrGridIndex, velocity = constants_1.VectorZero, spawner = undefined, seedOrRNG = undefined) {
return (0, entitiesSpecific_1.spawnPickup)(isaac_typescript_definitions_1.PickupVariant.TRINKET, trinketType, positionOrGridIndex, velocity, spawner, seedOrRNG);
}
/**
* Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.TRINKET` (350) and
* a specific seed.
*/
function spawnTrinketWithSeed(trinketType, positionOrGridIndex, seedOrRNG, velocity = constants_1.VectorZero, spawner = undefined) {
return spawnTrinket(trinketType, positionOrGridIndex, velocity, spawner, seedOrRNG);
}