UNPKG

isaacscript-common

Version:

Helper functions and features for IsaacScript mods.

50 lines (49 loc) 2.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getRockAltType = getRockAltType; exports.removeUrnRewards = removeUrnRewards; const isaac_typescript_definitions_1 = require("isaac-typescript-definitions"); const cachedClasses_1 = require("../core/cachedClasses"); const backdropTypeToRockAltType_1 = require("../objects/backdropTypeToRockAltType"); const entitiesSpecific_1 = require("./entitiesSpecific"); const gridEntities_1 = require("./gridEntities"); const pickupsSpecific_1 = require("./pickupsSpecific"); /** * Helper function to get the alternate rock type (i.e. urn, mushroom, etc.) that the current room * will have. * * The rock type is based on the backdrop of the room. * * For example, if you change the backdrop of the starting room of the run to `BackdropType.CAVES`, * and then spawn `GridEntityType.ROCK_ALT`, it will be a mushroom instead of an urn. Additionally, * if it is destroyed, it will generate mushroom-appropriate rewards. * * On the other hand, if an urn is spawned first before the backdrop is changed to * `BackdropType.CAVES`, the graphic of the urn will not switch to a mushroom. However, when * destroyed, the urn will still generate mushroom-appropriate rewards. */ function getRockAltType() { const room = cachedClasses_1.game.GetRoom(); const backdropType = room.GetBackdropType(); return backdropTypeToRockAltType_1.BACKDROP_TYPE_TO_ROCK_ALT_TYPE[backdropType]; } /** * Helper function to remove all coins, trinkets, and so on that spawned from breaking an urn. * * The rewards are based on the ones from the wiki: * https://bindingofisaacrebirth.fandom.com/wiki/Rocks#Urns */ function removeUrnRewards(gridEntity) { // Coins const coins = (0, pickupsSpecific_1.getCoins)(); (0, gridEntities_1.removeEntitiesSpawnedFromGridEntity)(coins, gridEntity); // A Quarter const quarters = (0, pickupsSpecific_1.getCollectibles)(isaac_typescript_definitions_1.CollectibleType.QUARTER); (0, gridEntities_1.removeEntitiesSpawnedFromGridEntity)(quarters, gridEntity); // Swallowed Penny const swallowedPennies = (0, pickupsSpecific_1.getTrinkets)(isaac_typescript_definitions_1.TrinketType.SWALLOWED_PENNY); (0, gridEntities_1.removeEntitiesSpawnedFromGridEntity)(swallowedPennies, gridEntity); // Spiders const spiders = (0, entitiesSpecific_1.getNPCs)(isaac_typescript_definitions_1.EntityType.SPIDER); (0, gridEntities_1.removeEntitiesSpawnedFromGridEntity)(spiders, gridEntity); }