UNPKG

isaacscript-common

Version:

Helper functions and features for IsaacScript mods.

53 lines (52 loc) 1.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PostTearKill = void 0; const isaac_typescript_definitions_1 = require("isaac-typescript-definitions"); const shouldFire_1 = require("../../shouldFire"); const CustomCallback_1 = require("../private/CustomCallback"); const v = { room: { firedSet: new Set(), }, }; class PostTearKill extends CustomCallback_1.CustomCallback { v = v; constructor() { super(); this.callbacksUsed = [ // 40 [isaac_typescript_definitions_1.ModCallback.POST_TEAR_UPDATE, this.postTearUpdate], // 42 [isaac_typescript_definitions_1.ModCallback.PRE_TEAR_COLLISION, this.preTearCollision], // 67 [isaac_typescript_definitions_1.ModCallback.POST_ENTITY_REMOVE, this.postEntityRemove], ]; } shouldFire = shouldFire_1.shouldFireTear; // ModCallback.POST_PROJECTILE_UPDATE (40) postTearUpdate = (tear) => { const ptrHash = GetPtrHash(tear); if (tear.CollidesWithGrid() || tear.IsDead()) { v.room.firedSet.add(ptrHash); } }; // ModCallback.PRE_TEAR_COLLISION (42) preTearCollision = (tear) => { const ptrHash = GetPtrHash(tear); v.room.firedSet.add(ptrHash); return undefined; }; // ModCallback.POST_ENTITY_REMOVE (67) postEntityRemove = (entity) => { const tear = entity.ToTear(); if (tear === undefined) { return; } const ptrHash = GetPtrHash(tear); if (v.room.firedSet.has(ptrHash)) { v.room.firedSet.add(ptrHash); this.fire(tear); } }; } exports.PostTearKill = PostTearKill;