isaacscript-common 84.0.0 → 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 +4 -1
- package/dist/functions/utils.d.ts.map +1 -1
- package/dist/functions/utils.js +195 -0
- package/dist/functions/utils.lua +6 -2
- 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 +4 -1
- 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 +7 -3
- 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 +6 -2
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deepCopy = void 0;
|
|
4
|
+
const DefaultMap_1 = require("../classes/DefaultMap");
|
|
5
|
+
const constants_1 = require("../classes/features/other/saveDataManager/constants");
|
|
6
|
+
const SerializationBrand_1 = require("../enums/private/SerializationBrand");
|
|
7
|
+
const SerializationType_1 = require("../enums/SerializationType");
|
|
8
|
+
const serialization_1 = require("../serialization");
|
|
9
|
+
const array_1 = require("./array");
|
|
10
|
+
const isaacAPIClass_1 = require("./isaacAPIClass");
|
|
11
|
+
const log_1 = require("./log");
|
|
12
|
+
const serialization_2 = require("./serialization");
|
|
13
|
+
const sort_1 = require("./sort");
|
|
14
|
+
const tstlClass_1 = require("./tstlClass");
|
|
15
|
+
const types_1 = require("./types");
|
|
16
|
+
const utils_1 = require("./utils");
|
|
17
|
+
function deepCopy(value, serializationType = SerializationType_1.SerializationType.NONE, traversalDescription = "", classConstructors = new LuaMap(), insideMap = false) {
|
|
18
|
+
if (constants_1.SAVE_DATA_MANAGER_DEBUG) {
|
|
19
|
+
let logString = `deepCopy is operating on: ${traversalDescription}`;
|
|
20
|
+
if (serializationType === SerializationType_1.SerializationType.SERIALIZE) {
|
|
21
|
+
logString += " (serializing)";
|
|
22
|
+
}
|
|
23
|
+
else if (serializationType === SerializationType_1.SerializationType.DESERIALIZE) {
|
|
24
|
+
logString += " (deserializing)";
|
|
25
|
+
}
|
|
26
|
+
logString += `: ${value}`;
|
|
27
|
+
(0, log_1.log)(logString);
|
|
28
|
+
}
|
|
29
|
+
const valueType = type(value);
|
|
30
|
+
switch (valueType) {
|
|
31
|
+
// First, handling the trivial case of primitives.
|
|
32
|
+
case "nil":
|
|
33
|
+
case "boolean":
|
|
34
|
+
case "number":
|
|
35
|
+
case "string": {
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
// Second, handle values that cannot be serialized.
|
|
39
|
+
case "function":
|
|
40
|
+
case "thread": {
|
|
41
|
+
if (serializationType === SerializationType_1.SerializationType.SERIALIZE) {
|
|
42
|
+
error(`The deep copy function does not support serialization of "${traversalDescription}", since it is type: ${valueType}`);
|
|
43
|
+
}
|
|
44
|
+
if (serializationType === SerializationType_1.SerializationType.DESERIALIZE) {
|
|
45
|
+
error(`The deep copy function does not support deserialization of "${traversalDescription}", since it is type: ${valueType}`);
|
|
46
|
+
}
|
|
47
|
+
// We cannot copy this, so simply return the reference.
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
case "table": {
|
|
51
|
+
const luaMap = value;
|
|
52
|
+
return deepCopyTable(luaMap, serializationType, traversalDescription, classConstructors, insideMap);
|
|
53
|
+
}
|
|
54
|
+
case "userdata": {
|
|
55
|
+
return deepCopyUserdata(value, serializationType, traversalDescription);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.deepCopy = deepCopy;
|
|
60
|
+
function deepCopyTable(luaMap, serializationType, traversalDescription, classConstructors, insideMap) {
|
|
61
|
+
// First, handle the cases of TSTL classes or serialized TSTL classes.
|
|
62
|
+
if ((0, tstlClass_1.isDefaultMap)(luaMap) || luaMap.has(SerializationBrand_1.SerializationBrand.DEFAULT_MAP)) {
|
|
63
|
+
return deepCopyDefaultMap(luaMap, serializationType, traversalDescription, classConstructors, insideMap);
|
|
64
|
+
}
|
|
65
|
+
if ((0, tstlClass_1.isTSTLMap)(luaMap) || luaMap.has(SerializationBrand_1.SerializationBrand.MAP)) {
|
|
66
|
+
return deepCopyMap(luaMap, serializationType, traversalDescription, classConstructors, insideMap);
|
|
67
|
+
}
|
|
68
|
+
if ((0, tstlClass_1.isTSTLSet)(luaMap) || luaMap.has(SerializationBrand_1.SerializationBrand.SET)) {
|
|
69
|
+
return deepCopySet(luaMap, serializationType, traversalDescription, classConstructors, insideMap);
|
|
70
|
+
}
|
|
71
|
+
const className = (0, tstlClass_1.getTSTLClassName)(luaMap);
|
|
72
|
+
if (className === "WeakMap") {
|
|
73
|
+
error(`The deep copy function does not support copying the "WeakMap" class for: ${traversalDescription}`);
|
|
74
|
+
}
|
|
75
|
+
if (className === "WeakSet") {
|
|
76
|
+
error(`The deep copy function does not support copying the "WeakSet" class for: ${traversalDescription}`);
|
|
77
|
+
}
|
|
78
|
+
if (className !== undefined || luaMap.has(SerializationBrand_1.SerializationBrand.TSTL_CLASS)) {
|
|
79
|
+
return deepCopyTSTLClass(luaMap, serializationType, traversalDescription, classConstructors, insideMap);
|
|
80
|
+
}
|
|
81
|
+
// This is not a TSTL Map/Set/class. If it has a metatable, abort.
|
|
82
|
+
checkMetatable(luaMap, traversalDescription);
|
|
83
|
+
// Handle the special case of serialized Isaac API classes.
|
|
84
|
+
if ((0, serialization_2.isSerializedIsaacAPIClass)(luaMap) &&
|
|
85
|
+
serializationType === SerializationType_1.SerializationType.DESERIALIZE) {
|
|
86
|
+
return (0, serialization_2.deserializeIsaacAPIClass)(luaMap);
|
|
87
|
+
}
|
|
88
|
+
// Handle the special case of an array.
|
|
89
|
+
if ((0, array_1.isArray)(luaMap)) {
|
|
90
|
+
return deepCopyArray(luaMap, serializationType, traversalDescription, classConstructors, insideMap);
|
|
91
|
+
}
|
|
92
|
+
// Base case: copy a normal Lua table
|
|
93
|
+
return deepCopyNormalLuaTable(luaMap, serializationType, traversalDescription, classConstructors, insideMap);
|
|
94
|
+
}
|
|
95
|
+
function deepCopyDefaultMap(defaultMap, serializationType, traversalDescription, classConstructors, insideMap) {
|
|
96
|
+
if (constants_1.SAVE_DATA_MANAGER_DEBUG) {
|
|
97
|
+
(0, log_1.log)("deepCopy is copying a DefaultMap.");
|
|
98
|
+
}
|
|
99
|
+
const constructorArg = (0, tstlClass_1.isDefaultMap)(defaultMap)
|
|
100
|
+
? defaultMap.getConstructorArg()
|
|
101
|
+
: undefined; // The undefined case is handled explicitly in the "getNewDefaultMap" function.
|
|
102
|
+
// First, handle the special case of serializing a DefaultMap instantiated with a factory
|
|
103
|
+
// function. If this is the case, then we cannot serialize it (because there is no way to
|
|
104
|
+
// serialize a function).
|
|
105
|
+
if (serializationType === SerializationType_1.SerializationType.SERIALIZE &&
|
|
106
|
+
!(0, types_1.isPrimitive)(constructorArg)) {
|
|
107
|
+
if (insideMap) {
|
|
108
|
+
// The case of a DefaultMap within another map is complicated. Unlike a DefaultMap attached to
|
|
109
|
+
// a "normal" object, the `merge` function will have no reference to the factory function that
|
|
110
|
+
// was used to instantiate it. Thus, there is no way to copy this object. In this case, we
|
|
111
|
+
// throw a run-time error to immediately alert the end-user that their data structure is
|
|
112
|
+
// invalid.
|
|
113
|
+
error("Failed to deep copy a DefaultMap because it was instantiated with a factory function and was also inside of an array, map, or set. For more information, see: https://isaacscript.github.io/main/gotchas#failed-to-deep-copy-a-defaultmap");
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
// In most cases, the DefaultMap will be attached to a normal table element. In this case, if
|
|
117
|
+
// we serialize it as a normal `Map`, then everything will work out fine, because the `merge`
|
|
118
|
+
// function only needs to copy the values (and not instantiate the object itself).
|
|
119
|
+
return deepCopyMap(defaultMap, serializationType, traversalDescription, classConstructors, insideMap);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const newDefaultMap = getNewDefaultMap(defaultMap, serializationType, traversalDescription, constructorArg);
|
|
123
|
+
insideMap = true;
|
|
124
|
+
const { entries, convertedNumberKeysToStrings } = getCopiedEntries(defaultMap, serializationType, traversalDescription, classConstructors, insideMap);
|
|
125
|
+
if (convertedNumberKeysToStrings) {
|
|
126
|
+
// Differentiating between the two types looks superfluous but is necessary for TSTL to produce
|
|
127
|
+
// the proper set method call.
|
|
128
|
+
if ((0, tstlClass_1.isDefaultMap)(newDefaultMap)) {
|
|
129
|
+
newDefaultMap.set(SerializationBrand_1.SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "");
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
newDefaultMap.set(SerializationBrand_1.SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "");
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
for (const [key, value] of entries) {
|
|
136
|
+
// Differentiating between the two types looks superfluous but is necessary for TSTL to produce
|
|
137
|
+
// the proper set method call.
|
|
138
|
+
if ((0, tstlClass_1.isDefaultMap)(newDefaultMap)) {
|
|
139
|
+
newDefaultMap.set(key, value);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
newDefaultMap.set(key, value);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
insideMap = false;
|
|
146
|
+
return newDefaultMap;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The new copied default map with either be a TSTL `DefaultMap` class or a Lua table, depending on
|
|
150
|
+
* whether we are serializing.
|
|
151
|
+
*/
|
|
152
|
+
function getNewDefaultMap(defaultMap, serializationType, traversalDescription, constructorArg) {
|
|
153
|
+
switch (serializationType) {
|
|
154
|
+
case SerializationType_1.SerializationType.NONE: {
|
|
155
|
+
// eslint-disable-next-line isaacscript/no-invalid-default-map
|
|
156
|
+
return new DefaultMap_1.DefaultMap(constructorArg);
|
|
157
|
+
}
|
|
158
|
+
case SerializationType_1.SerializationType.SERIALIZE: {
|
|
159
|
+
// Since we are serializing, the new object will be a Lua table. (At this point, we already
|
|
160
|
+
// handled the special case of a DefaultMap instantiated with a factory function.)
|
|
161
|
+
const newDefaultMap = new LuaMap();
|
|
162
|
+
newDefaultMap.set(SerializationBrand_1.SerializationBrand.DEFAULT_MAP, "");
|
|
163
|
+
newDefaultMap.set(SerializationBrand_1.SerializationBrand.DEFAULT_MAP_VALUE, constructorArg);
|
|
164
|
+
return newDefaultMap;
|
|
165
|
+
}
|
|
166
|
+
case SerializationType_1.SerializationType.DESERIALIZE: {
|
|
167
|
+
if ((0, tstlClass_1.isDefaultMap)(defaultMap)) {
|
|
168
|
+
error(`Failed to deserialize a default map of "${traversalDescription}", since it was not a Lua table.`);
|
|
169
|
+
}
|
|
170
|
+
const defaultMapValue = defaultMap.get(SerializationBrand_1.SerializationBrand.DEFAULT_MAP_VALUE);
|
|
171
|
+
(0, utils_1.assertDefined)(defaultMapValue, `Failed to deserialize a default map of "${traversalDescription}", since there was no serialization brand of: ${SerializationBrand_1.SerializationBrand.DEFAULT_MAP_VALUE}`);
|
|
172
|
+
// eslint-disable-next-line isaacscript/no-invalid-default-map
|
|
173
|
+
return new DefaultMap_1.DefaultMap(defaultMapValue);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function deepCopyMap(map, serializationType, traversalDescription, classConstructors, insideMap) {
|
|
178
|
+
if (constants_1.SAVE_DATA_MANAGER_DEBUG) {
|
|
179
|
+
(0, log_1.log)("deepCopy is copying a Map.");
|
|
180
|
+
}
|
|
181
|
+
let newMap;
|
|
182
|
+
if (serializationType === SerializationType_1.SerializationType.SERIALIZE) {
|
|
183
|
+
// Since we are serializing, the new object will be a Lua table.
|
|
184
|
+
newMap = new LuaMap();
|
|
185
|
+
newMap.set(SerializationBrand_1.SerializationBrand.MAP, "");
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
newMap = new Map();
|
|
189
|
+
}
|
|
190
|
+
insideMap = true;
|
|
191
|
+
const { entries, convertedNumberKeysToStrings } = getCopiedEntries(map, serializationType, traversalDescription, classConstructors, insideMap);
|
|
192
|
+
if (convertedNumberKeysToStrings) {
|
|
193
|
+
// Differentiating between the two types looks superfluous but is necessary for TSTL to produce
|
|
194
|
+
// the proper set method call.
|
|
195
|
+
if ((0, tstlClass_1.isTSTLMap)(newMap)) {
|
|
196
|
+
newMap.set(SerializationBrand_1.SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "");
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
newMap.set(SerializationBrand_1.SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "");
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
for (const [key, value] of entries) {
|
|
203
|
+
// Differentiating between the two types looks superfluous but is necessary for TSTL to produce
|
|
204
|
+
// the proper set method call.
|
|
205
|
+
if ((0, tstlClass_1.isTSTLMap)(newMap)) {
|
|
206
|
+
newMap.set(key, value);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
newMap.set(key, value);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
insideMap = false;
|
|
213
|
+
return newMap;
|
|
214
|
+
}
|
|
215
|
+
function deepCopySet(set, serializationType, traversalDescription, classConstructors, insideMap) {
|
|
216
|
+
if (constants_1.SAVE_DATA_MANAGER_DEBUG) {
|
|
217
|
+
(0, log_1.log)("deepCopy is copying a Set.");
|
|
218
|
+
}
|
|
219
|
+
let newSet;
|
|
220
|
+
if (serializationType === SerializationType_1.SerializationType.SERIALIZE) {
|
|
221
|
+
// For serialization purposes, we represent a `Set` as a table with keys that match the
|
|
222
|
+
// keys/values in the Set and values of an empty string.
|
|
223
|
+
newSet = new LuaMap();
|
|
224
|
+
newSet.set(SerializationBrand_1.SerializationBrand.SET, "");
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
newSet = new Set();
|
|
228
|
+
}
|
|
229
|
+
const { entries, convertedNumberKeysToStrings } = getCopiedEntries(set, serializationType, traversalDescription, classConstructors, insideMap);
|
|
230
|
+
if (convertedNumberKeysToStrings) {
|
|
231
|
+
// Differentiating between the two types looks superfluous but is necessary for TSTL to produce
|
|
232
|
+
// the proper set method call.
|
|
233
|
+
if ((0, tstlClass_1.isTSTLSet)(newSet)) {
|
|
234
|
+
// We should never be serializing an object of type `Set`.
|
|
235
|
+
error("The deep copy function cannot convert number keys to strings for a Set.");
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
newSet.set(SerializationBrand_1.SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "");
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
for (const [key] of entries) {
|
|
242
|
+
// Differentiating between the two types looks superfluous but is necessary for TSTL to produce
|
|
243
|
+
// the proper set method call.
|
|
244
|
+
if ((0, tstlClass_1.isTSTLSet)(newSet)) {
|
|
245
|
+
newSet.add(key);
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
newSet.set(key, "");
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return newSet;
|
|
252
|
+
}
|
|
253
|
+
function deepCopyTSTLClass(tstlClass, serializationType, traversalDescription, classConstructors, insideMap) {
|
|
254
|
+
if (constants_1.SAVE_DATA_MANAGER_DEBUG) {
|
|
255
|
+
(0, log_1.log)("deepCopy is copying a TSTL class.");
|
|
256
|
+
}
|
|
257
|
+
let newClass;
|
|
258
|
+
switch (serializationType) {
|
|
259
|
+
case SerializationType_1.SerializationType.NONE: {
|
|
260
|
+
// We can use the class constructor from the old class.
|
|
261
|
+
newClass = (0, tstlClass_1.newTSTLClass)(tstlClass);
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
case SerializationType_1.SerializationType.SERIALIZE: {
|
|
265
|
+
newClass = new LuaMap();
|
|
266
|
+
// We brand it with the name of the class so that we can run the corresponding constructor
|
|
267
|
+
// during deserialization.
|
|
268
|
+
const tstlClassName = (0, tstlClass_1.getTSTLClassName)(tstlClass);
|
|
269
|
+
if (tstlClassName !== undefined) {
|
|
270
|
+
newClass.set(SerializationBrand_1.SerializationBrand.TSTL_CLASS, tstlClassName);
|
|
271
|
+
}
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
case SerializationType_1.SerializationType.DESERIALIZE: {
|
|
275
|
+
const tstlClassName = tstlClass.get(SerializationBrand_1.SerializationBrand.TSTL_CLASS);
|
|
276
|
+
(0, utils_1.assertDefined)(tstlClassName, "Failed to deserialize a TSTL class since the brand did not contain the class name.");
|
|
277
|
+
const classConstructor = classConstructors.get(tstlClassName);
|
|
278
|
+
(0, utils_1.assertDefined)(classConstructor, `Failed to deserialize a TSTL class since there was no constructor registered for a class name of "${tstlClassName}". If this mod is using the save data manager, it must register the class constructor with the "saveDataManagerRegisterClass" method.`);
|
|
279
|
+
// eslint-disable-next-line new-cap
|
|
280
|
+
newClass = new classConstructor();
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
const { entries, convertedNumberKeysToStrings } = getCopiedEntries(tstlClass, serializationType, traversalDescription, classConstructors, insideMap);
|
|
285
|
+
if (convertedNumberKeysToStrings) {
|
|
286
|
+
newClass.set(SerializationBrand_1.SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "");
|
|
287
|
+
}
|
|
288
|
+
for (const [key, value] of entries) {
|
|
289
|
+
newClass.set(key, value);
|
|
290
|
+
}
|
|
291
|
+
return newClass;
|
|
292
|
+
}
|
|
293
|
+
function deepCopyArray(array, serializationType, traversalDescription, classConstructors, insideMap) {
|
|
294
|
+
if (constants_1.SAVE_DATA_MANAGER_DEBUG) {
|
|
295
|
+
(0, log_1.log)("deepCopy is copying an array.");
|
|
296
|
+
}
|
|
297
|
+
const newArray = [];
|
|
298
|
+
for (const value of array) {
|
|
299
|
+
const newValue = deepCopy(value, serializationType, traversalDescription, classConstructors, insideMap);
|
|
300
|
+
newArray.push(newValue);
|
|
301
|
+
}
|
|
302
|
+
return newArray;
|
|
303
|
+
}
|
|
304
|
+
function deepCopyNormalLuaTable(luaMap, serializationType, traversalDescription, classConstructors, insideMap) {
|
|
305
|
+
if (constants_1.SAVE_DATA_MANAGER_DEBUG) {
|
|
306
|
+
(0, log_1.log)("deepCopy is copying a normal Lua table.");
|
|
307
|
+
}
|
|
308
|
+
const newTable = new LuaMap();
|
|
309
|
+
const { entries, convertedNumberKeysToStrings } = getCopiedEntries(luaMap, serializationType, traversalDescription, classConstructors, insideMap);
|
|
310
|
+
if (convertedNumberKeysToStrings) {
|
|
311
|
+
newTable.set(SerializationBrand_1.SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "");
|
|
312
|
+
}
|
|
313
|
+
for (const [key, value] of entries) {
|
|
314
|
+
newTable.set(key, value);
|
|
315
|
+
}
|
|
316
|
+
return newTable;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Recursively clones the object's entries, automatically converting number keys to strings, if
|
|
320
|
+
* necessary.
|
|
321
|
+
*
|
|
322
|
+
* This should work on objects/tables, maps, sets, default maps, and classes.
|
|
323
|
+
*/
|
|
324
|
+
function getCopiedEntries(object, serializationType, traversalDescription, classConstructors, insideMap) {
|
|
325
|
+
// First, shallow copy the entries. We cannot use "pairs" to iterate over a `Map` or `Set`. We
|
|
326
|
+
// cannot use "[...pairs(object)]", as it results in a run-time error.
|
|
327
|
+
const entries = [];
|
|
328
|
+
if ((0, tstlClass_1.isTSTLMap)(object) || (0, tstlClass_1.isTSTLSet)(object) || (0, tstlClass_1.isDefaultMap)(object)) {
|
|
329
|
+
for (const [key, value] of object.entries()) {
|
|
330
|
+
entries.push([key, value]);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
for (const [key, value] of pairs(object)) {
|
|
335
|
+
entries.push([key, value]);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
if (constants_1.SAVE_DATA_MANAGER_DEBUG) {
|
|
339
|
+
entries.sort(sort_1.sortTwoDimensionalArray);
|
|
340
|
+
}
|
|
341
|
+
// During serialization, we brand some Lua tables with a special identifier to signify that it has
|
|
342
|
+
// keys that should be deserialized to numbers.
|
|
343
|
+
const convertStringKeysToNumbers = serializationType === SerializationType_1.SerializationType.DESERIALIZE &&
|
|
344
|
+
entries.some(([key]) => key === (0, types_1.asString)(SerializationBrand_1.SerializationBrand.OBJECT_WITH_NUMBER_KEYS));
|
|
345
|
+
const hasNumberKeys = entries.some(([key]) => (0, types_1.isNumber)(key));
|
|
346
|
+
const convertNumberKeysToStrings = serializationType === SerializationType_1.SerializationType.SERIALIZE && hasNumberKeys;
|
|
347
|
+
// Second, deep copy the entries.
|
|
348
|
+
const copiedEntries = [];
|
|
349
|
+
for (const [key, value] of entries) {
|
|
350
|
+
// When deserializing, we do not need to copy the serialization brands that are used to denote
|
|
351
|
+
// the object type.
|
|
352
|
+
if ((0, serialization_1.isSerializationBrand)(key)) {
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
traversalDescription = (0, utils_1.getTraversalDescription)(key, traversalDescription);
|
|
356
|
+
const newValue = deepCopy(value, serializationType, traversalDescription, classConstructors, insideMap);
|
|
357
|
+
let keyToUse = key;
|
|
358
|
+
if (convertStringKeysToNumbers) {
|
|
359
|
+
const numberKey = tonumber(key);
|
|
360
|
+
if (numberKey !== undefined) {
|
|
361
|
+
keyToUse = numberKey;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (convertNumberKeysToStrings) {
|
|
365
|
+
keyToUse = tostring(key);
|
|
366
|
+
}
|
|
367
|
+
copiedEntries.push([keyToUse, newValue]);
|
|
368
|
+
}
|
|
369
|
+
return {
|
|
370
|
+
entries: copiedEntries,
|
|
371
|
+
convertedNumberKeysToStrings: convertNumberKeysToStrings,
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Lua tables can have metatables, which make writing a generic deep cloner impossible. The deep
|
|
376
|
+
* copy function will refuse to copy a table type that has a metatable, outside of specifically
|
|
377
|
+
* supported TSTL objects.
|
|
378
|
+
*/
|
|
379
|
+
function checkMetatable(luaMap, traversalDescription) {
|
|
380
|
+
const metatable = getmetatable(luaMap);
|
|
381
|
+
if (metatable === undefined) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
const tableDescription = traversalDescription === ""
|
|
385
|
+
? "the table to copy"
|
|
386
|
+
: `"${traversalDescription}"`;
|
|
387
|
+
error(`The deepCopy function detected that ${tableDescription} has a metatable. Copying tables with metatables is not supported, unless they are explicitly handled by the save data manager. (e.g. TypeScriptToLua Maps, TypeScriptToLua Sets, etc.)`);
|
|
388
|
+
}
|
|
389
|
+
/** Isaac API classes are of type "userdata". End-user code cannot create userdata. */
|
|
390
|
+
function deepCopyUserdata(value, serializationType, traversalDescription) {
|
|
391
|
+
if (!(0, serialization_2.isCopyableIsaacAPIClass)(value)) {
|
|
392
|
+
const className = (0, isaacAPIClass_1.getIsaacAPIClassName)(value) ?? "Unknown";
|
|
393
|
+
error(`The deep copy function does not support serializing "${traversalDescription}", since it is an Isaac API class of type: ${className}`);
|
|
394
|
+
}
|
|
395
|
+
switch (serializationType) {
|
|
396
|
+
case SerializationType_1.SerializationType.NONE: {
|
|
397
|
+
return (0, serialization_2.copyIsaacAPIClass)(value);
|
|
398
|
+
}
|
|
399
|
+
case SerializationType_1.SerializationType.SERIALIZE: {
|
|
400
|
+
return (0, serialization_2.serializeIsaacAPIClass)(value);
|
|
401
|
+
}
|
|
402
|
+
case SerializationType_1.SerializationType.DESERIALIZE: {
|
|
403
|
+
return error(`The deep copy function can not deserialize "${traversalDescription}", since it is userdata.`);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|