UNPKG

isaacscript-common

Version:

Helper functions and features for IsaacScript mods.

54 lines (53 loc) 1.86 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PostBoneSwing = void 0; const isaac_typescript_definitions_1 = require("isaac-typescript-definitions"); const ReadonlySet_1 = require("../../types/ReadonlySet"); const CustomCallback_1 = require("../private/CustomCallback"); const BONE_SWING_ANIMATIONS = new ReadonlySet_1.ReadonlySet([ "Swing", "Swing2", "Spin", ]); const v = { room: { boneClubAnimations: new Map(), }, }; class PostBoneSwing extends CustomCallback_1.CustomCallback { v = v; constructor() { super(); this.callbacksUsed = [ // 52 [isaac_typescript_definitions_1.ModCallback.POST_KNIFE_RENDER, this.postKnifeRender], ]; } // ModCallback.POST_KNIFE_RENDER (52) postKnifeRender = (knife) => { // The tertiary argument of the `POST_KNIFE_RENDER` callback takes sub-types instead of knife // variants. if (knife.Variant === isaac_typescript_definitions_1.KnifeVariant.BONE_CLUB) { this.postKnifeRenderBoneClub(knife); } }; // ModCallback.POST_KNIFE_RENDER (52) // KnifeVariant.BONE_CLUB (1) postKnifeRenderBoneClub(knife) { const sprite = knife.GetSprite(); const animation = sprite.GetAnimation(); const ptrHash = GetPtrHash(knife); const animationOnLastFrame = v.room.boneClubAnimations.get(ptrHash); v.room.boneClubAnimations.set(ptrHash, animation); if (animationOnLastFrame !== undefined && animation !== animationOnLastFrame) { this.boneClubAnimationChanged(knife, animation); } } boneClubAnimationChanged(knife, animation) { if (BONE_SWING_ANIMATIONS.has(animation)) { this.fire(knife); } } } exports.PostBoneSwing = PostBoneSwing;