isaacscript-common
Version:
Helper functions and features for IsaacScript mods.
53 lines (52 loc) • 1.88 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PostProjectileKill = 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 PostProjectileKill extends CustomCallback_1.CustomCallback {
v = v;
constructor() {
super();
this.callbacksUsed = [
// 44
[isaac_typescript_definitions_1.ModCallback.POST_PROJECTILE_UPDATE, this.postProjectileUpdate],
// 46
[isaac_typescript_definitions_1.ModCallback.PRE_PROJECTILE_COLLISION, this.preProjectileCollision],
// 67
[isaac_typescript_definitions_1.ModCallback.POST_ENTITY_REMOVE, this.postEntityRemove],
];
}
shouldFire = shouldFire_1.shouldFireProjectile;
// ModCallback.POST_PROJECTILE_UPDATE (44)
postProjectileUpdate = (projectile) => {
const ptrHash = GetPtrHash(projectile);
if (projectile.CollidesWithGrid() || projectile.IsDead()) {
v.room.firedSet.add(ptrHash);
}
};
// ModCallback.PRE_PROJECTILE_COLLISION (46)
preProjectileCollision = (projectile) => {
const ptrHash = GetPtrHash(projectile);
v.room.firedSet.add(ptrHash);
return undefined;
};
// ModCallback.POST_ENTITY_REMOVE (67)
postEntityRemove = (entity) => {
const projectile = entity.ToProjectile();
if (projectile === undefined) {
return;
}
const ptrHash = GetPtrHash(projectile);
if (v.room.firedSet.has(ptrHash)) {
v.room.firedSet.add(ptrHash);
this.fire(projectile);
}
};
}
exports.PostProjectileKill = PostProjectileKill;