isaacscript-common 84.0.1 → 84.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/arrays/cachedEnumValues.js +33 -0
- package/dist/callbackClasses.js +289 -0
- package/dist/callbacks.js +181 -0
- package/dist/classes/DefaultMap.js +171 -0
- package/dist/classes/ModFeature.js +244 -0
- package/dist/classes/ModUpgraded.js +324 -0
- package/dist/classes/callbacks/EntityTakeDmgFilter.js +19 -0
- package/dist/classes/callbacks/EntityTakeDmgPlayer.js +29 -0
- package/dist/classes/callbacks/InputActionFilter.js +24 -0
- package/dist/classes/callbacks/InputActionPlayer.js +37 -0
- package/dist/classes/callbacks/PostAmbushFinished.js +40 -0
- package/dist/classes/callbacks/PostAmbushStarted.js +40 -0
- package/dist/classes/callbacks/PostBombExploded.js +24 -0
- package/dist/classes/callbacks/PostBombInitFilter.js +21 -0
- package/dist/classes/callbacks/PostBombInitLate.js +31 -0
- package/dist/classes/callbacks/PostBombRenderFilter.js +21 -0
- package/dist/classes/callbacks/PostBombUpdateFilter.js +21 -0
- package/dist/classes/callbacks/PostBoneSwing.js +53 -0
- package/dist/classes/callbacks/PostCollectibleEmpty.js +50 -0
- package/dist/classes/callbacks/PostCursedTeleport.js +119 -0
- package/dist/classes/callbacks/PostCustomRevive.js +17 -0
- package/dist/classes/callbacks/PostDiceRoomActivated.js +50 -0
- package/dist/classes/callbacks/PostDoorRender.js +24 -0
- package/dist/classes/callbacks/PostDoorUpdate.js +24 -0
- package/dist/classes/callbacks/PostEffectInitFilter.js +21 -0
- package/dist/classes/callbacks/PostEffectInitLate.js +31 -0
- package/dist/classes/callbacks/PostEffectRenderFilter.js +21 -0
- package/dist/classes/callbacks/PostEffectStateChanged.js +34 -0
- package/dist/classes/callbacks/PostEffectUpdateFilter.js +21 -0
- package/dist/classes/callbacks/PostEntityKillFilter.js +21 -0
- package/dist/classes/callbacks/PostEsauJr.js +12 -0
- package/dist/classes/callbacks/PostFamiliarInitFilter.js +21 -0
- package/dist/classes/callbacks/PostFamiliarInitLate.js +31 -0
- package/dist/classes/callbacks/PostFamiliarRenderFilter.js +21 -0
- package/dist/classes/callbacks/PostFamiliarStateChanged.js +34 -0
- package/dist/classes/callbacks/PostFamiliarUpdateFilter.js +21 -0
- package/dist/classes/callbacks/PostFirstEsauJr.js +12 -0
- package/dist/classes/callbacks/PostFirstFlip.js +12 -0
- package/dist/classes/callbacks/PostFlip.js +12 -0
- package/dist/classes/callbacks/PostGameEndFilter.js +21 -0
- package/dist/classes/callbacks/PostGameStartedReordered.js +14 -0
- package/dist/classes/callbacks/PostGameStartedReorderedLast.js +14 -0
- package/dist/classes/callbacks/PostGreedModeWave.js +35 -0
- package/dist/classes/callbacks/PostGridEntityBroken.js +14 -0
- package/dist/classes/callbacks/PostGridEntityCollision.js +28 -0
- package/dist/classes/callbacks/PostGridEntityCustomBroken.js +14 -0
- package/dist/classes/callbacks/PostGridEntityCustomCollision.js +24 -0
- package/dist/classes/callbacks/PostGridEntityCustomInit.js +14 -0
- package/dist/classes/callbacks/PostGridEntityCustomRemove.js +18 -0
- package/dist/classes/callbacks/PostGridEntityCustomRender.js +14 -0
- package/dist/classes/callbacks/PostGridEntityCustomStateChanged.js +14 -0
- package/dist/classes/callbacks/PostGridEntityCustomUpdate.js +14 -0
- package/dist/classes/callbacks/PostGridEntityInit.js +14 -0
- package/dist/classes/callbacks/PostGridEntityRemove.js +19 -0
- package/dist/classes/callbacks/PostGridEntityRender.js +14 -0
- package/dist/classes/callbacks/PostGridEntityStateChanged.js +14 -0
- package/dist/classes/callbacks/PostGridEntityUpdate.js +14 -0
- package/dist/classes/callbacks/PostHolyMantleRemoved.js +43 -0
- package/dist/classes/callbacks/PostItemDischarge.js +122 -0
- package/dist/classes/callbacks/PostItemPickup.js +14 -0
- package/dist/classes/callbacks/PostKeyboardChanged.js +46 -0
- package/dist/classes/callbacks/PostKnifeInitFilter.js +21 -0
- package/dist/classes/callbacks/PostKnifeInitLate.js +31 -0
- package/dist/classes/callbacks/PostKnifeRenderFilter.js +21 -0
- package/dist/classes/callbacks/PostKnifeUpdateFilter.js +21 -0
- package/dist/classes/callbacks/PostLaserInitFilter.js +21 -0
- package/dist/classes/callbacks/PostLaserInitLate.js +31 -0
- package/dist/classes/callbacks/PostLaserRenderFilter.js +21 -0
- package/dist/classes/callbacks/PostLaserUpdateFilter.js +21 -0
- package/dist/classes/callbacks/PostNPCDeathFilter.js +21 -0
- package/dist/classes/callbacks/PostNPCInitFilter.js +21 -0
- package/dist/classes/callbacks/PostNPCInitLate.js +31 -0
- package/dist/classes/callbacks/PostNPCRenderFilter.js +21 -0
- package/dist/classes/callbacks/PostNPCStateChanged.js +34 -0
- package/dist/classes/callbacks/PostNPCUpdateFilter.js +21 -0
- package/dist/classes/callbacks/PostNewLevelReordered.js +14 -0
- package/dist/classes/callbacks/PostNewRoomEarly.js +74 -0
- package/dist/classes/callbacks/PostNewRoomReordered.js +14 -0
- package/dist/classes/callbacks/PostPEffectUpdateReordered.js +14 -0
- package/dist/classes/callbacks/PostPickupChanged.js +14 -0
- package/dist/classes/callbacks/PostPickupCollect.js +38 -0
- package/dist/classes/callbacks/PostPickupInitFilter.js +21 -0
- package/dist/classes/callbacks/PostPickupInitFirst.js +33 -0
- package/dist/classes/callbacks/PostPickupInitLate.js +31 -0
- package/dist/classes/callbacks/PostPickupRenderFilter.js +21 -0
- package/dist/classes/callbacks/PostPickupSelectionFilter.js +29 -0
- package/dist/classes/callbacks/PostPickupStateChanged.js +34 -0
- package/dist/classes/callbacks/PostPickupUpdateFilter.js +21 -0
- package/dist/classes/callbacks/PostPitRender.js +24 -0
- package/dist/classes/callbacks/PostPitUpdate.js +24 -0
- package/dist/classes/callbacks/PostPlayerChangeHealth.js +47 -0
- package/dist/classes/callbacks/PostPlayerChangeStat.js +79 -0
- package/dist/classes/callbacks/PostPlayerChangeType.js +36 -0
- package/dist/classes/callbacks/PostPlayerCollectibleAdded.js +14 -0
- package/dist/classes/callbacks/PostPlayerCollectibleRemoved.js +14 -0
- package/dist/classes/callbacks/PostPlayerFatalDamage.js +83 -0
- package/dist/classes/callbacks/PostPlayerInitFirst.js +41 -0
- package/dist/classes/callbacks/PostPlayerInitLate.js +33 -0
- package/dist/classes/callbacks/PostPlayerRenderReordered.js +14 -0
- package/dist/classes/callbacks/PostPlayerUpdateReordered.js +14 -0
- package/dist/classes/callbacks/PostPoopRender.js +24 -0
- package/dist/classes/callbacks/PostPoopUpdate.js +24 -0
- package/dist/classes/callbacks/PostPressurePlateRender.js +24 -0
- package/dist/classes/callbacks/PostPressurePlateUpdate.js +24 -0
- package/dist/classes/callbacks/PostProjectileInitFilter.js +21 -0
- package/dist/classes/callbacks/PostProjectileInitLate.js +31 -0
- package/dist/classes/callbacks/PostProjectileKill.js +52 -0
- package/dist/classes/callbacks/PostProjectileRenderFilter.js +21 -0
- package/dist/classes/callbacks/PostProjectileUpdateFilter.js +21 -0
- package/dist/classes/callbacks/PostPurchase.js +90 -0
- package/dist/classes/callbacks/PostRockRender.js +24 -0
- package/dist/classes/callbacks/PostRockUpdate.js +24 -0
- package/dist/classes/callbacks/PostRoomClearChanged.js +46 -0
- package/dist/classes/callbacks/PostSacrifice.js +36 -0
- package/dist/classes/callbacks/PostSlotAnimationChanged.js +14 -0
- package/dist/classes/callbacks/PostSlotCollision.js +25 -0
- package/dist/classes/callbacks/PostSlotDestroyed.js +14 -0
- package/dist/classes/callbacks/PostSlotInit.js +14 -0
- package/dist/classes/callbacks/PostSlotRender.js +14 -0
- package/dist/classes/callbacks/PostSlotUpdate.js +14 -0
- package/dist/classes/callbacks/PostSpikesRender.js +24 -0
- package/dist/classes/callbacks/PostSpikesUpdate.js +24 -0
- package/dist/classes/callbacks/PostTNTRender.js +24 -0
- package/dist/classes/callbacks/PostTNTUpdate.js +24 -0
- package/dist/classes/callbacks/PostTearInitFilter.js +21 -0
- package/dist/classes/callbacks/PostTearInitLate.js +31 -0
- package/dist/classes/callbacks/PostTearInitVeryLate.js +35 -0
- package/dist/classes/callbacks/PostTearKill.js +52 -0
- package/dist/classes/callbacks/PostTearRenderFilter.js +21 -0
- package/dist/classes/callbacks/PostTearUpdateFilter.js +21 -0
- package/dist/classes/callbacks/PostTransformation.js +47 -0
- package/dist/classes/callbacks/PostTrinketBreak.js +70 -0
- package/dist/classes/callbacks/PostUsePillFilter.js +76 -0
- package/dist/classes/callbacks/PreBerserkDeath.js +41 -0
- package/dist/classes/callbacks/PreBombCollisionFilter.js +19 -0
- package/dist/classes/callbacks/PreCustomRevive.js +14 -0
- package/dist/classes/callbacks/PreEntitySpawnFilter.js +24 -0
- package/dist/classes/callbacks/PreFamiliarCollisionFilter.js +19 -0
- package/dist/classes/callbacks/PreGetPedestal.js +46 -0
- package/dist/classes/callbacks/PreItemPickup.js +14 -0
- package/dist/classes/callbacks/PreKnifeCollisionFilter.js +19 -0
- package/dist/classes/callbacks/PreNPCCollisionFilter.js +19 -0
- package/dist/classes/callbacks/PreNPCUpdateFilter.js +19 -0
- package/dist/classes/callbacks/PreNewLevel.js +51 -0
- package/dist/classes/callbacks/PreProjectileCollisionFilter.js +19 -0
- package/dist/classes/callbacks/PreRoomEntitySpawnFilter.js +26 -0
- package/dist/classes/callbacks/PreTearCollisionFilter.js +19 -0
- package/dist/classes/features/callbackLogic/CustomGridEntities.js +359 -0
- package/dist/classes/features/callbackLogic/CustomRevive.js +170 -0
- package/dist/classes/features/callbackLogic/EsauJrDetection.js +70 -0
- package/dist/classes/features/callbackLogic/FlipDetection.js +61 -0
- package/dist/classes/features/callbackLogic/GameReorderedCallbacks.js +220 -0
- package/dist/classes/features/callbackLogic/GridEntityCollisionDetection.js +62 -0
- package/dist/classes/features/callbackLogic/GridEntityRenderDetection.js +35 -0
- package/dist/classes/features/callbackLogic/GridEntityUpdateDetection.js +147 -0
- package/dist/classes/features/callbackLogic/ItemPickupDetection.js +68 -0
- package/dist/classes/features/callbackLogic/PickupChangeDetection.js +43 -0
- package/dist/classes/features/callbackLogic/PlayerCollectibleDetection.js +193 -0
- package/dist/classes/features/callbackLogic/PlayerReorderedCallbacks.js +109 -0
- package/dist/classes/features/callbackLogic/SlotDestroyedDetection.js +95 -0
- package/dist/classes/features/callbackLogic/SlotRenderDetection.js +48 -0
- package/dist/classes/features/callbackLogic/SlotUpdateDetection.js +52 -0
- package/dist/classes/features/other/CharacterHealthConversion.js +112 -0
- package/dist/classes/features/other/CharacterStats.js +68 -0
- package/dist/classes/features/other/CollectibleItemPoolType.js +75 -0
- package/dist/classes/features/other/CustomHotkeys.js +144 -0
- package/dist/classes/features/other/CustomItemPools.js +128 -0
- package/dist/classes/features/other/CustomPickups.js +118 -0
- package/dist/classes/features/other/CustomStages.js +471 -0
- package/dist/classes/features/other/CustomTrapdoors.js +596 -0
- package/dist/classes/features/other/DebugDisplay.js +699 -0
- package/dist/classes/features/other/DeployJSONRoom.js +301 -0
- package/dist/classes/features/other/DisableAllSound.js +90 -0
- package/dist/classes/features/other/DisableInputs.js +249 -0
- package/dist/classes/features/other/EdenStartingStatsHealth.js +197 -0
- package/dist/classes/features/other/ExtraConsoleCommands.js +292 -0
- package/dist/classes/features/other/FadeInRemover.js +67 -0
- package/dist/classes/features/other/FastReset.js +88 -0
- package/dist/classes/features/other/FlyingDetection.js +64 -0
- package/dist/classes/features/other/ForgottenSwitch.js +43 -0
- package/dist/classes/features/other/ItemPoolDetection.js +187 -0
- package/dist/classes/features/other/ModdedElementDetection.js +399 -0
- package/dist/classes/features/other/ModdedElementSets.js +1251 -0
- package/dist/classes/features/other/NoSirenSteal.js +88 -0
- package/dist/classes/features/other/Pause.js +197 -0
- package/dist/classes/features/other/PersistentEntities.js +168 -0
- package/dist/classes/features/other/PickupIndexCreation.js +229 -0
- package/dist/classes/features/other/PlayerCollectibleTracking.js +102 -0
- package/dist/classes/features/other/PonyDetection.js +86 -0
- package/dist/classes/features/other/PressInput.js +71 -0
- package/dist/classes/features/other/PreventChildEntities.js +60 -0
- package/dist/classes/features/other/PreventGridEntityRespawn.js +159 -0
- package/dist/classes/features/other/RerunDetection.js +69 -0
- package/dist/classes/features/other/RoomClearFrame.js +94 -0
- package/dist/classes/features/other/RoomHistory.js +196 -0
- package/dist/classes/features/other/RunInNFrames.js +323 -0
- package/dist/classes/features/other/RunNextRoom.js +53 -0
- package/dist/classes/features/other/RunNextRun.js +60 -0
- package/dist/classes/features/other/SaveDataManager.js +383 -0
- package/dist/classes/features/other/SpawnRockAltRewards.js +469 -0
- package/dist/classes/features/other/StageHistory.js +244 -0
- package/dist/classes/features/other/StartAmbush.js +62 -0
- package/dist/classes/features/other/TaintedLazarusPlayers.js +115 -0
- package/dist/classes/features/other/UnlockAchievementsDetection.js +60 -0
- package/dist/classes/features/other/customStages/backdrop.js +195 -0
- package/dist/classes/features/other/customStages/constants.js +19 -0
- package/dist/classes/features/other/customStages/gridEntities.js +177 -0
- package/dist/classes/features/other/customStages/shadows.js +67 -0
- package/dist/classes/features/other/customStages/streakText.js +222 -0
- package/dist/classes/features/other/customStages/utils.js +65 -0
- package/dist/classes/features/other/customStages/v.js +27 -0
- package/dist/classes/features/other/customStages/versusScreen.js +227 -0
- package/dist/classes/features/other/debugDisplay/DebugDisplayBomb.js +23 -0
- package/dist/classes/features/other/debugDisplay/DebugDisplayDoor.js +22 -0
- package/dist/classes/features/other/debugDisplay/DebugDisplayEffect.js +23 -0
- package/dist/classes/features/other/debugDisplay/DebugDisplayFamiliar.js +23 -0
- package/dist/classes/features/other/debugDisplay/DebugDisplayKnife.js +23 -0
- package/dist/classes/features/other/debugDisplay/DebugDisplayLaser.js +23 -0
- package/dist/classes/features/other/debugDisplay/DebugDisplayNPC.js +23 -0
- package/dist/classes/features/other/debugDisplay/DebugDisplayPickup.js +23 -0
- package/dist/classes/features/other/debugDisplay/DebugDisplayPit.js +22 -0
- package/dist/classes/features/other/debugDisplay/DebugDisplayPlayer.js +25 -0
- package/dist/classes/features/other/debugDisplay/DebugDisplayPoop.js +22 -0
- package/dist/classes/features/other/debugDisplay/DebugDisplayPressurePlate.js +25 -0
- package/dist/classes/features/other/debugDisplay/DebugDisplayProjectile.js +23 -0
- package/dist/classes/features/other/debugDisplay/DebugDisplayRock.js +22 -0
- package/dist/classes/features/other/debugDisplay/DebugDisplaySlot.js +22 -0
- package/dist/classes/features/other/debugDisplay/DebugDisplaySpikes.js +22 -0
- package/dist/classes/features/other/debugDisplay/DebugDisplayTNT.js +22 -0
- package/dist/classes/features/other/debugDisplay/DebugDisplayTear.js +23 -0
- package/dist/classes/features/other/debugDisplay/utils.js +13 -0
- package/dist/classes/features/other/extraConsoleCommands/commands.js +1598 -0
- package/dist/classes/features/other/extraConsoleCommands/subroutines.js +135 -0
- package/dist/classes/features/other/extraConsoleCommands/v.js +30 -0
- package/dist/classes/features/other/saveDataManager/constants.js +4 -0
- package/dist/classes/features/other/saveDataManager/glowingHourGlass.js +106 -0
- package/dist/classes/features/other/saveDataManager/loadFromDisk.js +69 -0
- package/dist/classes/features/other/saveDataManager/restoreDefaults.js +69 -0
- package/dist/classes/features/other/saveDataManager/saveToDisk.js +46 -0
- package/dist/classes/private/CustomCallback.js +59 -0
- package/dist/classes/private/Feature.js +39 -0
- package/dist/core/cachedClasses.js +61 -0
- package/dist/core/constants.js +289 -0
- package/dist/core/constantsFirstLast.js +98 -0
- package/dist/core/constantsVanilla.js +131 -0
- package/dist/core/upgradeMod.js +71 -0
- package/dist/customStageMetadata.json +1 -0
- package/dist/data/itempools.json +16625 -0
- package/dist/decorators.js +21 -0
- package/dist/enums/AmbushType.js +9 -0
- package/dist/enums/CornerType.js +11 -0
- package/dist/enums/HealthType.js +20 -0
- package/dist/enums/ISCFeature.js +65 -0
- package/dist/enums/LadderSubTypeCustom.js +20 -0
- package/dist/enums/ModCallbackCustom.js +2477 -0
- package/dist/enums/MysteriousPaperEffect.js +16 -0
- package/dist/enums/PlayerStat.js +37 -0
- package/dist/enums/PocketItemType.js +13 -0
- package/dist/enums/RockAltType.js +23 -0
- package/dist/enums/SaveDataKey.js +14 -0
- package/dist/enums/SerializationType.js +10 -0
- package/dist/enums/SlotDestructionType.js +22 -0
- package/dist/enums/private/GridEntityTypeCustom.js +10 -0
- package/dist/enums/private/SerializationBrand.js +42 -0
- package/dist/enums/private/StageTravelState.js +13 -0
- package/dist/enums/private/TrapdoorAnimation.js +9 -0
- package/dist/enums/private/UIStreakAnimation.js +10 -0
- package/dist/features.js +150 -0
- package/dist/functions/ambush.js +26 -0
- package/dist/functions/array.js +586 -0
- package/dist/functions/arrayLua.js +81 -0
- package/dist/functions/benchmark.js +36 -0
- package/dist/functions/bitSet128.js +64 -0
- package/dist/functions/bitwise.js +82 -0
- package/dist/functions/bombs.js +14 -0
- package/dist/functions/bosses.js +238 -0
- package/dist/functions/cards.js +164 -0
- package/dist/functions/challenges.js +117 -0
- package/dist/functions/characters.js +182 -0
- package/dist/functions/charge.js +251 -0
- package/dist/functions/chargeBar.js +54 -0
- package/dist/functions/collectibleTag.js +24 -0
- package/dist/functions/collectibles.js +581 -0
- package/dist/functions/color.js +88 -0
- package/dist/functions/console.js +18 -0
- package/dist/functions/curses.js +37 -0
- package/dist/functions/debugFunctions.js +108 -0
- package/dist/functions/decorators.js +113 -0
- package/dist/functions/deepCopy.js +406 -0
- package/dist/functions/deepCopyTests.js +361 -0
- package/dist/functions/dimensions.js +30 -0
- package/dist/functions/direction.js +78 -0
- package/dist/functions/doors.js +524 -0
- package/dist/functions/easing.js +327 -0
- package/dist/functions/effects.js +14 -0
- package/dist/functions/emptyRoom.js +79 -0
- package/dist/functions/entities.js +529 -0
- package/dist/functions/entitiesSpecific.js +582 -0
- package/dist/functions/entityTypes.js +9 -0
- package/dist/functions/enums.js +244 -0
- package/dist/functions/external.js +59 -0
- package/dist/functions/familiars.js +136 -0
- package/dist/functions/flag.js +146 -0
- package/dist/functions/frames.js +166 -0
- package/dist/functions/globals.js +291 -0
- package/dist/functions/gridEntities.js +990 -0
- package/dist/functions/gridEntitiesSpecific.js +456 -0
- package/dist/functions/gridIndex.js +35 -0
- package/dist/functions/hash.js +75 -0
- package/dist/functions/hex.js +57 -0
- package/dist/functions/input.js +185 -0
- package/dist/functions/isaacAPIClass.js +157 -0
- package/dist/functions/itemPool.js +118 -0
- package/dist/functions/jsonHelpers.js +73 -0
- package/dist/functions/jsonRoom.js +184 -0
- package/dist/functions/kColor.js +89 -0
- package/dist/functions/language.js +16 -0
- package/dist/functions/level.js +66 -0
- package/dist/functions/levelGrid.js +497 -0
- package/dist/functions/log.js +86 -0
- package/dist/functions/logEntities.js +308 -0
- package/dist/functions/logMisc.js +510 -0
- package/dist/functions/map.js +121 -0
- package/dist/functions/math.js +149 -0
- package/dist/functions/merge.js +159 -0
- package/dist/functions/mergeTests.js +313 -0
- package/dist/functions/minimap.js +204 -0
- package/dist/functions/modFeatures.js +39 -0
- package/dist/functions/newArray.js +30 -0
- package/dist/functions/nextStage.js +169 -0
- package/dist/functions/npcDataStructures.js +146 -0
- package/dist/functions/npcs.js +132 -0
- package/dist/functions/pickupVariants.js +63 -0
- package/dist/functions/pickups.js +168 -0
- package/dist/functions/pickupsSpecific.js +376 -0
- package/dist/functions/pills.js +200 -0
- package/dist/functions/playerCenter.js +53 -0
- package/dist/functions/playerCollectibles.js +300 -0
- package/dist/functions/playerDataStructures.js +145 -0
- package/dist/functions/playerEffects.js +63 -0
- package/dist/functions/playerHealth.js +604 -0
- package/dist/functions/playerIndex.js +186 -0
- package/dist/functions/playerTrinkets.js +149 -0
- package/dist/functions/players.js +471 -0
- package/dist/functions/pocketItems.js +165 -0
- package/dist/functions/positionVelocity.js +158 -0
- package/dist/functions/pressurePlate.js +26 -0
- package/dist/functions/projectiles.js +57 -0
- package/dist/functions/random.js +90 -0
- package/dist/functions/readOnly.js +33 -0
- package/dist/functions/render.js +36 -0
- package/dist/functions/revive.js +151 -0
- package/dist/functions/rng.js +140 -0
- package/dist/functions/rockAlt.js +50 -0
- package/dist/functions/roomData.js +155 -0
- package/dist/functions/roomGrid.js +97 -0
- package/dist/functions/roomShape.js +143 -0
- package/dist/functions/roomShapeWalls.js +187 -0
- package/dist/functions/roomTransition.js +43 -0
- package/dist/functions/rooms.js +782 -0
- package/dist/functions/run.js +121 -0
- package/dist/functions/seeds.js +22 -0
- package/dist/functions/serialization.js +98 -0
- package/dist/functions/set.js +215 -0
- package/dist/functions/slots.js +41 -0
- package/dist/functions/sort.js +158 -0
- package/dist/functions/sound.js +45 -0
- package/dist/functions/spawnCollectible.js +112 -0
- package/dist/functions/sprites.js +130 -0
- package/dist/functions/stage.js +540 -0
- package/dist/functions/stats.js +104 -0
- package/dist/functions/storyBosses.js +63 -0
- package/dist/functions/string.js +194 -0
- package/dist/functions/table.js +162 -0
- package/dist/functions/tears.js +128 -0
- package/dist/functions/transformations.js +89 -0
- package/dist/functions/trinketGive.js +145 -0
- package/dist/functions/trinkets.js +213 -0
- package/dist/functions/tstlClass.js +97 -0
- package/dist/functions/types.js +225 -0
- package/dist/functions/ui.js +148 -0
- package/dist/functions/utils.d.ts +2 -0
- package/dist/functions/utils.d.ts.map +1 -1
- package/dist/functions/utils.js +195 -0
- package/dist/functions/utils.lua +4 -1
- package/dist/functions/vector.js +150 -0
- package/dist/functions/versusScreen.js +58 -0
- package/dist/functions/weighted.js +57 -0
- package/dist/index.js +219 -0
- package/dist/index.rollup.d.ts +2 -0
- package/dist/indexLua.js +220 -0
- package/dist/interfaces/ChargeBarSprites.js +2 -0
- package/dist/interfaces/Corner.js +2 -0
- package/dist/interfaces/CustomStageTSConfig.js +2 -0
- package/dist/interfaces/GridEntityCustomData.js +2 -0
- package/dist/interfaces/JSONRoomsFile.js +2 -0
- package/dist/interfaces/PlayerHealth.js +2 -0
- package/dist/interfaces/PlayerStats.js +4 -0
- package/dist/interfaces/PocketItemDescription.js +2 -0
- package/dist/interfaces/RoomDescription.js +2 -0
- package/dist/interfaces/SaveData.js +98 -0
- package/dist/interfaces/StageHistoryEntry.js +2 -0
- package/dist/interfaces/TSTLClassMetatable.js +2 -0
- package/dist/interfaces/TrinketSituation.js +2 -0
- package/dist/interfaces/private/AddCallbackParametersCustom.js +4 -0
- package/dist/interfaces/private/CustomStage.js +2 -0
- package/dist/interfaces/private/CustomTrapdoorDescription.js +2 -0
- package/dist/interfaces/private/ModUpgradedInterface.js +2 -0
- package/dist/isaacscript-common.lua +5 -2
- package/dist/maps/PHDPillConversionsMap.js +23 -0
- package/dist/maps/cardNameToTypeMap.js +211 -0
- package/dist/maps/characterNameToTypeMap.js +91 -0
- package/dist/maps/collectibleNameToTypeMap.js +19 -0
- package/dist/maps/defaultPlayerStatMap.js +17 -0
- package/dist/maps/entityTypeVariantToBossIDMap.js +11 -0
- package/dist/maps/falsePHDPillConversionsMap.js +37 -0
- package/dist/maps/gridEntityTypeToBrokenStateMap.js +32 -0
- package/dist/maps/gridEntityXMLMap.js +133 -0
- package/dist/maps/itemPoolTypeToItemPoolName.js +38 -0
- package/dist/maps/keyboardToStringMap.js +71 -0
- package/dist/maps/pillNameToEffectMap.js +91 -0
- package/dist/maps/roomNameToTypeMap.js +43 -0
- package/dist/maps/roomShapeToTopLeftWallGridIndexMap.js +17 -0
- package/dist/maps/transformationNameToPlayerFormMap.js +35 -0
- package/dist/maps/trinketNameToTypeMap.js +19 -0
- package/dist/objects/LRoomShapeToRectangles.js +43 -0
- package/dist/objects/backdropTypeToRockAltType.js +68 -0
- package/dist/objects/batteryNames.js +13 -0
- package/dist/objects/bombNames.js +17 -0
- package/dist/objects/bossIDToEntityTypeVariant.js +228 -0
- package/dist/objects/bossNamePNGFileNames.js +120 -0
- package/dist/objects/bossNames.js +119 -0
- package/dist/objects/bossPortraitPNGFileNames.js +123 -0
- package/dist/objects/cardDescriptions.js +106 -0
- package/dist/objects/cardNames.js +106 -0
- package/dist/objects/challengeBosses.js +60 -0
- package/dist/objects/challengeCharacters.js +58 -0
- package/dist/objects/challengeCollectibleTypes.js +255 -0
- package/dist/objects/challengeNames.js +54 -0
- package/dist/objects/challengeTrinketType.js +58 -0
- package/dist/objects/characterDamageMultipliers.js +49 -0
- package/dist/objects/characterNames.js +48 -0
- package/dist/objects/characterSpritePNGFileNames.js +50 -0
- package/dist/objects/characterStartingCollectibleTypes.js +105 -0
- package/dist/objects/characterStartingTrinketTypes.js +90 -0
- package/dist/objects/chestNames.js +20 -0
- package/dist/objects/coinNames.js +16 -0
- package/dist/objects/coinSubTypeToValue.js +15 -0
- package/dist/objects/collectibleDescriptions.js +742 -0
- package/dist/objects/collectibleNames.js +745 -0
- package/dist/objects/colors.js +26 -0
- package/dist/objects/directionNames.js +11 -0
- package/dist/objects/directionToDegrees.js +11 -0
- package/dist/objects/directionToMoveAction.js +11 -0
- package/dist/objects/directionToShootAction.js +11 -0
- package/dist/objects/directionToVector.js +13 -0
- package/dist/objects/doorSlotFlagToDoorSlot.js +15 -0
- package/dist/objects/doorSlotToDirection.js +15 -0
- package/dist/objects/doorSlotToDoorSlotFlag.js +15 -0
- package/dist/objects/gridEntityTypeToANM2Name.js +37 -0
- package/dist/objects/heartNames.js +21 -0
- package/dist/objects/isaacAPIClassTypeToBrand.js +12 -0
- package/dist/objects/isaacAPIClassTypeToFunctions.js +46 -0
- package/dist/objects/itemPoolTypeToCollectibleTypesSet.js +57 -0
- package/dist/objects/kColors.js +27 -0
- package/dist/objects/keyNames.js +13 -0
- package/dist/objects/languageNames.js +13 -0
- package/dist/objects/oppositeDoorSlots.js +15 -0
- package/dist/objects/pillEffectClasses.js +57 -0
- package/dist/objects/pillEffectNames.js +57 -0
- package/dist/objects/pillEffectTypeToPillEffects.js +23 -0
- package/dist/objects/pillEffectTypes.js +57 -0
- package/dist/objects/playerNamePNGFileNames.js +57 -0
- package/dist/objects/playerPortraitPNGFileNames.js +54 -0
- package/dist/objects/roomShapeBounds.js +48 -0
- package/dist/objects/roomShapeCorners.js +330 -0
- package/dist/objects/roomShapeLayoutSizes.js +41 -0
- package/dist/objects/roomShapeToBottomRightPosition.js +25 -0
- package/dist/objects/roomShapeToDoorSlotCoordinates.js +111 -0
- package/dist/objects/roomShapeToDoorSlots.js +72 -0
- package/dist/objects/roomShapeToDoorSlotsToGridIndexDelta.js +118 -0
- package/dist/objects/roomShapeToGridWidth.js +20 -0
- package/dist/objects/roomShapeToTopLeftPosition.js +26 -0
- package/dist/objects/roomShapeVolumes.js +32 -0
- package/dist/objects/roomTypeNames.js +35 -0
- package/dist/objects/roomTypeSpecialGotoPrefixes.js +35 -0
- package/dist/objects/sackNames.js +11 -0
- package/dist/objects/slotNames.js +26 -0
- package/dist/objects/stageIDNames.js +43 -0
- package/dist/objects/stageToMusic.js +91 -0
- package/dist/objects/stageToStageID.js +117 -0
- package/dist/objects/stageTypeSuffixes.js +14 -0
- package/dist/objects/transformationNames.js +20 -0
- package/dist/objects/trinketDescriptions.js +199 -0
- package/dist/objects/trinketNames.js +202 -0
- package/dist/objects/versusScreenBackgroundColors.js +46 -0
- package/dist/objects/versusScreenDirtSpotColors.js +46 -0
- package/dist/patchErrorFunctions.js +65 -0
- package/dist/serialization.js +21 -0
- package/dist/sets/LRoomShapesSet.js +11 -0
- package/dist/sets/bigRoomShapesSet.js +14 -0
- package/dist/sets/bossSets.js +465 -0
- package/dist/sets/charactersThatStartWithAnActiveItemSet.js +18 -0
- package/dist/sets/charactersWithBlackHeartFromEternalHeartSet.js +9 -0
- package/dist/sets/charactersWithFreeDevilDealsSet.js +6 -0
- package/dist/sets/charactersWithNoRedHeartsSet.js +19 -0
- package/dist/sets/charactersWithNoSoulHeartsSet.js +16 -0
- package/dist/sets/consoleCommandsSet.js +64 -0
- package/dist/sets/entitiesWithArmorSet.js +59 -0
- package/dist/sets/familiarsThatShootPlayerTearsSet.js +15 -0
- package/dist/sets/itemConfigCardTypesForCards.js +14 -0
- package/dist/sets/lostStyleCharactersSet.js +16 -0
- package/dist/sets/mineShaftRoomSubTypesSet.js +12 -0
- package/dist/sets/narrowRoomShapesSet.js +11 -0
- package/dist/sets/poopGridEntityXMLTypesSet.js +16 -0
- package/dist/sets/redHeartSubTypesSet.js +10 -0
- package/dist/sets/repentanceBossIDsSet.js +30 -0
- package/dist/sets/sinEntityTypesSet.js +14 -0
- package/dist/sets/singleUseActiveCollectibleTypesSet.js +15 -0
- package/dist/shaderCrashFix.js +24 -0
- package/dist/shouldFire.js +226 -0
- package/dist/types/AddSubtract.js +2 -0
- package/dist/types/AllButFirst.js +2 -0
- package/dist/types/AllButLast.js +2 -0
- package/dist/types/AnyClass.js +2 -0
- package/dist/types/AnyEntity.js +2 -0
- package/dist/types/AnyFunction.js +2 -0
- package/dist/types/AnyGridEntity.js +2 -0
- package/dist/types/CompositionTypeSatisfiesEnum.js +11 -0
- package/dist/types/ConversionHeartSubType.js +2 -0
- package/dist/types/Decrement.js +2 -0
- package/dist/types/ERange.js +2 -0
- package/dist/types/EntityID.js +2 -0
- package/dist/types/FunctionTuple.js +2 -0
- package/dist/types/GridEntityID.js +2 -0
- package/dist/types/HasFunction.js +2 -0
- package/dist/types/IRange.js +2 -0
- package/dist/types/Immutable.js +2 -0
- package/dist/types/Increment.js +2 -0
- package/dist/types/LowercaseKeys.js +2 -0
- package/dist/types/NaturalNumbersLessThan.js +2 -0
- package/dist/types/NaturalNumbersLessThanOrEqualTo.js +2 -0
- package/dist/types/PickingUpItem.js +44 -0
- package/dist/types/PickupIndex.js +2 -0
- package/dist/types/PlayerIndex.js +2 -0
- package/dist/types/PossibleStatType.js +2 -0
- package/dist/types/PublicInterface.js +2 -0
- package/dist/types/ReadonlyMap.js +6 -0
- package/dist/types/ReadonlyRecord.js +2 -0
- package/dist/types/ReadonlySet.js +6 -0
- package/dist/types/StartsWithLowercase.js +2 -0
- package/dist/types/StartsWithUppercase.js +2 -0
- package/dist/types/TSTLClass.js +2 -0
- package/dist/types/Tuple.js +2 -0
- package/dist/types/TupleKeys.js +2 -0
- package/dist/types/TupleToIntersection.js +2 -0
- package/dist/types/TupleToUnion.js +2 -0
- package/dist/types/TupleWithLengthBetween.js +22 -0
- package/dist/types/TupleWithMaxLength.js +27 -0
- package/dist/types/UnionToIntersection.js +2 -0
- package/dist/types/UppercaseKeys.js +2 -0
- package/dist/types/WeightedArray.js +2 -0
- package/dist/types/WidenLiteral.js +2 -0
- package/dist/types/Writable.js +2 -0
- package/dist/types/private/CallbackTuple.js +2 -0
- package/dist/types/private/ModUpgradedWithFeatures.js +2 -0
- package/package.json +1 -1
- package/src/functions/utils.ts +4 -1
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getVisibleHearts = exports.getScreenTopRightPos = exports.getScreenTopLeftPos = exports.getScreenTopCenterPos = exports.getScreenRightX = exports.getScreenCenterPos = exports.getScreenBottomY = exports.getScreenBottomRightPos = exports.getScreenBottomLeftPos = exports.getScreenBottomCenterPos = exports.getHeartsUIWidth = exports.getHeartRowLength = exports.getHUDOffsetVector = void 0;
|
|
4
|
+
const isaac_typescript_definitions_1 = require("isaac-typescript-definitions");
|
|
5
|
+
const cachedClasses_1 = require("../core/cachedClasses");
|
|
6
|
+
const constants_1 = require("../core/constants");
|
|
7
|
+
const vector_1 = require("./vector");
|
|
8
|
+
/**
|
|
9
|
+
* In the options menu, players have the ability to set a HUD offset (which gets written to the
|
|
10
|
+
* `HudOffset` attribute in the "options.ini" file). This function uses the current HUD offset to
|
|
11
|
+
* generate a vector that should be added to the corresponding position that you want to draw a UI
|
|
12
|
+
* element at.
|
|
13
|
+
*
|
|
14
|
+
* For example:
|
|
15
|
+
* - If the user does not have a HUD offset configured, this function will return `Vector(0, 0)`.
|
|
16
|
+
* - If the user has a HUD offset of 1.0 configured, this function will return `Vector(20, 12)`.
|
|
17
|
+
*/
|
|
18
|
+
function getHUDOffsetVector() {
|
|
19
|
+
// Convert e.g. 0.4 to 4.
|
|
20
|
+
const hudOffset = Math.floor(Options.HUDOffset * 10);
|
|
21
|
+
// Expected values are integers between 1 and 10.
|
|
22
|
+
if (hudOffset < 1 || hudOffset > 10) {
|
|
23
|
+
return (0, vector_1.copyVector)(constants_1.VectorZero);
|
|
24
|
+
}
|
|
25
|
+
const x = hudOffset * 2;
|
|
26
|
+
let y = hudOffset;
|
|
27
|
+
if (y >= 4) {
|
|
28
|
+
y++;
|
|
29
|
+
}
|
|
30
|
+
if (y >= 9) {
|
|
31
|
+
y++;
|
|
32
|
+
}
|
|
33
|
+
return Vector(x, y);
|
|
34
|
+
}
|
|
35
|
+
exports.getHUDOffsetVector = getHUDOffsetVector;
|
|
36
|
+
/**
|
|
37
|
+
* Returns how many hearts are in the heart UI row. If the player has more than 6 hearts, this
|
|
38
|
+
* function will return 6.
|
|
39
|
+
*/
|
|
40
|
+
function getHeartRowLength(player) {
|
|
41
|
+
const maxHearts = player.GetMaxHearts();
|
|
42
|
+
const soulHearts = player.GetSoulHearts();
|
|
43
|
+
const boneHearts = player.GetBoneHearts();
|
|
44
|
+
const brokenHearts = player.GetBrokenHearts();
|
|
45
|
+
// There are no half bone hearts or half broken hearts.
|
|
46
|
+
const combinedHearts = maxHearts + soulHearts + boneHearts * 2 + brokenHearts * 2;
|
|
47
|
+
const heartRowLength = combinedHearts / 2;
|
|
48
|
+
// After 6 hearts, the hearts wrap to a second row.
|
|
49
|
+
return Math.min(heartRowLength, 6);
|
|
50
|
+
}
|
|
51
|
+
exports.getHeartRowLength = getHeartRowLength;
|
|
52
|
+
/**
|
|
53
|
+
* Helper function to get the width of the first player's hearts on the UI. This is useful for
|
|
54
|
+
* drawing UI elements to the right of where the player's hearts are. Make sure to use this in
|
|
55
|
+
* combination with the `getHUDOffsetVector` helper function.
|
|
56
|
+
*/
|
|
57
|
+
function getHeartsUIWidth() {
|
|
58
|
+
const level = cachedClasses_1.game.GetLevel();
|
|
59
|
+
const curses = level.GetCurses();
|
|
60
|
+
const player = Isaac.GetPlayer();
|
|
61
|
+
const extraLives = player.GetExtraLives();
|
|
62
|
+
const effects = player.GetEffects();
|
|
63
|
+
const hasHolyMantleEffect = effects.HasCollectibleEffect(isaac_typescript_definitions_1.CollectibleType.HOLY_MANTLE);
|
|
64
|
+
let heartRowLength = getHeartRowLength(player);
|
|
65
|
+
if (hasHolyMantleEffect) {
|
|
66
|
+
heartRowLength++;
|
|
67
|
+
}
|
|
68
|
+
if (curses === isaac_typescript_definitions_1.LevelCurse.UNKNOWN) {
|
|
69
|
+
heartRowLength = 1;
|
|
70
|
+
}
|
|
71
|
+
let width = heartRowLength * constants_1.UI_HEART_WIDTH;
|
|
72
|
+
if (extraLives > 9) {
|
|
73
|
+
width += 20;
|
|
74
|
+
if (player.HasCollectible(isaac_typescript_definitions_1.CollectibleType.GUPPYS_COLLAR)) {
|
|
75
|
+
width += 6;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else if (extraLives > 0) {
|
|
79
|
+
width += 16;
|
|
80
|
+
if (player.HasCollectible(isaac_typescript_definitions_1.CollectibleType.GUPPYS_COLLAR)) {
|
|
81
|
+
width += 4;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return width;
|
|
85
|
+
}
|
|
86
|
+
exports.getHeartsUIWidth = getHeartsUIWidth;
|
|
87
|
+
function getScreenBottomCenterPos() {
|
|
88
|
+
const bottomRightPos = getScreenBottomRightPos();
|
|
89
|
+
return Vector(bottomRightPos.X / 2, bottomRightPos.Y);
|
|
90
|
+
}
|
|
91
|
+
exports.getScreenBottomCenterPos = getScreenBottomCenterPos;
|
|
92
|
+
function getScreenBottomLeftPos() {
|
|
93
|
+
const bottomRightPos = getScreenBottomRightPos();
|
|
94
|
+
return Vector(0, bottomRightPos.Y);
|
|
95
|
+
}
|
|
96
|
+
exports.getScreenBottomLeftPos = getScreenBottomLeftPos;
|
|
97
|
+
function getScreenBottomRightPos() {
|
|
98
|
+
const screenWidth = Isaac.GetScreenWidth();
|
|
99
|
+
const screenHeight = Isaac.GetScreenHeight();
|
|
100
|
+
return Vector(screenWidth, screenHeight);
|
|
101
|
+
}
|
|
102
|
+
exports.getScreenBottomRightPos = getScreenBottomRightPos;
|
|
103
|
+
function getScreenBottomY() {
|
|
104
|
+
const bottomRightPos = getScreenBottomRightPos();
|
|
105
|
+
return bottomRightPos.Y;
|
|
106
|
+
}
|
|
107
|
+
exports.getScreenBottomY = getScreenBottomY;
|
|
108
|
+
function getScreenCenterPos() {
|
|
109
|
+
const bottomRightPos = getScreenBottomRightPos();
|
|
110
|
+
return bottomRightPos.div(2);
|
|
111
|
+
}
|
|
112
|
+
exports.getScreenCenterPos = getScreenCenterPos;
|
|
113
|
+
function getScreenRightX() {
|
|
114
|
+
const bottomRightPos = getScreenBottomRightPos();
|
|
115
|
+
return bottomRightPos.X;
|
|
116
|
+
}
|
|
117
|
+
exports.getScreenRightX = getScreenRightX;
|
|
118
|
+
function getScreenTopCenterPos() {
|
|
119
|
+
const bottomRightPos = getScreenBottomRightPos();
|
|
120
|
+
return Vector(bottomRightPos.X / 2, 0);
|
|
121
|
+
}
|
|
122
|
+
exports.getScreenTopCenterPos = getScreenTopCenterPos;
|
|
123
|
+
function getScreenTopLeftPos() {
|
|
124
|
+
return (0, vector_1.copyVector)(constants_1.VectorZero);
|
|
125
|
+
}
|
|
126
|
+
exports.getScreenTopLeftPos = getScreenTopLeftPos;
|
|
127
|
+
function getScreenTopRightPos() {
|
|
128
|
+
const bottomRightPos = getScreenBottomRightPos();
|
|
129
|
+
return Vector(bottomRightPos.X, 0);
|
|
130
|
+
}
|
|
131
|
+
exports.getScreenTopRightPos = getScreenTopRightPos;
|
|
132
|
+
/**
|
|
133
|
+
* Get how many hearts are currently being shown on the hearts UI.
|
|
134
|
+
*
|
|
135
|
+
* This function is originally from piber20 Helper.
|
|
136
|
+
*/
|
|
137
|
+
function getVisibleHearts(player) {
|
|
138
|
+
const effectiveMaxHearts = player.GetEffectiveMaxHearts();
|
|
139
|
+
const soulHearts = player.GetSoulHearts();
|
|
140
|
+
const boneHearts = player.GetBoneHearts();
|
|
141
|
+
const maxHearts = Math.max(effectiveMaxHearts, boneHearts * 2);
|
|
142
|
+
let visibleHearts = Math.ceil((maxHearts + soulHearts) / 2);
|
|
143
|
+
if (visibleHearts < 1) {
|
|
144
|
+
visibleHearts = 1;
|
|
145
|
+
}
|
|
146
|
+
return visibleHearts;
|
|
147
|
+
}
|
|
148
|
+
exports.getVisibleHearts = getVisibleHearts;
|
|
@@ -32,6 +32,7 @@ export declare function assertNotNull<T>(value: T, ...[msg]: [null] extends [T]
|
|
|
32
32
|
* - `eRange(1, 3)` returns `[1, 2]`.
|
|
33
33
|
* - `eRange(2, 5)` returns `[2, 3, 4]`.
|
|
34
34
|
* - `eRange(5, 2)` returns `[]`.
|
|
35
|
+
* - `eRange(3, 3)` returns `[]`.
|
|
35
36
|
*
|
|
36
37
|
* @param start The integer to start at.
|
|
37
38
|
* @param end Optional. The integer to end at. If not specified, then the start will be 0 and the
|
|
@@ -58,6 +59,7 @@ export declare function getTraversalDescription(key: unknown, traversalDescripti
|
|
|
58
59
|
* - `iRange(1, 3)` returns `[1, 2, 3]`.
|
|
59
60
|
* - `iRange(2, 5)` returns `[2, 3, 4, 5]`.
|
|
60
61
|
* - `iRange(5, 2)` returns `[]`.
|
|
62
|
+
* - `iRange(3, 3)` returns `[3]`.
|
|
61
63
|
*
|
|
62
64
|
* @param start The integer to start at.
|
|
63
65
|
* @param end Optional. The integer to end at. If not specified, then the start will be 0 and the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/functions/utils.ts"],"names":[],"mappings":";AAIA;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,EACR,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,GAC7B,CAAC,MAAM,CAAC,GACR;IACE,iFAAiF;CAClF,GACJ,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC,EAAE,SAAS,CAAC,CAIxC;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,EACR,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GACxB,CAAC,MAAM,CAAC,GACR;IACE,4EAA4E;CAC7E,GACJ,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAInC;AAED
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/functions/utils.ts"],"names":[],"mappings":";AAIA;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,EACR,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,GAC7B,CAAC,MAAM,CAAC,GACR;IACE,iFAAiF;CAClF,GACJ,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC,EAAE,SAAS,CAAC,CAIxC;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,EACR,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GACxB,CAAC,MAAM,CAAC,GACR;IACE,4EAA4E;CAC7E,GACJ,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAInC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,SAAS,SAAI,GAAG,SAAS,GAAG,EAAE,CAY3E;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,OAAO,EACZ,oBAAoB,EAAE,MAAM,GAC3B,MAAM,CAQR;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,SAAS,SAAI,GAAG,SAAS,GAAG,EAAE,CAO3E;AAED;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAE/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAMvC;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAiBtC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI,CAI7D;AAED;;;;;;;;;;;;;;GAcG;AAEH,wBAAgB,IAAI,CAAC,GAAG,IAAI,EAAE,SAAS,OAAO,EAAE,GAAG,IAAI,CAAG"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.todo = exports.repeat = exports.isRepentance = exports.isMultiplayer = exports.inRange = exports.iRange = exports.getTraversalDescription = exports.eRange = exports.assertNotNull = exports.assertDefined = void 0;
|
|
4
|
+
const ReadonlySet_1 = require("../types/ReadonlySet");
|
|
5
|
+
const playerIndex_1 = require("./playerIndex");
|
|
6
|
+
const types_1 = require("./types");
|
|
7
|
+
/**
|
|
8
|
+
* Helper function to throw an error (using the `error` Lua function) if the provided value is equal
|
|
9
|
+
* to `undefined`.
|
|
10
|
+
*
|
|
11
|
+
* This is useful to have TypeScript narrow a `T | undefined` value to `T` in a concise way.
|
|
12
|
+
*/
|
|
13
|
+
function assertDefined(value, ...[msg]) {
|
|
14
|
+
if (value === undefined) {
|
|
15
|
+
error(msg);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.assertDefined = assertDefined;
|
|
19
|
+
/**
|
|
20
|
+
* Helper function to throw an error (using the `error` Lua function) if the provided value is equal
|
|
21
|
+
* to `null`.
|
|
22
|
+
*
|
|
23
|
+
* This is useful to have TypeScript narrow a `T | null` value to `T` in a concise way.
|
|
24
|
+
*/
|
|
25
|
+
function assertNotNull(value, ...[msg]) {
|
|
26
|
+
if (value === null) {
|
|
27
|
+
error(msg);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.assertNotNull = assertNotNull;
|
|
31
|
+
/**
|
|
32
|
+
* Helper function to return an array of integers with the specified range, inclusive on the lower
|
|
33
|
+
* end and exclusive on the high end. (The "e" in the function name stands for exclusive.) Thus,
|
|
34
|
+
* this function works in a similar way as the built-in `range` function from Python.
|
|
35
|
+
*
|
|
36
|
+
* If the end is lower than the start, an empty array will be returned.
|
|
37
|
+
*
|
|
38
|
+
* For example:
|
|
39
|
+
*
|
|
40
|
+
* - `eRange(2)` returns `[0, 1]`.
|
|
41
|
+
* - `eRange(3)` returns `[0, 1, 2]`.
|
|
42
|
+
* - `eRange(-3)` returns `[0, -1, -2]`.
|
|
43
|
+
* - `eRange(1, 3)` returns `[1, 2]`.
|
|
44
|
+
* - `eRange(2, 5)` returns `[2, 3, 4]`.
|
|
45
|
+
* - `eRange(5, 2)` returns `[]`.
|
|
46
|
+
* - `eRange(3, 3)` returns `[]`.
|
|
47
|
+
*
|
|
48
|
+
* @param start The integer to start at.
|
|
49
|
+
* @param end Optional. The integer to end at. If not specified, then the start will be 0 and the
|
|
50
|
+
* first argument will be the end.
|
|
51
|
+
* @param increment Optional. The increment to use. Default is 1.
|
|
52
|
+
*/
|
|
53
|
+
function eRange(start, end, increment = 1) {
|
|
54
|
+
if (end === undefined) {
|
|
55
|
+
return eRange(0, start, increment);
|
|
56
|
+
}
|
|
57
|
+
const array = [];
|
|
58
|
+
for (let i = start; i < end; i += increment) {
|
|
59
|
+
array.push(i);
|
|
60
|
+
}
|
|
61
|
+
return array;
|
|
62
|
+
}
|
|
63
|
+
exports.eRange = eRange;
|
|
64
|
+
/**
|
|
65
|
+
* Helper function to log what is happening in functions that recursively move through nested data
|
|
66
|
+
* structures.
|
|
67
|
+
*/
|
|
68
|
+
function getTraversalDescription(key, traversalDescription) {
|
|
69
|
+
if (traversalDescription !== "") {
|
|
70
|
+
traversalDescription += " --> ";
|
|
71
|
+
}
|
|
72
|
+
traversalDescription += tostring(key);
|
|
73
|
+
return traversalDescription;
|
|
74
|
+
}
|
|
75
|
+
exports.getTraversalDescription = getTraversalDescription;
|
|
76
|
+
/**
|
|
77
|
+
* Helper function to return an array of integers with the specified range, inclusive on both ends.
|
|
78
|
+
* (The "i" in the function name stands for inclusive.)
|
|
79
|
+
*
|
|
80
|
+
* If the end is lower than the start, an empty array will be returned.
|
|
81
|
+
*
|
|
82
|
+
* For example:
|
|
83
|
+
*
|
|
84
|
+
* - `iRange(2)` returns `[0, 1, 2]`.
|
|
85
|
+
* - `iRange(3)` returns `[0, 1, 2, 3]`.
|
|
86
|
+
* - `iRange(-3)` returns `[0, -1, -2, -3]`.
|
|
87
|
+
* - `iRange(1, 3)` returns `[1, 2, 3]`.
|
|
88
|
+
* - `iRange(2, 5)` returns `[2, 3, 4, 5]`.
|
|
89
|
+
* - `iRange(5, 2)` returns `[]`.
|
|
90
|
+
* - `iRange(3, 3)` returns `[3]`.
|
|
91
|
+
*
|
|
92
|
+
* @param start The integer to start at.
|
|
93
|
+
* @param end Optional. The integer to end at. If not specified, then the start will be 0 and the
|
|
94
|
+
* first argument will be the end.
|
|
95
|
+
* @param increment Optional. The increment to use. Default is 1.
|
|
96
|
+
*/
|
|
97
|
+
function iRange(start, end, increment = 1) {
|
|
98
|
+
if (end === undefined) {
|
|
99
|
+
return iRange(0, start, increment);
|
|
100
|
+
}
|
|
101
|
+
const exclusiveEnd = end + 1;
|
|
102
|
+
return eRange(start, exclusiveEnd, increment);
|
|
103
|
+
}
|
|
104
|
+
exports.iRange = iRange;
|
|
105
|
+
/**
|
|
106
|
+
* Helper function to check if a variable is within a certain range, inclusive on both ends.
|
|
107
|
+
*
|
|
108
|
+
* - For example, `inRange(1, 1, 3)` will return `true`.
|
|
109
|
+
* - For example, `inRange(0, 1, 3)` will return `false`.
|
|
110
|
+
*
|
|
111
|
+
* @param num The number to check.
|
|
112
|
+
* @param start The start of the range to check.
|
|
113
|
+
* @param end The end of the range to check.
|
|
114
|
+
*/
|
|
115
|
+
function inRange(num, start, end) {
|
|
116
|
+
return num >= start && num <= end;
|
|
117
|
+
}
|
|
118
|
+
exports.inRange = inRange;
|
|
119
|
+
/**
|
|
120
|
+
* Helper function to detect if there is two or more players currently playing.
|
|
121
|
+
*
|
|
122
|
+
* Specifically, this function looks for unique `ControllerIndex` values across all players.
|
|
123
|
+
*
|
|
124
|
+
* This function is not safe to use in the `POST_PLAYER_INIT` callback, because the
|
|
125
|
+
* `ControllerIndex` will not be set properly. As a workaround, you can use it in the
|
|
126
|
+
* `POST_PLAYER_INIT_FIRST` callback (or some other callback like `POST_UPDATE`).
|
|
127
|
+
*/
|
|
128
|
+
function isMultiplayer() {
|
|
129
|
+
const players = (0, playerIndex_1.getAllPlayers)();
|
|
130
|
+
const controllerIndexes = players.map((player) => player.ControllerIndex);
|
|
131
|
+
const controllerIndexesSet = new ReadonlySet_1.ReadonlySet(controllerIndexes);
|
|
132
|
+
return controllerIndexesSet.size > 1;
|
|
133
|
+
}
|
|
134
|
+
exports.isMultiplayer = isMultiplayer;
|
|
135
|
+
/**
|
|
136
|
+
* Helper function to check if the player is using Afterbirth+ or Repentance.
|
|
137
|
+
*
|
|
138
|
+
* This function should always be used over the `REPENTANCE` constant, since the latter is not safe.
|
|
139
|
+
*
|
|
140
|
+
* Specifically, this function checks for the `Sprite.GetAnimation` method:
|
|
141
|
+
* https://bindingofisaacrebirth.fandom.com/wiki/V1.06.J818#Lua_Changes
|
|
142
|
+
*/
|
|
143
|
+
function isRepentance() {
|
|
144
|
+
const metatable = getmetatable(Sprite);
|
|
145
|
+
assertDefined(metatable, "Failed to get the metatable of the Sprite global table.");
|
|
146
|
+
const classTable = metatable.get("__class");
|
|
147
|
+
assertDefined(classTable, 'Failed to get the "__class" key of the Sprite metatable.');
|
|
148
|
+
const getAnimation = classTable.get("GetAnimation");
|
|
149
|
+
return (0, types_1.isFunction)(getAnimation);
|
|
150
|
+
}
|
|
151
|
+
exports.isRepentance = isRepentance;
|
|
152
|
+
/**
|
|
153
|
+
* Helper function to repeat code N times. This is faster to type and cleaner than using a for loop.
|
|
154
|
+
*
|
|
155
|
+
* For example:
|
|
156
|
+
*
|
|
157
|
+
* ```ts
|
|
158
|
+
* const player = Isaac.GetPlayer();
|
|
159
|
+
* repeat(10, () => {
|
|
160
|
+
* player.AddCollectible(CollectibleType.STEVEN);
|
|
161
|
+
* });
|
|
162
|
+
* ```
|
|
163
|
+
*
|
|
164
|
+
* The repeated function is passed the index of the iteration, if needed:
|
|
165
|
+
*
|
|
166
|
+
* ```ts
|
|
167
|
+
* repeat(3, (i) => {
|
|
168
|
+
* print(i); // Prints "0", "1", "2"
|
|
169
|
+
* });
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
function repeat(num, func) {
|
|
173
|
+
for (let i = 0; i < num; i++) {
|
|
174
|
+
func(i);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
exports.repeat = repeat;
|
|
178
|
+
/**
|
|
179
|
+
* Helper function to signify that the enclosing code block is not yet complete. Using this function
|
|
180
|
+
* is similar to writing a "TODO" comment, but it has the benefit of preventing ESLint errors due to
|
|
181
|
+
* unused variables or early returns.
|
|
182
|
+
*
|
|
183
|
+
* When you see this function, it simply means that the programmer intends to add in more code to
|
|
184
|
+
* this spot later.
|
|
185
|
+
*
|
|
186
|
+
* This function is variadic, meaning that you can pass as many arguments as you want. (This is
|
|
187
|
+
* useful as a means to prevent unused variables.)
|
|
188
|
+
*
|
|
189
|
+
* This function does not actually do anything. (It is an "empty" function.)
|
|
190
|
+
*
|
|
191
|
+
* @allowEmptyVariadic
|
|
192
|
+
*/
|
|
193
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
|
|
194
|
+
function todo(...args) { }
|
|
195
|
+
exports.todo = todo;
|
package/dist/functions/utils.lua
CHANGED
|
@@ -46,6 +46,7 @@ end
|
|
|
46
46
|
-- - `eRange(1, 3)` returns `[1, 2]`.
|
|
47
47
|
-- - `eRange(2, 5)` returns `[2, 3, 4]`.
|
|
48
48
|
-- - `eRange(5, 2)` returns `[]`.
|
|
49
|
+
-- - `eRange(3, 3)` returns `[]`.
|
|
49
50
|
--
|
|
50
51
|
-- @param start The integer to start at.
|
|
51
52
|
-- @param end Optional. The integer to end at. If not specified, then the start will be 0 and the
|
|
@@ -90,6 +91,7 @@ end
|
|
|
90
91
|
-- - `iRange(1, 3)` returns `[1, 2, 3]`.
|
|
91
92
|
-- - `iRange(2, 5)` returns `[2, 3, 4, 5]`.
|
|
92
93
|
-- - `iRange(5, 2)` returns `[]`.
|
|
94
|
+
-- - `iRange(3, 3)` returns `[3]`.
|
|
93
95
|
--
|
|
94
96
|
-- @param start The integer to start at.
|
|
95
97
|
-- @param end Optional. The integer to end at. If not specified, then the start will be 0 and the
|
|
@@ -102,7 +104,8 @@ function ____exports.iRange(self, start, ____end, increment)
|
|
|
102
104
|
if ____end == nil then
|
|
103
105
|
return ____exports.iRange(nil, 0, start, increment)
|
|
104
106
|
end
|
|
105
|
-
|
|
107
|
+
local exclusiveEnd = ____end + 1
|
|
108
|
+
return ____exports.eRange(nil, start, exclusiveEnd, increment)
|
|
106
109
|
end
|
|
107
110
|
--- Helper function to check if a variable is within a certain range, inclusive on both ends.
|
|
108
111
|
--
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.vectorToString = exports.vectorToDirection = exports.vectorEquals = exports.serializeVector = exports.isVector = exports.isSerializedVector = exports.getRandomVector = exports.getClosestVectorTo = exports.doesVectorHaveLength = exports.deserializeVector = exports.copyVector = void 0;
|
|
4
|
+
const SerializationBrand_1 = require("../enums/private/SerializationBrand");
|
|
5
|
+
const direction_1 = require("./direction");
|
|
6
|
+
const isaacAPIClass_1 = require("./isaacAPIClass");
|
|
7
|
+
const random_1 = require("./random");
|
|
8
|
+
const rng_1 = require("./rng");
|
|
9
|
+
const table_1 = require("./table");
|
|
10
|
+
const types_1 = require("./types");
|
|
11
|
+
const utils_1 = require("./utils");
|
|
12
|
+
const OBJECT_NAME = "Vector";
|
|
13
|
+
const KEYS = ["X", "Y"];
|
|
14
|
+
/** Helper function to copy a `Vector` Isaac API class. */
|
|
15
|
+
function copyVector(vector) {
|
|
16
|
+
if (!isVector(vector)) {
|
|
17
|
+
error(`Failed to copy a ${OBJECT_NAME} object since the provided object was not a userdata ${OBJECT_NAME} class.`);
|
|
18
|
+
}
|
|
19
|
+
return Vector(vector.X, vector.Y);
|
|
20
|
+
}
|
|
21
|
+
exports.copyVector = copyVector;
|
|
22
|
+
/**
|
|
23
|
+
* Helper function to convert a `SerializedVector` object to a normal `RNG` object. (This is used by
|
|
24
|
+
* the save data manager when reading data from the "save#.dat" file.)
|
|
25
|
+
*/
|
|
26
|
+
function deserializeVector(vector) {
|
|
27
|
+
if (!(0, types_1.isTable)(vector)) {
|
|
28
|
+
error(`Failed to deserialize a ${OBJECT_NAME} object since the provided object was not a Lua table.`);
|
|
29
|
+
}
|
|
30
|
+
const [x, y] = (0, table_1.getNumbersFromTable)(vector, OBJECT_NAME, ...KEYS);
|
|
31
|
+
(0, utils_1.assertDefined)(x, `Failed to deserialize a ${OBJECT_NAME} object since the provided object did not have a value for: X`);
|
|
32
|
+
(0, utils_1.assertDefined)(y, `Failed to deserialize a ${OBJECT_NAME} object since the provided object did not have a value for: Y`);
|
|
33
|
+
return Vector(x, y);
|
|
34
|
+
}
|
|
35
|
+
exports.deserializeVector = deserializeVector;
|
|
36
|
+
/**
|
|
37
|
+
* Helper function to measure a vector to see if it has a non-zero length using a threshold to
|
|
38
|
+
* ignore extremely small values.
|
|
39
|
+
*
|
|
40
|
+
* Use this function instead of explicitly checking if the length is 0 because vectors in the game
|
|
41
|
+
* are unlikely to ever be exactly set to 0. Instead, they will always have some miniscule length.
|
|
42
|
+
*
|
|
43
|
+
* @param vector The vector to measure.
|
|
44
|
+
* @param threshold Optional. The threshold from 0 to consider to be a non-zero vector. Default is
|
|
45
|
+
* 0.01.
|
|
46
|
+
*/
|
|
47
|
+
function doesVectorHaveLength(vector, threshold = 0.01) {
|
|
48
|
+
return vector.Length() >= threshold;
|
|
49
|
+
}
|
|
50
|
+
exports.doesVectorHaveLength = doesVectorHaveLength;
|
|
51
|
+
/**
|
|
52
|
+
* Given an array of vectors, this helper function returns the closest one to a provided reference
|
|
53
|
+
* vector.
|
|
54
|
+
*
|
|
55
|
+
* @param referenceVector The vector to compare against.
|
|
56
|
+
* @param vectors The array of vectors to look through.
|
|
57
|
+
*/
|
|
58
|
+
function getClosestVectorTo(referenceVector, vectors) {
|
|
59
|
+
let closestVector;
|
|
60
|
+
let closestDistance = math.huge;
|
|
61
|
+
for (const vector of vectors) {
|
|
62
|
+
const distance = referenceVector.Distance(vector);
|
|
63
|
+
if (distance < closestDistance) {
|
|
64
|
+
closestVector = vector;
|
|
65
|
+
closestDistance = distance;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return closestVector;
|
|
69
|
+
}
|
|
70
|
+
exports.getClosestVectorTo = getClosestVectorTo;
|
|
71
|
+
/**
|
|
72
|
+
* Helper function to get a random vector between (-1, -1) and (1, 1).
|
|
73
|
+
*
|
|
74
|
+
* To get random vectors with a bigger length, multiply this with a number.
|
|
75
|
+
*
|
|
76
|
+
* Use this over the `RandomVector` function when you need the vector to be seeded.
|
|
77
|
+
*
|
|
78
|
+
* If you want to generate an unseeded vector, you must explicitly pass `undefined` to the
|
|
79
|
+
* `seedOrRNG` parameter.
|
|
80
|
+
*
|
|
81
|
+
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
82
|
+
* `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
83
|
+
* a random seed.
|
|
84
|
+
*/
|
|
85
|
+
function getRandomVector(seedOrRNG) {
|
|
86
|
+
const rng = (0, rng_1.isRNG)(seedOrRNG) ? seedOrRNG : (0, rng_1.newRNG)(seedOrRNG);
|
|
87
|
+
const x = (0, random_1.getRandomFloat)(-1, 1, rng);
|
|
88
|
+
const y = (0, random_1.getRandomFloat)(-1, 1, rng);
|
|
89
|
+
return Vector(x, y);
|
|
90
|
+
}
|
|
91
|
+
exports.getRandomVector = getRandomVector;
|
|
92
|
+
/**
|
|
93
|
+
* Used to determine is the given table is a serialized `Vector` object created by the `deepCopy`
|
|
94
|
+
* function.
|
|
95
|
+
*/
|
|
96
|
+
function isSerializedVector(object) {
|
|
97
|
+
if (!(0, types_1.isTable)(object)) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
return (0, table_1.tableHasKeys)(object, ...KEYS) && object.has(SerializationBrand_1.SerializationBrand.VECTOR);
|
|
101
|
+
}
|
|
102
|
+
exports.isSerializedVector = isSerializedVector;
|
|
103
|
+
/** Helper function to check if something is an instantiated `Vector` object. */
|
|
104
|
+
function isVector(object) {
|
|
105
|
+
return (0, isaacAPIClass_1.isIsaacAPIClassOfType)(object, OBJECT_NAME);
|
|
106
|
+
}
|
|
107
|
+
exports.isVector = isVector;
|
|
108
|
+
/**
|
|
109
|
+
* Helper function to convert a `Vector` object to a `SerializedVector` object. (This is used by the
|
|
110
|
+
* save data manager when writing data from the "save#.dat" file.)
|
|
111
|
+
*/
|
|
112
|
+
function serializeVector(vector) {
|
|
113
|
+
if (!isVector(vector)) {
|
|
114
|
+
error(`Failed to serialize a ${OBJECT_NAME} object since the provided object was not a userdata ${OBJECT_NAME} class.`);
|
|
115
|
+
}
|
|
116
|
+
const vectorTable = new LuaMap();
|
|
117
|
+
(0, table_1.copyUserdataValuesToTable)(vector, KEYS, vectorTable);
|
|
118
|
+
vectorTable.set(SerializationBrand_1.SerializationBrand.VECTOR, "");
|
|
119
|
+
return vectorTable;
|
|
120
|
+
}
|
|
121
|
+
exports.serializeVector = serializeVector;
|
|
122
|
+
/**
|
|
123
|
+
* Helper function to compare two vectors for equality.
|
|
124
|
+
*
|
|
125
|
+
* This function is useful because vectors are not directly comparable. In other words, `Vector(1.2)
|
|
126
|
+
* === Vector(1.2)` will be equal to false.
|
|
127
|
+
*/
|
|
128
|
+
function vectorEquals(vector1, vector2) {
|
|
129
|
+
return (0, isaacAPIClass_1.isaacAPIClassEquals)(vector1, vector2, KEYS);
|
|
130
|
+
}
|
|
131
|
+
exports.vectorEquals = vectorEquals;
|
|
132
|
+
/** Helper function for finding out which way a vector is pointing. */
|
|
133
|
+
function vectorToDirection(vector) {
|
|
134
|
+
const angleDegrees = vector.GetAngleDegrees();
|
|
135
|
+
return (0, direction_1.angleToDirection)(angleDegrees);
|
|
136
|
+
}
|
|
137
|
+
exports.vectorToDirection = vectorToDirection;
|
|
138
|
+
/**
|
|
139
|
+
* Helper function to convert a vector to a string.
|
|
140
|
+
*
|
|
141
|
+
* @param vector The vector to convert.
|
|
142
|
+
* @param round Optional. If true, will round the vector values to the nearest integer. Default is
|
|
143
|
+
* false.
|
|
144
|
+
*/
|
|
145
|
+
function vectorToString(vector, round = false) {
|
|
146
|
+
const x = round ? Math.round(vector.X) : vector.X;
|
|
147
|
+
const y = round ? Math.round(vector.Y) : vector.Y;
|
|
148
|
+
return `(${x}, ${y})`;
|
|
149
|
+
}
|
|
150
|
+
exports.vectorToString = vectorToString;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCharacterPortraitPNGFilePath = exports.getCharacterNamePNGFilePath = exports.getBossPortraitPNGFilePath = exports.getBossNamePNGFilePath = void 0;
|
|
4
|
+
const bossNamePNGFileNames_1 = require("../objects/bossNamePNGFileNames");
|
|
5
|
+
const bossPortraitPNGFileNames_1 = require("../objects/bossPortraitPNGFileNames");
|
|
6
|
+
const playerNamePNGFileNames_1 = require("../objects/playerNamePNGFileNames");
|
|
7
|
+
const playerPortraitPNGFileNames_1 = require("../objects/playerPortraitPNGFileNames");
|
|
8
|
+
/** Most of the PNG files related to the versus screen are located in this directory. */
|
|
9
|
+
const PNG_PATH_PREFIX = "gfx/ui/boss";
|
|
10
|
+
/**
|
|
11
|
+
* Player portraits are not located in the same directory as everything else, since they are re-used
|
|
12
|
+
* from the animation where the player travels to a new stage.
|
|
13
|
+
*/
|
|
14
|
+
const PLAYER_PORTRAIT_PNG_PATH_PREFIX = "gfx/ui/stage";
|
|
15
|
+
/**
|
|
16
|
+
* Helper function to get the path to the name file that corresponds to the graphic shown on the
|
|
17
|
+
* versus screen for the particular boss.
|
|
18
|
+
*
|
|
19
|
+
* For example, the file path for `BossID.MONSTRO` is "gfx/ui/boss/bossname_20.0_monstro.png".
|
|
20
|
+
*/
|
|
21
|
+
function getBossNamePNGFilePath(bossID) {
|
|
22
|
+
const fileName = bossNamePNGFileNames_1.BOSS_NAME_PNG_FILE_NAMES[bossID];
|
|
23
|
+
return `${PNG_PATH_PREFIX}/${fileName}`;
|
|
24
|
+
}
|
|
25
|
+
exports.getBossNamePNGFilePath = getBossNamePNGFilePath;
|
|
26
|
+
/**
|
|
27
|
+
* Helper function to get the path to the portrait file that corresponds to the graphic shown on the
|
|
28
|
+
* versus screen for the particular boss.
|
|
29
|
+
*
|
|
30
|
+
* For example, the file path for `BossID.MONSTRO` is "gfx/ui/boss/portrait_20.0_monstro.png".
|
|
31
|
+
*/
|
|
32
|
+
function getBossPortraitPNGFilePath(bossID) {
|
|
33
|
+
const fileName = bossPortraitPNGFileNames_1.BOSS_PORTRAIT_PNG_FILE_NAMES[bossID];
|
|
34
|
+
return `${PNG_PATH_PREFIX}/${fileName}`;
|
|
35
|
+
}
|
|
36
|
+
exports.getBossPortraitPNGFilePath = getBossPortraitPNGFilePath;
|
|
37
|
+
/**
|
|
38
|
+
* Helper function to get the path to the name file that corresponds to the graphic shown on the
|
|
39
|
+
* versus screen for the particular character.
|
|
40
|
+
*
|
|
41
|
+
* For example, the file path for `PlayerType.ISAAC` is "gfx/ui/boss/playername_01_isaac.png".
|
|
42
|
+
*/
|
|
43
|
+
function getCharacterNamePNGFilePath(character) {
|
|
44
|
+
const fileName = playerNamePNGFileNames_1.PLAYER_NAME_PNG_FILE_NAMES[character];
|
|
45
|
+
return `${PNG_PATH_PREFIX}/${fileName}`;
|
|
46
|
+
}
|
|
47
|
+
exports.getCharacterNamePNGFilePath = getCharacterNamePNGFilePath;
|
|
48
|
+
/**
|
|
49
|
+
* Helper function to get the path to the portrait file that corresponds to the graphic shown on the
|
|
50
|
+
* versus screen for the particular character.
|
|
51
|
+
*
|
|
52
|
+
* For example, the file path for `PlayerType.ISAAC` is "gfx/ui/boss/playerportrait_isaac.png".
|
|
53
|
+
*/
|
|
54
|
+
function getCharacterPortraitPNGFilePath(character) {
|
|
55
|
+
const fileName = playerPortraitPNGFileNames_1.PLAYER_PORTRAIT_PNG_FILE_NAMES[character];
|
|
56
|
+
return `${PLAYER_PORTRAIT_PNG_PATH_PREFIX}/${fileName}`;
|
|
57
|
+
}
|
|
58
|
+
exports.getCharacterPortraitPNGFilePath = getCharacterPortraitPNGFilePath;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRandomIndexFromWeightedArray = exports.getRandomFromWeightedArray = void 0;
|
|
4
|
+
const array_1 = require("./array");
|
|
5
|
+
const random_1 = require("./random");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
/**
|
|
8
|
+
* Get a random value from a `WeightedArray`. (A `WeightedArray` is an array of tuples, where the
|
|
9
|
+
* first element in the tuple is a value, and the second element in the tuple is a float
|
|
10
|
+
* corresponding to the value's weight.)
|
|
11
|
+
*
|
|
12
|
+
* If you want to get an unseeded element, you must explicitly pass `undefined` to the `seedOrRNG`
|
|
13
|
+
* parameter.
|
|
14
|
+
*
|
|
15
|
+
* @param weightedArray The array to pick from.
|
|
16
|
+
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
17
|
+
* `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
18
|
+
* a random seed.
|
|
19
|
+
*/
|
|
20
|
+
function getRandomFromWeightedArray(weightedArray, seedOrRNG) {
|
|
21
|
+
const randomIndex = getRandomIndexFromWeightedArray(weightedArray, seedOrRNG);
|
|
22
|
+
const randomElement = weightedArray[randomIndex];
|
|
23
|
+
(0, utils_1.assertDefined)(randomElement, `Failed to get an element from a weighted array using a random index of: ${randomIndex}`);
|
|
24
|
+
return randomElement[0];
|
|
25
|
+
}
|
|
26
|
+
exports.getRandomFromWeightedArray = getRandomFromWeightedArray;
|
|
27
|
+
/**
|
|
28
|
+
* Get a random index from a `WeightedArray`. (A `WeightedArray` is an array of tuples, where the
|
|
29
|
+
* first element in the tuple is a value, and the second element in the tuple is a float
|
|
30
|
+
* corresponding to the value's weight.)
|
|
31
|
+
*
|
|
32
|
+
* If you want to get an unseeded index, you must explicitly pass `undefined` to the `seedOrRNG`
|
|
33
|
+
* parameter.
|
|
34
|
+
*
|
|
35
|
+
* @param weightedArray The array to pick from.
|
|
36
|
+
* @param seedOrRNG The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
37
|
+
* `RNG.Next` method will be called. If `undefined` is provided, it will default to
|
|
38
|
+
* a random seed.
|
|
39
|
+
*/
|
|
40
|
+
function getRandomIndexFromWeightedArray(weightedArray, seedOrRNG) {
|
|
41
|
+
if (weightedArray.length === 0) {
|
|
42
|
+
error("Failed to get a random index from a weighted array since the provided array was empty.");
|
|
43
|
+
}
|
|
44
|
+
const weights = weightedArray.map((tuple) => tuple[1]);
|
|
45
|
+
const totalWeight = (0, array_1.sumArray)(weights);
|
|
46
|
+
const randomWeight = (0, random_1.getRandomFloat)(0, totalWeight, seedOrRNG);
|
|
47
|
+
let weightAccumulator = 0;
|
|
48
|
+
for (const [i, tuple] of weightedArray.entries()) {
|
|
49
|
+
const [_element, weight] = tuple;
|
|
50
|
+
weightAccumulator += weight;
|
|
51
|
+
if (weightAccumulator >= randomWeight) {
|
|
52
|
+
return i;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
error("Failed to get a random index from a weighted array.");
|
|
56
|
+
}
|
|
57
|
+
exports.getRandomIndexFromWeightedArray = getRandomIndexFromWeightedArray;
|