UNPKG

isaacscript-common

Version:

Helper functions and features for IsaacScript mods.

224 lines (223 loc) • 10.3 kB
"use strict"; /* eslint sort-exports/sort-exports: [ "warn", { sortDir: "asc", }, ] */ Object.defineProperty(exports, "__esModule", { value: true }); exports.shouldFireAmbush = shouldFireAmbush; exports.shouldFireBomb = shouldFireBomb; exports.shouldFireBoolean = shouldFireBoolean; exports.shouldFireCollectibleType = shouldFireCollectibleType; exports.shouldFireDoor = shouldFireDoor; exports.shouldFireEffect = shouldFireEffect; exports.shouldFireEntity = shouldFireEntity; exports.shouldFireFamiliar = shouldFireFamiliar; exports.shouldFireGridEntity = shouldFireGridEntity; exports.shouldFireGridEntityCustom = shouldFireGridEntityCustom; exports.shouldFireItemPickup = shouldFireItemPickup; exports.shouldFireKnife = shouldFireKnife; exports.shouldFireLaser = shouldFireLaser; exports.shouldFireLevel = shouldFireLevel; exports.shouldFireNPC = shouldFireNPC; exports.shouldFirePickup = shouldFirePickup; exports.shouldFirePit = shouldFirePit; exports.shouldFirePlayer = shouldFirePlayer; exports.shouldFirePoop = shouldFirePoop; exports.shouldFirePressurePlate = shouldFirePressurePlate; exports.shouldFireProjectile = shouldFireProjectile; exports.shouldFireRock = shouldFireRock; exports.shouldFireRoom = shouldFireRoom; exports.shouldFireSlot = shouldFireSlot; exports.shouldFireSpikes = shouldFireSpikes; exports.shouldFireTNT = shouldFireTNT; exports.shouldFireTear = shouldFireTear; exports.shouldFireTrinketType = shouldFireTrinketType; function shouldFireAmbush(fireArgs, optionalArgs) { const [ambushType] = fireArgs; const [callbackAmbushType] = optionalArgs; return callbackAmbushType === undefined || callbackAmbushType === ambushType; } function shouldFireBomb(fireArgs, optionalArgs) { const [bomb] = fireArgs; const [callbackBombVariant, callbackSubType] = optionalArgs; return ((callbackBombVariant === undefined || callbackBombVariant === bomb.Variant) && (callbackSubType === undefined || callbackSubType === bomb.SubType)); } function shouldFireBoolean(fireArgs, optionalArgs) { const [fireArg] = fireArgs; const [optionalArg] = optionalArgs; return optionalArg === undefined || optionalArg === fireArg; } function shouldFireCollectibleType(fireArgs, optionalArgs) { const [_player, collectibleType] = fireArgs; const [callbackCollectibleType] = optionalArgs; return (callbackCollectibleType === undefined || callbackCollectibleType === collectibleType); } function shouldFireDoor(fireArgs, optionalArgs) { const [door] = fireArgs; const [callbackDoorVariant] = optionalArgs; const doorVariant = door.GetVariant(); return (callbackDoorVariant === undefined || callbackDoorVariant === doorVariant); } function shouldFireEffect(fireArgs, optionalArgs) { const [effect] = fireArgs; const [callbackEffectVariant, callbackSubType] = optionalArgs; return ((callbackEffectVariant === undefined || callbackEffectVariant === effect.Variant) && (callbackSubType === undefined || callbackSubType === effect.SubType)); } function shouldFireEntity(fireArgs, optionalArgs) { const [entity] = fireArgs; const [callbackEntityType, callbackVariant, callbackSubType] = optionalArgs; return ((callbackEntityType === undefined || callbackEntityType === entity.Type) && (callbackVariant === undefined || callbackVariant === entity.Variant) && (callbackSubType === undefined || callbackSubType === entity.SubType)); } function shouldFireFamiliar(fireArgs, optionalArgs) { const [familiar] = fireArgs; const [callbackFamiliarVariant, callbackSubType] = optionalArgs; return ((callbackFamiliarVariant === undefined || callbackFamiliarVariant === familiar.Variant) && (callbackSubType === undefined || callbackSubType === familiar.SubType)); } function shouldFireGridEntity(fireArgs, optionalArgs) { const [gridEntity] = fireArgs; const [callbackGridEntityType, callbackVariant] = optionalArgs; const gridEntityType = gridEntity.GetType(); const variant = gridEntity.GetVariant(); return ((callbackGridEntityType === undefined || callbackGridEntityType === gridEntityType) && (callbackVariant === undefined || callbackVariant === variant)); } function shouldFireGridEntityCustom(fireArgs, optionalArgs) { const [_gridEntity, gridEntityTypeCustom] = fireArgs; const [callbackGridEntityTypeCustom] = optionalArgs; return (callbackGridEntityTypeCustom === undefined || callbackGridEntityTypeCustom === gridEntityTypeCustom); } function shouldFireItemPickup(fireArgs, optionalArgs) { const [_player, pickingUpItem] = fireArgs; const [callbackItemType, callbackSubtype] = optionalArgs; return ((callbackItemType === undefined || callbackItemType === pickingUpItem.itemType) && (callbackSubtype === undefined // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison || callbackSubtype === pickingUpItem.subType)); } function shouldFireKnife(fireArgs, optionalArgs) { const [knife] = fireArgs; const [callbackKnifeVariant, callbackSubType] = optionalArgs; return ((callbackKnifeVariant === undefined || callbackKnifeVariant === knife.Variant) && (callbackSubType === undefined || callbackSubType === knife.SubType)); } function shouldFireLaser(fireArgs, optionalArgs) { const [laser] = fireArgs; const [callbackLaserVariant, callbackSubType] = optionalArgs; return ((callbackLaserVariant === undefined || callbackLaserVariant === laser.Variant) && (callbackSubType === undefined || callbackSubType === laser.SubType)); } function shouldFireLevel(fireArgs, optionalArgs) { const [stage, stageType] = fireArgs; const [callbackStage, callbackStageType] = optionalArgs; return ((callbackStage === undefined || callbackStage === stage) && (callbackStageType === undefined || callbackStageType === stageType)); } function shouldFireNPC(fireArgs, optionalArgs) { const [npc] = fireArgs; const [callbackEntityType, callbackVariant, callbackSubType] = optionalArgs; return ((callbackEntityType === undefined || callbackEntityType === npc.Type) && (callbackVariant === undefined || callbackVariant === npc.Variant) && (callbackSubType === undefined || callbackSubType === npc.SubType)); } function shouldFirePickup(fireArgs, optionalArgs) { const [pickup] = fireArgs; const [callbackPickupVariant, callbackPickupSubType] = optionalArgs; return ((callbackPickupVariant === undefined || callbackPickupVariant === pickup.Variant) && (callbackPickupSubType === undefined || callbackPickupSubType === pickup.SubType)); } function shouldFirePit(fireArgs, optionalArgs) { const [pit] = fireArgs; const [callbackPitVariant] = optionalArgs; const pitVariant = pit.GetVariant(); return callbackPitVariant === undefined || callbackPitVariant === pitVariant; } function shouldFirePlayer(fireArgs, optionalArgs) { const [player] = fireArgs; const [callbackPlayerVariant, callbackCharacter] = optionalArgs; const character = player.GetPlayerType(); return ((callbackPlayerVariant === undefined || callbackPlayerVariant === player.Variant) && (callbackCharacter === undefined || callbackCharacter === character)); } function shouldFirePoop(fireArgs, optionalArgs) { const [poop] = fireArgs; const [callbackPoopGridEntityVariant] = optionalArgs; const poopGridEntityVariant = poop.GetVariant(); return (callbackPoopGridEntityVariant === undefined || callbackPoopGridEntityVariant === poopGridEntityVariant); } function shouldFirePressurePlate(fireArgs, optionalArgs) { const [pressurePlate] = fireArgs; const [callbackPressurePlateVariant] = optionalArgs; const pressurePlateVariant = pressurePlate.GetVariant(); return (callbackPressurePlateVariant === undefined || callbackPressurePlateVariant === pressurePlateVariant); } function shouldFireProjectile(fireArgs, optionalArgs) { const [projectile] = fireArgs; const [callbackProjectileVariant, callbackSubType] = optionalArgs; return ((callbackProjectileVariant === undefined || callbackProjectileVariant === projectile.Variant) && (callbackSubType === undefined || callbackSubType === projectile.SubType)); } function shouldFireRock(fireArgs, optionalArgs) { const [rock] = fireArgs; const [callbackGridEntity, callbackVariant] = optionalArgs; const gridEntityType = rock.GetType(); const variant = rock.GetVariant(); return ((callbackGridEntity === undefined || callbackGridEntity === gridEntityType) && (callbackVariant === undefined || callbackVariant === variant)); } function shouldFireRoom(fireArgs, optionalArgs) { const [roomType] = fireArgs; const [callbackRoomType] = optionalArgs; return callbackRoomType === undefined || callbackRoomType === roomType; } function shouldFireSlot(fireArgs, optionalArgs) { const [slot] = fireArgs; const [callbackSlotVariant, callbackSubType] = optionalArgs; return ((callbackSlotVariant === undefined || callbackSlotVariant === slot.Variant) && (callbackSubType === undefined || callbackSubType === slot.SubType)); } function shouldFireSpikes(fireArgs, optionalArgs) { const [spikes] = fireArgs; const [callbackVariant] = optionalArgs; const variant = spikes.GetVariant(); return callbackVariant === undefined || callbackVariant === variant; } function shouldFireTNT(fireArgs, optionalArgs) { const [tnt] = fireArgs; const [callbackVariant] = optionalArgs; const variant = tnt.GetVariant(); return callbackVariant === undefined || callbackVariant === variant; } function shouldFireTear(fireArgs, optionalArgs) { const [tear] = fireArgs; const [callbackTearVariant, callbackSubType] = optionalArgs; return ((callbackTearVariant === undefined || callbackTearVariant === tear.Variant) && (callbackSubType === undefined || callbackSubType === tear.SubType)); } function shouldFireTrinketType(fireArgs, optionalArgs) { const [_player, trinketType] = fireArgs; const [callbackTrinketType] = optionalArgs; return (callbackTrinketType === undefined || callbackTrinketType === trinketType); }