isaacscript-common 87.9.7 → 87.10.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/cachedEnumValues.js +29 -32
- package/dist/callbackClasses.js +142 -289
- package/dist/callbacks.js +147 -183
- package/dist/classes/DefaultMap.js +4 -8
- package/dist/classes/ModFeature.js +21 -25
- package/dist/classes/ModUpgraded.js +43 -47
- package/dist/classes/callbacks/EntityTakeDmgFilter.js +6 -10
- package/dist/classes/callbacks/EntityTakeDmgPlayer.js +7 -11
- package/dist/classes/callbacks/InputActionFilter.js +4 -8
- package/dist/classes/callbacks/InputActionPlayer.js +4 -8
- package/dist/classes/callbacks/PostAmbushFinished.js +10 -14
- package/dist/classes/callbacks/PostAmbushStarted.js +10 -14
- package/dist/classes/callbacks/PostBombExploded.js +8 -12
- package/dist/classes/callbacks/PostBombInitFilter.js +6 -10
- package/dist/classes/callbacks/PostBombInitLate.js +6 -10
- package/dist/classes/callbacks/PostBombRenderFilter.js +6 -10
- package/dist/classes/callbacks/PostBombUpdateFilter.js +6 -10
- package/dist/classes/callbacks/PostBoneSwing.js +7 -11
- package/dist/classes/callbacks/PostCollectibleEmpty.js +6 -10
- package/dist/classes/callbacks/PostCursedTeleport.js +30 -34
- package/dist/classes/callbacks/PostCustomRevive.js +4 -8
- package/dist/classes/callbacks/PostDiceRoomActivated.js +9 -13
- package/dist/classes/callbacks/PostDoorRender.js +8 -12
- package/dist/classes/callbacks/PostDoorUpdate.js +8 -12
- package/dist/classes/callbacks/PostEffectInitFilter.js +6 -10
- package/dist/classes/callbacks/PostEffectInitLate.js +6 -10
- package/dist/classes/callbacks/PostEffectRenderFilter.js +6 -10
- package/dist/classes/callbacks/PostEffectStateChanged.js +8 -12
- package/dist/classes/callbacks/PostEffectUpdateFilter.js +6 -10
- package/dist/classes/callbacks/PostEntityKillFilter.js +6 -10
- package/dist/classes/callbacks/PostEntityRemoveFilter.js +6 -10
- package/dist/classes/callbacks/PostEsauJr.js +4 -8
- package/dist/classes/callbacks/PostFamiliarInitFilter.js +6 -10
- package/dist/classes/callbacks/PostFamiliarInitLate.js +6 -10
- package/dist/classes/callbacks/PostFamiliarRenderFilter.js +6 -10
- package/dist/classes/callbacks/PostFamiliarStateChanged.js +8 -12
- package/dist/classes/callbacks/PostFamiliarUpdateFilter.js +6 -10
- package/dist/classes/callbacks/PostFirstEsauJr.js +4 -8
- package/dist/classes/callbacks/PostFirstFlip.js +4 -8
- package/dist/classes/callbacks/PostFlip.js +4 -8
- package/dist/classes/callbacks/PostGameEndFilter.js +6 -10
- package/dist/classes/callbacks/PostGameStartedReordered.js +6 -10
- package/dist/classes/callbacks/PostGameStartedReorderedLast.js +6 -10
- package/dist/classes/callbacks/PostGreedModeWave.js +7 -11
- package/dist/classes/callbacks/PostGridEntityBroken.js +6 -10
- package/dist/classes/callbacks/PostGridEntityCollision.js +4 -8
- package/dist/classes/callbacks/PostGridEntityCustomBroken.js +6 -10
- package/dist/classes/callbacks/PostGridEntityCustomCollision.js +4 -8
- package/dist/classes/callbacks/PostGridEntityCustomInit.js +6 -10
- package/dist/classes/callbacks/PostGridEntityCustomRemove.js +4 -8
- package/dist/classes/callbacks/PostGridEntityCustomRender.js +6 -10
- package/dist/classes/callbacks/PostGridEntityCustomStateChanged.js +6 -10
- package/dist/classes/callbacks/PostGridEntityCustomUpdate.js +6 -10
- package/dist/classes/callbacks/PostGridEntityInit.js +6 -10
- package/dist/classes/callbacks/PostGridEntityRemove.js +4 -8
- package/dist/classes/callbacks/PostGridEntityRender.js +6 -10
- package/dist/classes/callbacks/PostGridEntityStateChanged.js +6 -10
- package/dist/classes/callbacks/PostGridEntityUpdate.js +6 -10
- package/dist/classes/callbacks/PostHolyMantleRemoved.js +15 -19
- package/dist/classes/callbacks/PostItemDischarge.js +23 -27
- package/dist/classes/callbacks/PostItemPickup.js +6 -10
- package/dist/classes/callbacks/PostKeyboardChanged.js +9 -13
- package/dist/classes/callbacks/PostKnifeInitFilter.js +6 -10
- package/dist/classes/callbacks/PostKnifeInitLate.js +6 -10
- package/dist/classes/callbacks/PostKnifeRenderFilter.js +6 -10
- package/dist/classes/callbacks/PostKnifeUpdateFilter.js +6 -10
- package/dist/classes/callbacks/PostLaserInitFilter.js +6 -10
- package/dist/classes/callbacks/PostLaserInitLate.js +6 -10
- package/dist/classes/callbacks/PostLaserRenderFilter.js +6 -10
- package/dist/classes/callbacks/PostLaserUpdateFilter.js +6 -10
- package/dist/classes/callbacks/PostNPCDeathFilter.js +6 -10
- package/dist/classes/callbacks/PostNPCInitFilter.js +6 -10
- package/dist/classes/callbacks/PostNPCInitLate.js +6 -10
- package/dist/classes/callbacks/PostNPCRenderFilter.js +6 -10
- package/dist/classes/callbacks/PostNPCStateChanged.js +8 -12
- package/dist/classes/callbacks/PostNPCUpdateFilter.js +6 -10
- package/dist/classes/callbacks/PostNewLevelReordered.js +6 -10
- package/dist/classes/callbacks/PostNewRoomEarly.js +17 -21
- package/dist/classes/callbacks/PostNewRoomReordered.js +6 -10
- package/dist/classes/callbacks/PostPEffectUpdateReordered.js +6 -10
- package/dist/classes/callbacks/PostPickupChanged.js +6 -10
- package/dist/classes/callbacks/PostPickupCollect.js +8 -12
- package/dist/classes/callbacks/PostPickupInitFilter.js +6 -10
- package/dist/classes/callbacks/PostPickupInitFirst.js +10 -14
- package/dist/classes/callbacks/PostPickupInitLate.js +6 -10
- package/dist/classes/callbacks/PostPickupRenderFilter.js +6 -10
- package/dist/classes/callbacks/PostPickupSelectionFilter.js +4 -8
- package/dist/classes/callbacks/PostPickupStateChanged.js +8 -12
- package/dist/classes/callbacks/PostPickupUpdateFilter.js +6 -10
- package/dist/classes/callbacks/PostPitRender.js +8 -12
- package/dist/classes/callbacks/PostPitUpdate.js +8 -12
- package/dist/classes/callbacks/PostPlayerChangeHealth.js +14 -18
- package/dist/classes/callbacks/PostPlayerChangeStat.js +26 -30
- package/dist/classes/callbacks/PostPlayerChangeType.js +11 -15
- package/dist/classes/callbacks/PostPlayerCollectibleAdded.js +6 -10
- package/dist/classes/callbacks/PostPlayerCollectibleRemoved.js +6 -10
- package/dist/classes/callbacks/PostPlayerFatalDamage.js +24 -28
- package/dist/classes/callbacks/PostPlayerInitFirst.js +12 -16
- package/dist/classes/callbacks/PostPlayerInitLate.js +9 -13
- package/dist/classes/callbacks/PostPlayerRenderReordered.js +6 -10
- package/dist/classes/callbacks/PostPlayerUpdateReordered.js +6 -10
- package/dist/classes/callbacks/PostPoopRender.js +8 -12
- package/dist/classes/callbacks/PostPoopUpdate.js +8 -12
- package/dist/classes/callbacks/PostPressurePlateRender.js +8 -12
- package/dist/classes/callbacks/PostPressurePlateUpdate.js +8 -12
- package/dist/classes/callbacks/PostProjectileInitFilter.js +6 -10
- package/dist/classes/callbacks/PostProjectileInitLate.js +6 -10
- package/dist/classes/callbacks/PostProjectileKill.js +8 -12
- package/dist/classes/callbacks/PostProjectileRenderFilter.js +6 -10
- package/dist/classes/callbacks/PostProjectileUpdateFilter.js +6 -10
- package/dist/classes/callbacks/PostPurchase.js +21 -25
- package/dist/classes/callbacks/PostRockRender.js +8 -12
- package/dist/classes/callbacks/PostRockUpdate.js +8 -12
- package/dist/classes/callbacks/PostRoomClearChanged.js +9 -13
- package/dist/classes/callbacks/PostSacrifice.js +12 -16
- package/dist/classes/callbacks/PostSlotAnimationChanged.js +6 -10
- package/dist/classes/callbacks/PostSlotCollision.js +8 -12
- package/dist/classes/callbacks/PostSlotDestroyed.js +6 -10
- package/dist/classes/callbacks/PostSlotInit.js +6 -10
- package/dist/classes/callbacks/PostSlotRender.js +6 -10
- package/dist/classes/callbacks/PostSlotUpdate.js +6 -10
- package/dist/classes/callbacks/PostSpikesRender.js +8 -12
- package/dist/classes/callbacks/PostSpikesUpdate.js +8 -12
- package/dist/classes/callbacks/PostTNTRender.js +8 -12
- package/dist/classes/callbacks/PostTNTUpdate.js +8 -12
- package/dist/classes/callbacks/PostTearInitFilter.js +6 -10
- package/dist/classes/callbacks/PostTearInitLate.js +6 -10
- package/dist/classes/callbacks/PostTearInitVeryLate.js +6 -10
- package/dist/classes/callbacks/PostTearKill.js +8 -12
- package/dist/classes/callbacks/PostTearRenderFilter.js +6 -10
- package/dist/classes/callbacks/PostTearUpdateFilter.js +6 -10
- package/dist/classes/callbacks/PostTransformation.js +10 -14
- package/dist/classes/callbacks/PostTrinketBreak.js +16 -20
- package/dist/classes/callbacks/PostUsePillFilter.js +18 -22
- package/dist/classes/callbacks/PreBerserkDeath.js +14 -18
- package/dist/classes/callbacks/PreBombCollisionFilter.js +6 -10
- package/dist/classes/callbacks/PreCustomRevive.js +6 -10
- package/dist/classes/callbacks/PreEntitySpawnFilter.js +4 -8
- package/dist/classes/callbacks/PreFamiliarCollisionFilter.js +6 -10
- package/dist/classes/callbacks/PreGetPedestal.js +8 -12
- package/dist/classes/callbacks/PreItemPickup.js +6 -10
- package/dist/classes/callbacks/PreKnifeCollisionFilter.js +6 -10
- package/dist/classes/callbacks/PreNPCCollisionFilter.js +6 -10
- package/dist/classes/callbacks/PreNPCUpdateFilter.js +6 -10
- package/dist/classes/callbacks/PreNewLevel.js +10 -14
- package/dist/classes/callbacks/PreProjectileCollisionFilter.js +6 -10
- package/dist/classes/callbacks/PreRoomEntitySpawnFilter.js +4 -8
- package/dist/classes/callbacks/PreTearCollisionFilter.js +6 -10
- package/dist/classes/features/callbackLogic/CustomGridEntities.js +46 -50
- package/dist/classes/features/callbackLogic/CustomRevive.js +28 -32
- package/dist/classes/features/callbackLogic/EsauJrDetection.js +11 -15
- package/dist/classes/features/callbackLogic/FlipDetection.js +11 -15
- package/dist/classes/features/callbackLogic/GameReorderedCallbacks.js +26 -30
- package/dist/classes/features/callbackLogic/GridEntityCollisionDetection.js +10 -14
- package/dist/classes/features/callbackLogic/GridEntityRenderDetection.js +6 -10
- package/dist/classes/features/callbackLogic/GridEntityUpdateDetection.js +12 -16
- package/dist/classes/features/callbackLogic/ItemPickupDetection.js +17 -21
- package/dist/classes/features/callbackLogic/PickupChangeDetection.js +6 -10
- package/dist/classes/features/callbackLogic/PlayerCollectibleDetection.js +39 -43
- package/dist/classes/features/callbackLogic/PlayerReorderedCallbacks.js +18 -22
- package/dist/classes/features/callbackLogic/SlotDestroyedDetection.js +17 -21
- package/dist/classes/features/callbackLogic/SlotRenderDetection.js +8 -12
- package/dist/classes/features/callbackLogic/SlotUpdateDetection.js +9 -13
- package/dist/classes/features/other/CharacterHealthConversion.js +13 -17
- package/dist/classes/features/other/CharacterStats.js +9 -13
- package/dist/classes/features/other/CollectibleItemPoolType.js +17 -21
- package/dist/classes/features/other/CustomHotkeys.js +15 -19
- package/dist/classes/features/other/CustomItemPools.js +20 -24
- package/dist/classes/features/other/CustomPickups.js +15 -19
- package/dist/classes/features/other/CustomStages.js +116 -153
- package/dist/classes/features/other/CustomTrapdoors.js +119 -123
- package/dist/classes/features/other/DebugDisplay.js +77 -81
- package/dist/classes/features/other/DeployJSONRoom.js +65 -69
- package/dist/classes/features/other/DisableAllSound.js +14 -18
- package/dist/classes/features/other/DisableInputs.js +24 -28
- package/dist/classes/features/other/EdenStartingStatsHealth.js +36 -40
- package/dist/classes/features/other/ExtraConsoleCommands.js +65 -102
- package/dist/classes/features/other/FadeInRemover.js +9 -13
- package/dist/classes/features/other/FastReset.js +18 -22
- package/dist/classes/features/other/FlyingDetection.js +10 -14
- package/dist/classes/features/other/ForgottenSwitch.js +8 -12
- package/dist/classes/features/other/ItemPoolDetection.js +35 -39
- package/dist/classes/features/other/ModdedElementDetection.js +43 -47
- package/dist/classes/features/other/ModdedElementSets.js +135 -139
- package/dist/classes/features/other/NoSirenSteal.js +7 -11
- package/dist/classes/features/other/Pause.js +48 -52
- package/dist/classes/features/other/PersistentEntities.js +16 -20
- package/dist/classes/features/other/PickupIndexCreation.js +31 -35
- package/dist/classes/features/other/PlayerCollectibleTracking.js +18 -22
- package/dist/classes/features/other/PonyDetection.js +22 -26
- package/dist/classes/features/other/PressInput.js +10 -14
- package/dist/classes/features/other/PreventChildEntities.js +6 -10
- package/dist/classes/features/other/PreventGridEntityRespawn.js +34 -38
- package/dist/classes/features/other/RerunDetection.js +11 -15
- package/dist/classes/features/other/RoomClearFrame.js +11 -15
- package/dist/classes/features/other/RoomHistory.js +30 -34
- package/dist/classes/features/other/RunInNFrames.js +24 -28
- package/dist/classes/features/other/RunNextRoom.js +8 -12
- package/dist/classes/features/other/RunNextRun.js +8 -12
- package/dist/classes/features/other/SaveDataManager.js +61 -65
- package/dist/classes/features/other/SpawnRockAltRewards.js +115 -119
- package/dist/classes/features/other/StageHistory.js +76 -80
- package/dist/classes/features/other/StartAmbush.js +12 -16
- package/dist/classes/features/other/TaintedLazarusPlayers.js +10 -14
- package/dist/classes/features/other/UnlockAchievementsDetection.js +10 -14
- package/dist/classes/features/other/customStages/backdrop.js +68 -71
- package/dist/classes/features/other/customStages/constants.js +7 -10
- package/dist/classes/features/other/customStages/gridEntities.js +23 -30
- package/dist/classes/features/other/customStages/shadows.js +27 -30
- package/dist/classes/features/other/customStages/streakText.js +55 -60
- package/dist/classes/features/other/customStages/utils.js +13 -17
- package/dist/classes/features/other/customStages/v.js +4 -7
- package/dist/classes/features/other/customStages/versusScreen.js +46 -50
- package/dist/classes/features/other/debugDisplay/DebugDisplayBomb.js +8 -12
- package/dist/classes/features/other/debugDisplay/DebugDisplayDoor.js +8 -12
- package/dist/classes/features/other/debugDisplay/DebugDisplayEffect.js +8 -12
- package/dist/classes/features/other/debugDisplay/DebugDisplayFamiliar.js +8 -12
- package/dist/classes/features/other/debugDisplay/DebugDisplayKnife.js +8 -12
- package/dist/classes/features/other/debugDisplay/DebugDisplayLaser.js +8 -12
- package/dist/classes/features/other/debugDisplay/DebugDisplayNPC.js +8 -12
- package/dist/classes/features/other/debugDisplay/DebugDisplayPickup.js +8 -12
- package/dist/classes/features/other/debugDisplay/DebugDisplayPit.js +8 -12
- package/dist/classes/features/other/debugDisplay/DebugDisplayPlayer.js +8 -12
- package/dist/classes/features/other/debugDisplay/DebugDisplayPoop.js +8 -12
- package/dist/classes/features/other/debugDisplay/DebugDisplayPressurePlate.js +8 -12
- package/dist/classes/features/other/debugDisplay/DebugDisplayProjectile.js +8 -12
- package/dist/classes/features/other/debugDisplay/DebugDisplayRock.js +8 -12
- package/dist/classes/features/other/debugDisplay/DebugDisplaySlot.js +8 -12
- package/dist/classes/features/other/debugDisplay/DebugDisplaySpikes.js +8 -12
- package/dist/classes/features/other/debugDisplay/DebugDisplayTNT.js +8 -12
- package/dist/classes/features/other/debugDisplay/DebugDisplayTear.js +8 -12
- package/dist/classes/features/other/debugDisplay/utils.js +6 -10
- package/dist/classes/features/other/extraConsoleCommands/commands.js +411 -557
- package/dist/classes/features/other/extraConsoleCommands/subroutines.js +47 -57
- package/dist/classes/features/other/extraConsoleCommands/v.js +1 -4
- package/dist/classes/features/other/saveDataManager/constants.js +1 -4
- package/dist/classes/features/other/saveDataManager/glowingHourGlass.js +17 -21
- package/dist/classes/features/other/saveDataManager/loadFromDisk.js +19 -22
- package/dist/classes/features/other/saveDataManager/restoreDefaults.js +20 -25
- package/dist/classes/features/other/saveDataManager/saveToDisk.js +13 -16
- package/dist/classes/private/CustomCallback.js +4 -8
- package/dist/classes/private/Feature.js +1 -5
- package/dist/core/cachedClasses.js +12 -15
- package/dist/core/constants.js +126 -130
- package/dist/core/constantsFirstLast.js +22 -25
- package/dist/core/constantsVanilla.js +25 -28
- package/dist/core/upgradeMod.js +7 -10
- package/dist/decorators.js +6 -10
- package/dist/enums/AmbushType.js +2 -5
- package/dist/enums/CornerType.js +2 -5
- package/dist/enums/HealthType.js +2 -5
- package/dist/enums/ISCFeature.js +2 -5
- package/dist/enums/LadderSubTypeCustom.js +2 -5
- package/dist/enums/ModCallbackCustom.js +2 -5
- package/dist/enums/MysteriousPaperEffect.js +2 -5
- package/dist/enums/PlayerStat.js +2 -5
- package/dist/enums/PocketItemType.js +2 -5
- package/dist/enums/RockAltType.js +2 -5
- package/dist/enums/SaveDataKey.js +2 -5
- package/dist/enums/SerializationType.js +2 -5
- package/dist/enums/SlotDestructionType.js +2 -5
- package/dist/enums/private/GridEntityTypeCustom.js +1 -4
- package/dist/enums/private/SerializationBrand.js +2 -5
- package/dist/enums/private/StageTravelState.js +2 -5
- package/dist/enums/private/TrapdoorAnimation.js +2 -5
- package/dist/enums/private/UIStreakAnimation.js +2 -5
- package/dist/features.js +138 -141
- package/dist/functions/ambush.js +9 -12
- package/dist/functions/array.js +45 -76
- package/dist/functions/arrayLua.js +7 -16
- package/dist/functions/benchmark.js +4 -7
- package/dist/functions/bitSet128.js +19 -26
- package/dist/functions/bitwise.js +14 -23
- package/dist/functions/bombs.js +1 -4
- package/dist/functions/bosses.js +68 -85
- package/dist/functions/cards.js +44 -62
- package/dist/functions/challenges.js +28 -39
- package/dist/functions/characters.js +68 -87
- package/dist/functions/charge.js +41 -52
- package/dist/functions/chargeBar.js +2 -6
- package/dist/functions/collectibleTag.js +9 -13
- package/dist/functions/collectibles.js +133 -172
- package/dist/functions/color.js +29 -38
- package/dist/functions/console.js +4 -8
- package/dist/functions/curses.js +6 -10
- package/dist/functions/debugFunctions.js +7 -14
- package/dist/functions/decorators.js +13 -19
- package/dist/functions/deepCopy.js +96 -99
- package/dist/functions/deepCopyTests.js +56 -59
- package/dist/functions/dimensions.js +10 -14
- package/dist/functions/direction.js +22 -30
- package/dist/functions/doors.js +104 -154
- package/dist/functions/easing.js +30 -62
- package/dist/functions/effects.js +6 -10
- package/dist/functions/emptyRoom.js +30 -34
- package/dist/functions/entities.js +88 -115
- package/dist/functions/entitiesSpecific.js +83 -125
- package/dist/functions/entityTypes.js +3 -6
- package/dist/functions/enums.js +27 -41
- package/dist/functions/external.js +4 -8
- package/dist/functions/familiars.js +17 -25
- package/dist/functions/flag.js +10 -19
- package/dist/functions/frames.js +31 -51
- package/dist/functions/globals.js +26 -66
- package/dist/functions/gridEntities.js +231 -269
- package/dist/functions/gridEntitiesSpecific.js +86 -126
- package/dist/functions/gridIndex.js +8 -11
- package/dist/functions/hash.js +1 -4
- package/dist/functions/hex.js +7 -11
- package/dist/functions/input.js +65 -88
- package/dist/functions/isaacAPIClass.js +28 -53
- package/dist/functions/itemPool.js +39 -48
- package/dist/functions/jsonHelpers.js +5 -42
- package/dist/functions/jsonRoom.js +39 -46
- package/dist/functions/kColor.js +30 -39
- package/dist/functions/language.js +3 -6
- package/dist/functions/level.js +20 -26
- package/dist/functions/levelGrid.js +81 -108
- package/dist/functions/log.js +6 -12
- package/dist/functions/logEntities.js +49 -59
- package/dist/functions/logMisc.js +183 -214
- package/dist/functions/map.js +10 -20
- package/dist/functions/math.js +16 -31
- package/dist/functions/merge.js +48 -51
- package/dist/functions/mergeTests.js +34 -37
- package/dist/functions/minimap.js +34 -46
- package/dist/functions/modFeatures.js +1 -4
- package/dist/functions/newArray.js +5 -8
- package/dist/functions/nextStage.js +63 -67
- package/dist/functions/npcDataStructures.js +9 -20
- package/dist/functions/npcs.js +37 -45
- package/dist/functions/pickupVariants.js +26 -39
- package/dist/functions/pickups.js +43 -59
- package/dist/functions/pickupsSpecific.js +76 -118
- package/dist/functions/pills.js +52 -72
- package/dist/functions/playerCenter.js +13 -16
- package/dist/functions/playerCollectibles.js +59 -79
- package/dist/functions/playerDataStructures.js +18 -29
- package/dist/functions/playerEffects.js +12 -19
- package/dist/functions/playerHealth.js +91 -113
- package/dist/functions/playerIndex.js +22 -33
- package/dist/functions/playerTrinkets.js +31 -43
- package/dist/functions/players.js +87 -126
- package/dist/functions/pocketItems.js +33 -43
- package/dist/functions/positionVelocity.js +23 -32
- package/dist/functions/pressurePlate.js +7 -10
- package/dist/functions/projectiles.js +11 -15
- package/dist/functions/random.js +8 -13
- package/dist/functions/readOnly.js +3 -8
- package/dist/functions/render.js +7 -12
- package/dist/functions/revive.js +38 -45
- package/dist/functions/rng.js +31 -44
- package/dist/functions/rockAlt.js +18 -22
- package/dist/functions/roomData.js +24 -40
- package/dist/functions/roomGrid.js +17 -25
- package/dist/functions/roomShape.js +39 -55
- package/dist/functions/roomShapeWalls.js +67 -71
- package/dist/functions/roomTransition.js +13 -17
- package/dist/functions/rooms.js +181 -244
- package/dist/functions/run.js +29 -39
- package/dist/functions/seeds.js +6 -10
- package/dist/functions/serialization.js +27 -34
- package/dist/functions/set.js +24 -40
- package/dist/functions/slots.js +18 -22
- package/dist/functions/sort.js +9 -15
- package/dist/functions/sound.js +12 -16
- package/dist/functions/spawnCollectible.js +21 -26
- package/dist/functions/sprites.js +16 -24
- package/dist/functions/stage.js +122 -164
- package/dist/functions/stats.js +37 -43
- package/dist/functions/storyBosses.js +36 -40
- package/dist/functions/string.js +19 -33
- package/dist/functions/table.js +21 -31
- package/dist/functions/tears.js +6 -14
- package/dist/functions/transformations.js +35 -42
- package/dist/functions/trinketGive.js +29 -36
- package/dist/functions/trinkets.js +45 -60
- package/dist/functions/tstlClass.js +11 -20
- package/dist/functions/types.js +22 -46
- package/dist/functions/ui.js +25 -40
- package/dist/functions/utils.js +22 -36
- package/dist/functions/vector.js +33 -46
- package/dist/functions/versusScreen.js +12 -18
- package/dist/functions/weighted.js +8 -12
- package/dist/index.js +150 -166
- package/dist/index.rollup.d.ts +11 -11
- package/dist/indexLua.js +151 -167
- package/dist/interfaces/ChargeBarSprites.js +1 -2
- package/dist/interfaces/Corner.js +1 -2
- package/dist/interfaces/CustomStageTSConfig.js +1 -2
- package/dist/interfaces/GridEntityCustomData.js +1 -2
- package/dist/interfaces/JSONRoomsFile.js +1 -2
- package/dist/interfaces/PlayerHealth.d.ts +11 -11
- package/dist/interfaces/PlayerHealth.d.ts.map +1 -1
- package/dist/interfaces/PlayerHealth.js +1 -2
- package/dist/interfaces/PlayerStats.js +2 -4
- package/dist/interfaces/PocketItemDescription.js +1 -2
- package/dist/interfaces/RoomDescription.js +1 -2
- package/dist/interfaces/SaveData.js +1 -2
- package/dist/interfaces/StageHistoryEntry.js +1 -2
- package/dist/interfaces/TSTLClassMetatable.js +1 -2
- package/dist/interfaces/TrinketSituation.js +1 -2
- package/dist/interfaces/private/AddCallbackParametersCustom.js +2 -4
- package/dist/interfaces/private/CustomStage.js +1 -2
- package/dist/interfaces/private/CustomTrapdoorDescription.js +1 -2
- package/dist/interfaces/private/ModUpgradedInterface.js +1 -2
- package/dist/isaacscript-common.lua +1 -1
- package/dist/maps/PHDPillConversionsMap.js +19 -22
- package/dist/maps/cardNameToTypeMap.js +205 -208
- package/dist/maps/characterNameToTypeMap.js +85 -88
- package/dist/maps/collectibleNameToTypeMap.js +5 -8
- package/dist/maps/defaultPlayerStatMap.js +10 -13
- package/dist/maps/entityTypeVariantToBossIDMap.js +3 -6
- package/dist/maps/falsePHDPillConversionsMap.js +33 -36
- package/dist/maps/gridEntityTypeToBrokenStateMap.js +15 -18
- package/dist/maps/gridEntityXMLMap.js +52 -55
- package/dist/maps/itemPoolTypeToItemPoolName.js +33 -36
- package/dist/maps/keyboardToStringMap.js +66 -69
- package/dist/maps/pillNameToEffectMap.js +83 -86
- package/dist/maps/roomNameToTypeMap.js +38 -41
- package/dist/maps/roomShapeToTopLeftWallGridIndexMap.js +9 -12
- package/dist/maps/transformationNameToPlayerFormMap.js +30 -33
- package/dist/maps/trinketNameToTypeMap.js +5 -8
- package/dist/objects/LRoomShapeToRectangles.js +22 -25
- package/dist/objects/backdropTypeToRockAltType.js +65 -68
- package/dist/objects/batteryNames.js +8 -11
- package/dist/objects/bombNames.js +11 -14
- package/dist/objects/bossIDToEntityTypeVariant.js +116 -119
- package/dist/objects/bossNamePNGFileNames.js +104 -107
- package/dist/objects/bossNames.js +105 -108
- package/dist/objects/bossPortraitPNGFileNames.js +104 -107
- package/dist/objects/cardDescriptions.js +101 -104
- package/dist/objects/cardNames.js +101 -104
- package/dist/objects/challengeBosses.js +49 -52
- package/dist/objects/challengeCharacters.js +49 -52
- package/dist/objects/challengeCollectibleTypes.js +160 -163
- package/dist/objects/challengeNames.js +49 -52
- package/dist/objects/challengeTrinketType.js +48 -51
- package/dist/objects/characterDamageMultipliers.js +44 -47
- package/dist/objects/characterNames.js +44 -47
- package/dist/objects/characterSpritePNGFileNames.js +44 -47
- package/dist/objects/characterStartingCollectibleTypes.js +49 -52
- package/dist/objects/characterStartingTrinketTypes.js +44 -47
- package/dist/objects/chestNames.js +15 -18
- package/dist/objects/coinNames.js +11 -14
- package/dist/objects/coinSubTypeToValue.js +11 -14
- package/dist/objects/collectibleDescriptions.js +725 -728
- package/dist/objects/collectibleNames.js +725 -728
- package/dist/objects/colors.js +1 -4
- package/dist/objects/directionNames.js +7 -10
- package/dist/objects/directionToDegrees.js +7 -10
- package/dist/objects/directionToMoveAction.js +7 -10
- package/dist/objects/directionToShootAction.js +7 -10
- package/dist/objects/directionToVector.js +9 -12
- package/dist/objects/doorSlotFlagToDoorSlot.js +11 -14
- package/dist/objects/doorSlotToDirection.js +11 -14
- package/dist/objects/doorSlotToDoorSlotFlag.js +11 -14
- package/dist/objects/gridEntityTypeToANM2Name.js +30 -33
- package/dist/objects/heartNames.js +16 -19
- package/dist/objects/isaacAPIClassTypeToBrand.js +8 -11
- package/dist/objects/isaacAPIClassTypeToFunctions.js +37 -40
- package/dist/objects/itemPoolTypeToCollectibleTypesSet.js +9 -45
- package/dist/objects/kColors.js +1 -4
- package/dist/objects/keyNames.js +8 -11
- package/dist/objects/languageNames.js +9 -12
- package/dist/objects/oppositeDoorSlots.js +11 -14
- package/dist/objects/pillEffectClasses.js +53 -56
- package/dist/objects/pillEffectNames.js +53 -56
- package/dist/objects/pillEffectTypeToPillEffects.js +11 -14
- package/dist/objects/pillEffectTypes.js +53 -56
- package/dist/objects/playerNamePNGFileNames.js +44 -47
- package/dist/objects/playerPortraitPNGFileNames.js +44 -47
- package/dist/objects/roomShapeBounds.js +23 -26
- package/dist/objects/roomShapeCorners.js +128 -131
- package/dist/objects/roomShapeLayoutSizes.js +23 -26
- package/dist/objects/roomShapeToBottomRightPosition.js +17 -20
- package/dist/objects/roomShapeToDoorSlotCoordinates.js +78 -81
- package/dist/objects/roomShapeToDoorSlots.js +48 -51
- package/dist/objects/roomShapeToDoorSlotsToGridIndexDelta.js +82 -85
- package/dist/objects/roomShapeToGridWidth.js +14 -17
- package/dist/objects/roomShapeToTopLeftPosition.js +18 -21
- package/dist/objects/roomShapeVolumes.js +21 -24
- package/dist/objects/roomTypeNames.js +32 -35
- package/dist/objects/roomTypeSpecialGotoPrefixes.js +32 -35
- package/dist/objects/sackNames.js +6 -9
- package/dist/objects/slotNames.js +21 -24
- package/dist/objects/stageIDNames.js +33 -36
- package/dist/objects/stageToMusic.js +69 -72
- package/dist/objects/stageToStageID.js +90 -93
- package/dist/objects/stageTypeSuffixes.js +8 -11
- package/dist/objects/transformationNames.js +16 -19
- package/dist/objects/trinketDescriptions.js +192 -195
- package/dist/objects/trinketNames.js +192 -195
- package/dist/objects/versusScreenBackgroundColors.js +39 -42
- package/dist/objects/versusScreenDirtSpotColors.js +39 -42
- package/dist/patchErrorFunctions.js +4 -7
- package/dist/serialization.js +6 -9
- package/dist/sets/LRoomShapesSet.js +7 -10
- package/dist/sets/bigRoomShapesSet.js +10 -13
- package/dist/sets/bossSets.js +261 -264
- package/dist/sets/charactersThatStartWithAnActiveItemSet.js +14 -17
- package/dist/sets/charactersWithBlackHeartFromEternalHeartSet.js +5 -8
- package/dist/sets/charactersWithFreeDevilDealsSet.js +3 -6
- package/dist/sets/charactersWithNoRedHeartsSet.js +11 -14
- package/dist/sets/charactersWithNoSoulHeartsSet.js +8 -11
- package/dist/sets/consoleCommandsSet.js +2 -5
- package/dist/sets/entitiesWithArmorSet.js +44 -47
- package/dist/sets/familiarsThatShootPlayerTearsSet.js +11 -14
- package/dist/sets/itemConfigCardTypesForCards.js +7 -10
- package/dist/sets/lostStyleCharactersSet.js +8 -11
- package/dist/sets/mineShaftRoomSubTypesSet.js +8 -11
- package/dist/sets/narrowRoomShapesSet.js +7 -10
- package/dist/sets/poopGridEntityXMLTypesSet.js +12 -15
- package/dist/sets/redHeartSubTypesSet.js +6 -9
- package/dist/sets/repentanceBossIDsSet.js +26 -29
- package/dist/sets/sinEntityTypesSet.js +10 -13
- package/dist/sets/singleUseActiveCollectibleTypesSet.js +11 -14
- package/dist/shaderCrashFix.js +4 -7
- package/dist/shouldFire.js +28 -58
- package/dist/types/AddSubtract.js +1 -2
- package/dist/types/AllButFirst.js +1 -2
- package/dist/types/AllButLast.js +1 -2
- package/dist/types/AnyClass.js +1 -2
- package/dist/types/AnyEntity.js +1 -2
- package/dist/types/AnyFunction.js +1 -2
- package/dist/types/AnyGridEntity.js +1 -2
- package/dist/types/CompositionTypeSatisfiesEnum.js +1 -2
- package/dist/types/ConversionHeartSubType.js +1 -2
- package/dist/types/Decrement.js +1 -2
- package/dist/types/ERange.js +1 -2
- package/dist/types/EntityID.js +1 -2
- package/dist/types/FunctionTuple.js +1 -2
- package/dist/types/GridEntityID.js +1 -2
- package/dist/types/HasFunction.js +1 -2
- package/dist/types/IRange.js +1 -2
- package/dist/types/Immutable.js +1 -2
- package/dist/types/Increment.js +1 -2
- package/dist/types/LowercaseKeys.js +1 -2
- package/dist/types/NaturalNumbersLessThan.js +1 -2
- package/dist/types/NaturalNumbersLessThanOrEqualTo.js +1 -2
- package/dist/types/ObjectValues.js +1 -2
- package/dist/types/PickingUpItem.js +15 -22
- package/dist/types/PickupIndex.js +1 -2
- package/dist/types/PlayerIndex.js +1 -2
- package/dist/types/PossibleStatType.js +1 -2
- package/dist/types/PublicInterface.js +1 -2
- package/dist/types/ReadonlyMap.js +1 -4
- package/dist/types/ReadonlyRecord.js +1 -2
- package/dist/types/ReadonlySet.js +1 -4
- package/dist/types/StartsWithLowercase.js +1 -2
- package/dist/types/StartsWithUppercase.js +1 -2
- package/dist/types/TSTLClass.js +1 -2
- package/dist/types/Tuple.js +1 -2
- package/dist/types/TupleKeys.js +1 -2
- package/dist/types/TupleToIntersection.js +1 -2
- package/dist/types/TupleToUnion.js +1 -2
- package/dist/types/TupleWithLengthBetween.js +1 -2
- package/dist/types/TupleWithMaxLength.js +1 -2
- package/dist/types/UnionToIntersection.js +1 -2
- package/dist/types/UppercaseKeys.js +1 -2
- package/dist/types/WeightedArray.js +1 -2
- package/dist/types/WidenLiteral.js +1 -2
- package/dist/types/Writable.js +1 -2
- package/dist/types/private/CallbackTuple.js +1 -2
- package/dist/types/private/ModUpgradedWithFeatures.js +1 -2
- package/package.json +3 -3
- package/src/interfaces/PlayerHealth.ts +12 -11
|
@@ -1,30 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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) {
|
|
1
|
+
import { DefaultMap } from "../classes/DefaultMap";
|
|
2
|
+
import { SAVE_DATA_MANAGER_DEBUG } from "../classes/features/other/saveDataManager/constants";
|
|
3
|
+
import { SerializationBrand } from "../enums/private/SerializationBrand";
|
|
4
|
+
import { SerializationType } from "../enums/SerializationType";
|
|
5
|
+
import { isSerializationBrand } from "../serialization";
|
|
6
|
+
import { isArray } from "./array";
|
|
7
|
+
import { getIsaacAPIClassName } from "./isaacAPIClass";
|
|
8
|
+
import { log } from "./log";
|
|
9
|
+
import { copyIsaacAPIClass, deserializeIsaacAPIClass, isCopyableIsaacAPIClass, isSerializedIsaacAPIClass, serializeIsaacAPIClass, } from "./serialization";
|
|
10
|
+
import { sortTwoDimensionalArray } from "./sort";
|
|
11
|
+
import { getTSTLClassName, isDefaultMap, isTSTLMap, isTSTLSet, newTSTLClass, } from "./tstlClass";
|
|
12
|
+
import { asString, isNumber, isPrimitive } from "./types";
|
|
13
|
+
import { assertDefined, getTraversalDescription } from "./utils";
|
|
14
|
+
export function deepCopy(value, serializationType = SerializationType.NONE, traversalDescription = "", classConstructors = new LuaMap(), insideMap = false) {
|
|
15
|
+
if (SAVE_DATA_MANAGER_DEBUG) {
|
|
19
16
|
let logString = `deepCopy is operating on: ${traversalDescription}`;
|
|
20
|
-
if (serializationType ===
|
|
17
|
+
if (serializationType === SerializationType.SERIALIZE) {
|
|
21
18
|
logString += " (serializing)";
|
|
22
19
|
}
|
|
23
|
-
else if (serializationType ===
|
|
20
|
+
else if (serializationType === SerializationType.DESERIALIZE) {
|
|
24
21
|
logString += " (deserializing)";
|
|
25
22
|
}
|
|
26
23
|
logString += `: ${value}`;
|
|
27
|
-
|
|
24
|
+
log(logString);
|
|
28
25
|
}
|
|
29
26
|
const valueType = type(value);
|
|
30
27
|
switch (valueType) {
|
|
@@ -38,10 +35,10 @@ function deepCopy(value, serializationType = SerializationType_1.SerializationTy
|
|
|
38
35
|
// Second, handle values that cannot be serialized.
|
|
39
36
|
case "function":
|
|
40
37
|
case "thread": {
|
|
41
|
-
if (serializationType ===
|
|
38
|
+
if (serializationType === SerializationType.SERIALIZE) {
|
|
42
39
|
error(`The deep copy function does not support serialization of "${traversalDescription}", since it is type: ${valueType}`);
|
|
43
40
|
}
|
|
44
|
-
if (serializationType ===
|
|
41
|
+
if (serializationType === SerializationType.DESERIALIZE) {
|
|
45
42
|
error(`The deep copy function does not support deserialization of "${traversalDescription}", since it is type: ${valueType}`);
|
|
46
43
|
}
|
|
47
44
|
// We cannot copy this, so simply return the reference.
|
|
@@ -72,8 +69,8 @@ function checkMetatable(luaMap, traversalDescription) {
|
|
|
72
69
|
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.)`);
|
|
73
70
|
}
|
|
74
71
|
function deepCopyArray(array, serializationType, traversalDescription, classConstructors, insideMap) {
|
|
75
|
-
if (
|
|
76
|
-
|
|
72
|
+
if (SAVE_DATA_MANAGER_DEBUG) {
|
|
73
|
+
log("deepCopy is copying an array.");
|
|
77
74
|
}
|
|
78
75
|
const newArray = [];
|
|
79
76
|
for (const value of array) {
|
|
@@ -83,17 +80,17 @@ function deepCopyArray(array, serializationType, traversalDescription, classCons
|
|
|
83
80
|
return newArray;
|
|
84
81
|
}
|
|
85
82
|
function deepCopyDefaultMap(defaultMap, serializationType, traversalDescription, classConstructors, insideMap) {
|
|
86
|
-
if (
|
|
87
|
-
|
|
83
|
+
if (SAVE_DATA_MANAGER_DEBUG) {
|
|
84
|
+
log("deepCopy is copying a DefaultMap.");
|
|
88
85
|
}
|
|
89
|
-
const constructorArg =
|
|
86
|
+
const constructorArg = isDefaultMap(defaultMap)
|
|
90
87
|
? defaultMap.getConstructorArg()
|
|
91
88
|
: undefined; // The undefined case is handled explicitly in the "getNewDefaultMap" function.
|
|
92
89
|
// First, handle the special case of serializing a DefaultMap instantiated with a factory
|
|
93
90
|
// function. If this is the case, then we cannot serialize it (because there is no way to
|
|
94
91
|
// serialize a function).
|
|
95
|
-
if (serializationType ===
|
|
96
|
-
&& !
|
|
92
|
+
if (serializationType === SerializationType.SERIALIZE
|
|
93
|
+
&& !isPrimitive(constructorArg)) {
|
|
97
94
|
if (insideMap) {
|
|
98
95
|
// The case of a DefaultMap within another map is complicated. Unlike a DefaultMap attached to
|
|
99
96
|
// a "normal" object, the `merge` function will have no reference to the factory function that
|
|
@@ -115,18 +112,18 @@ function deepCopyDefaultMap(defaultMap, serializationType, traversalDescription,
|
|
|
115
112
|
if (convertedNumberKeysToStrings) {
|
|
116
113
|
// Differentiating between the two types looks superfluous but is necessary for TSTL to produce
|
|
117
114
|
// the proper set method call.
|
|
118
|
-
if (
|
|
119
|
-
newDefaultMap.set(
|
|
115
|
+
if (isDefaultMap(newDefaultMap)) {
|
|
116
|
+
newDefaultMap.set(SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "");
|
|
120
117
|
// eslint-disable-next-line unicorn/no-duplicate-if-branches
|
|
121
118
|
}
|
|
122
119
|
else {
|
|
123
|
-
newDefaultMap.set(
|
|
120
|
+
newDefaultMap.set(SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "");
|
|
124
121
|
}
|
|
125
122
|
}
|
|
126
123
|
for (const [key, value] of entries) {
|
|
127
124
|
// Differentiating between the two types looks superfluous but is necessary for TSTL to produce
|
|
128
125
|
// the proper set method call.
|
|
129
|
-
if (
|
|
126
|
+
if (isDefaultMap(newDefaultMap)) {
|
|
130
127
|
newDefaultMap.set(key, value);
|
|
131
128
|
// eslint-disable-next-line unicorn/no-duplicate-if-branches
|
|
132
129
|
}
|
|
@@ -137,14 +134,14 @@ function deepCopyDefaultMap(defaultMap, serializationType, traversalDescription,
|
|
|
137
134
|
return newDefaultMap;
|
|
138
135
|
}
|
|
139
136
|
function deepCopyMap(map, serializationType, traversalDescription, classConstructors, insideMap) {
|
|
140
|
-
if (
|
|
141
|
-
|
|
137
|
+
if (SAVE_DATA_MANAGER_DEBUG) {
|
|
138
|
+
log("deepCopy is copying a Map.");
|
|
142
139
|
}
|
|
143
140
|
let newMap;
|
|
144
|
-
if (serializationType ===
|
|
141
|
+
if (serializationType === SerializationType.SERIALIZE) {
|
|
145
142
|
// Since we are serializing, the new object will be a Lua table.
|
|
146
143
|
newMap = new LuaMap();
|
|
147
|
-
newMap.set(
|
|
144
|
+
newMap.set(SerializationBrand.MAP, "");
|
|
148
145
|
}
|
|
149
146
|
else {
|
|
150
147
|
newMap = new Map();
|
|
@@ -154,18 +151,18 @@ function deepCopyMap(map, serializationType, traversalDescription, classConstruc
|
|
|
154
151
|
if (convertedNumberKeysToStrings) {
|
|
155
152
|
// Differentiating between the two types looks superfluous but is necessary for TSTL to produce
|
|
156
153
|
// the proper set method call.
|
|
157
|
-
if (
|
|
158
|
-
newMap.set(
|
|
154
|
+
if (isTSTLMap(newMap)) {
|
|
155
|
+
newMap.set(SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "");
|
|
159
156
|
// eslint-disable-next-line unicorn/no-duplicate-if-branches
|
|
160
157
|
}
|
|
161
158
|
else {
|
|
162
|
-
newMap.set(
|
|
159
|
+
newMap.set(SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "");
|
|
163
160
|
}
|
|
164
161
|
}
|
|
165
162
|
for (const [key, value] of entries) {
|
|
166
163
|
// Differentiating between the two types looks superfluous but is necessary for TSTL to produce
|
|
167
164
|
// the proper set method call.
|
|
168
|
-
if (
|
|
165
|
+
if (isTSTLMap(newMap)) {
|
|
169
166
|
newMap.set(key, value);
|
|
170
167
|
// eslint-disable-next-line unicorn/no-duplicate-if-branches
|
|
171
168
|
}
|
|
@@ -176,13 +173,13 @@ function deepCopyMap(map, serializationType, traversalDescription, classConstruc
|
|
|
176
173
|
return newMap;
|
|
177
174
|
}
|
|
178
175
|
function deepCopyNormalLuaTable(luaMap, serializationType, traversalDescription, classConstructors, insideMap) {
|
|
179
|
-
if (
|
|
180
|
-
|
|
176
|
+
if (SAVE_DATA_MANAGER_DEBUG) {
|
|
177
|
+
log("deepCopy is copying a normal Lua table.");
|
|
181
178
|
}
|
|
182
179
|
const newTable = new LuaMap();
|
|
183
180
|
const { entries, convertedNumberKeysToStrings } = getCopiedEntries(luaMap, serializationType, traversalDescription, classConstructors, insideMap);
|
|
184
181
|
if (convertedNumberKeysToStrings) {
|
|
185
|
-
newTable.set(
|
|
182
|
+
newTable.set(SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "");
|
|
186
183
|
}
|
|
187
184
|
for (const [key, value] of entries) {
|
|
188
185
|
newTable.set(key, value);
|
|
@@ -190,15 +187,15 @@ function deepCopyNormalLuaTable(luaMap, serializationType, traversalDescription,
|
|
|
190
187
|
return newTable;
|
|
191
188
|
}
|
|
192
189
|
function deepCopySet(set, serializationType, traversalDescription, classConstructors, insideMap) {
|
|
193
|
-
if (
|
|
194
|
-
|
|
190
|
+
if (SAVE_DATA_MANAGER_DEBUG) {
|
|
191
|
+
log("deepCopy is copying a Set.");
|
|
195
192
|
}
|
|
196
193
|
let newSet;
|
|
197
|
-
if (serializationType ===
|
|
194
|
+
if (serializationType === SerializationType.SERIALIZE) {
|
|
198
195
|
// For serialization purposes, we represent a `Set` as a table with keys that match the
|
|
199
196
|
// keys/values in the Set and values of an empty string.
|
|
200
197
|
newSet = new LuaMap();
|
|
201
|
-
newSet.set(
|
|
198
|
+
newSet.set(SerializationBrand.SET, "");
|
|
202
199
|
}
|
|
203
200
|
else {
|
|
204
201
|
newSet = new Set();
|
|
@@ -207,18 +204,18 @@ function deepCopySet(set, serializationType, traversalDescription, classConstruc
|
|
|
207
204
|
if (convertedNumberKeysToStrings) {
|
|
208
205
|
// Differentiating between the two types looks superfluous but is necessary for TSTL to produce
|
|
209
206
|
// the proper set method call.
|
|
210
|
-
if (
|
|
207
|
+
if (isTSTLSet(newSet)) {
|
|
211
208
|
// We should never be serializing an object of type `Set`.
|
|
212
209
|
error("The deep copy function cannot convert number keys to strings for a Set.");
|
|
213
210
|
}
|
|
214
211
|
else {
|
|
215
|
-
newSet.set(
|
|
212
|
+
newSet.set(SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "");
|
|
216
213
|
}
|
|
217
214
|
}
|
|
218
215
|
for (const [key] of entries) {
|
|
219
216
|
// Differentiating between the two types looks superfluous but is necessary for TSTL to produce
|
|
220
217
|
// the proper set method call.
|
|
221
|
-
if (
|
|
218
|
+
if (isTSTLSet(newSet)) {
|
|
222
219
|
newSet.add(key);
|
|
223
220
|
}
|
|
224
221
|
else {
|
|
@@ -229,62 +226,62 @@ function deepCopySet(set, serializationType, traversalDescription, classConstruc
|
|
|
229
226
|
}
|
|
230
227
|
function deepCopyTable(luaMap, serializationType, traversalDescription, classConstructors, insideMap) {
|
|
231
228
|
// First, handle the cases of TSTL classes or serialized TSTL classes.
|
|
232
|
-
if (
|
|
229
|
+
if (isDefaultMap(luaMap) || luaMap.has(SerializationBrand.DEFAULT_MAP)) {
|
|
233
230
|
return deepCopyDefaultMap(luaMap, serializationType, traversalDescription, classConstructors, insideMap);
|
|
234
231
|
}
|
|
235
|
-
if (
|
|
232
|
+
if (isTSTLMap(luaMap) || luaMap.has(SerializationBrand.MAP)) {
|
|
236
233
|
return deepCopyMap(luaMap, serializationType, traversalDescription, classConstructors, insideMap);
|
|
237
234
|
}
|
|
238
|
-
if (
|
|
235
|
+
if (isTSTLSet(luaMap) || luaMap.has(SerializationBrand.SET)) {
|
|
239
236
|
return deepCopySet(luaMap, serializationType, traversalDescription, classConstructors, insideMap);
|
|
240
237
|
}
|
|
241
|
-
const className =
|
|
238
|
+
const className = getTSTLClassName(luaMap);
|
|
242
239
|
if (className === "WeakMap" || className === "WeakSet") {
|
|
243
240
|
error(`The deep copy function does not support copying the "${className}" class for: ${traversalDescription}`);
|
|
244
241
|
}
|
|
245
|
-
if (className !== undefined || luaMap.has(
|
|
242
|
+
if (className !== undefined || luaMap.has(SerializationBrand.TSTL_CLASS)) {
|
|
246
243
|
return deepCopyTSTLClass(luaMap, serializationType, traversalDescription, classConstructors, insideMap);
|
|
247
244
|
}
|
|
248
245
|
// This is not a TSTL Map/Set/class. If it has a metatable, abort.
|
|
249
246
|
checkMetatable(luaMap, traversalDescription);
|
|
250
247
|
// Handle the special case of serialized Isaac API classes.
|
|
251
|
-
if (
|
|
252
|
-
&& serializationType ===
|
|
253
|
-
return
|
|
248
|
+
if (isSerializedIsaacAPIClass(luaMap)
|
|
249
|
+
&& serializationType === SerializationType.DESERIALIZE) {
|
|
250
|
+
return deserializeIsaacAPIClass(luaMap);
|
|
254
251
|
}
|
|
255
252
|
// Handle the special case of an array.
|
|
256
|
-
if (
|
|
253
|
+
if (isArray(luaMap)) {
|
|
257
254
|
return deepCopyArray(luaMap, serializationType, traversalDescription, classConstructors, insideMap);
|
|
258
255
|
}
|
|
259
256
|
// Base case: copy a normal Lua table
|
|
260
257
|
return deepCopyNormalLuaTable(luaMap, serializationType, traversalDescription, classConstructors, insideMap);
|
|
261
258
|
}
|
|
262
259
|
function deepCopyTSTLClass(tstlClass, serializationType, traversalDescription, classConstructors, insideMap) {
|
|
263
|
-
if (
|
|
264
|
-
|
|
260
|
+
if (SAVE_DATA_MANAGER_DEBUG) {
|
|
261
|
+
log("deepCopy is copying a TSTL class.");
|
|
265
262
|
}
|
|
266
263
|
let newClass;
|
|
267
264
|
switch (serializationType) {
|
|
268
|
-
case
|
|
265
|
+
case SerializationType.NONE: {
|
|
269
266
|
// We can use the class constructor from the old class.
|
|
270
|
-
newClass =
|
|
267
|
+
newClass = newTSTLClass(tstlClass);
|
|
271
268
|
break;
|
|
272
269
|
}
|
|
273
|
-
case
|
|
270
|
+
case SerializationType.SERIALIZE: {
|
|
274
271
|
newClass = new LuaMap();
|
|
275
272
|
// We brand it with the name of the class so that we can run the corresponding constructor
|
|
276
273
|
// during deserialization.
|
|
277
|
-
const tstlClassName =
|
|
274
|
+
const tstlClassName = getTSTLClassName(tstlClass);
|
|
278
275
|
if (tstlClassName !== undefined) {
|
|
279
|
-
newClass.set(
|
|
276
|
+
newClass.set(SerializationBrand.TSTL_CLASS, tstlClassName);
|
|
280
277
|
}
|
|
281
278
|
break;
|
|
282
279
|
}
|
|
283
|
-
case
|
|
284
|
-
const tstlClassName = tstlClass.get(
|
|
285
|
-
|
|
280
|
+
case SerializationType.DESERIALIZE: {
|
|
281
|
+
const tstlClassName = tstlClass.get(SerializationBrand.TSTL_CLASS);
|
|
282
|
+
assertDefined(tstlClassName, "Failed to deserialize a TSTL class since the brand did not contain the class name.");
|
|
286
283
|
const classConstructor = classConstructors.get(tstlClassName);
|
|
287
|
-
|
|
284
|
+
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.`);
|
|
288
285
|
// eslint-disable-next-line new-cap
|
|
289
286
|
newClass = new classConstructor();
|
|
290
287
|
break;
|
|
@@ -292,7 +289,7 @@ function deepCopyTSTLClass(tstlClass, serializationType, traversalDescription, c
|
|
|
292
289
|
}
|
|
293
290
|
const { entries, convertedNumberKeysToStrings } = getCopiedEntries(tstlClass, serializationType, traversalDescription, classConstructors, insideMap);
|
|
294
291
|
if (convertedNumberKeysToStrings) {
|
|
295
|
-
newClass.set(
|
|
292
|
+
newClass.set(SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "");
|
|
296
293
|
}
|
|
297
294
|
for (const [key, value] of entries) {
|
|
298
295
|
newClass.set(key, value);
|
|
@@ -301,18 +298,18 @@ function deepCopyTSTLClass(tstlClass, serializationType, traversalDescription, c
|
|
|
301
298
|
}
|
|
302
299
|
/** Isaac API classes are of type "userdata". End-user code cannot create userdata. */
|
|
303
300
|
function deepCopyUserdata(value, serializationType, traversalDescription) {
|
|
304
|
-
if (!
|
|
305
|
-
const className =
|
|
301
|
+
if (!isCopyableIsaacAPIClass(value)) {
|
|
302
|
+
const className = getIsaacAPIClassName(value) ?? "Unknown";
|
|
306
303
|
error(`The deep copy function does not support serializing "${traversalDescription}", since it is an Isaac API class of type: ${className}`);
|
|
307
304
|
}
|
|
308
305
|
switch (serializationType) {
|
|
309
|
-
case
|
|
310
|
-
return
|
|
306
|
+
case SerializationType.NONE: {
|
|
307
|
+
return copyIsaacAPIClass(value);
|
|
311
308
|
}
|
|
312
|
-
case
|
|
313
|
-
return
|
|
309
|
+
case SerializationType.SERIALIZE: {
|
|
310
|
+
return serializeIsaacAPIClass(value);
|
|
314
311
|
}
|
|
315
|
-
case
|
|
312
|
+
case SerializationType.DESERIALIZE: {
|
|
316
313
|
return error(`The deep copy function can not deserialize "${traversalDescription}", since it is userdata.`);
|
|
317
314
|
}
|
|
318
315
|
}
|
|
@@ -327,7 +324,7 @@ function getCopiedEntries(object, serializationType, traversalDescription, class
|
|
|
327
324
|
// First, shallow copy the entries. We cannot use "pairs" to iterate over a `Map` or `Set`. We
|
|
328
325
|
// cannot use "[...pairs(object)]", as it results in a run-time error.
|
|
329
326
|
const entries = [];
|
|
330
|
-
if (
|
|
327
|
+
if (isTSTLMap(object) || isTSTLSet(object) || isDefaultMap(object)) {
|
|
331
328
|
for (const [key, value] of object.entries()) {
|
|
332
329
|
entries.push([key, value]);
|
|
333
330
|
}
|
|
@@ -337,24 +334,24 @@ function getCopiedEntries(object, serializationType, traversalDescription, class
|
|
|
337
334
|
entries.push([key, value]);
|
|
338
335
|
}
|
|
339
336
|
}
|
|
340
|
-
if (
|
|
341
|
-
entries.sort(
|
|
337
|
+
if (SAVE_DATA_MANAGER_DEBUG) {
|
|
338
|
+
entries.sort(sortTwoDimensionalArray);
|
|
342
339
|
}
|
|
343
340
|
// During serialization, we brand some Lua tables with a special identifier to signify that it has
|
|
344
341
|
// keys that should be deserialized to numbers.
|
|
345
|
-
const convertStringKeysToNumbers = serializationType ===
|
|
346
|
-
&& entries.some(([key]) => key ===
|
|
347
|
-
const hasNumberKeys = entries.some(([key]) =>
|
|
348
|
-
const convertNumberKeysToStrings = serializationType ===
|
|
342
|
+
const convertStringKeysToNumbers = serializationType === SerializationType.DESERIALIZE
|
|
343
|
+
&& entries.some(([key]) => key === asString(SerializationBrand.OBJECT_WITH_NUMBER_KEYS));
|
|
344
|
+
const hasNumberKeys = entries.some(([key]) => isNumber(key));
|
|
345
|
+
const convertNumberKeysToStrings = serializationType === SerializationType.SERIALIZE && hasNumberKeys;
|
|
349
346
|
// Second, deep copy the entries.
|
|
350
347
|
const copiedEntries = [];
|
|
351
348
|
for (const [key, value] of entries) {
|
|
352
349
|
// When deserializing, we do not need to copy the serialization brands that are used to denote
|
|
353
350
|
// the object type.
|
|
354
|
-
if (
|
|
351
|
+
if (isSerializationBrand(key)) {
|
|
355
352
|
continue;
|
|
356
353
|
}
|
|
357
|
-
traversalDescription =
|
|
354
|
+
traversalDescription = getTraversalDescription(key, traversalDescription);
|
|
358
355
|
const newValue = deepCopy(value, serializationType, traversalDescription, classConstructors, insideMap);
|
|
359
356
|
let keyToUse = key;
|
|
360
357
|
if (convertStringKeysToNumbers) {
|
|
@@ -379,26 +376,26 @@ function getCopiedEntries(object, serializationType, traversalDescription, class
|
|
|
379
376
|
*/
|
|
380
377
|
function getNewDefaultMap(defaultMap, serializationType, traversalDescription, constructorArg) {
|
|
381
378
|
switch (serializationType) {
|
|
382
|
-
case
|
|
379
|
+
case SerializationType.NONE: {
|
|
383
380
|
// eslint-disable-next-line isaacscript/no-invalid-default-map
|
|
384
|
-
return new
|
|
381
|
+
return new DefaultMap(constructorArg);
|
|
385
382
|
}
|
|
386
|
-
case
|
|
383
|
+
case SerializationType.SERIALIZE: {
|
|
387
384
|
// Since we are serializing, the new object will be a Lua table. (At this point, we already
|
|
388
385
|
// handled the special case of a DefaultMap instantiated with a factory function.)
|
|
389
386
|
const newDefaultMap = new LuaMap();
|
|
390
|
-
newDefaultMap.set(
|
|
391
|
-
newDefaultMap.set(
|
|
387
|
+
newDefaultMap.set(SerializationBrand.DEFAULT_MAP, "");
|
|
388
|
+
newDefaultMap.set(SerializationBrand.DEFAULT_MAP_VALUE, constructorArg);
|
|
392
389
|
return newDefaultMap;
|
|
393
390
|
}
|
|
394
|
-
case
|
|
395
|
-
if (
|
|
391
|
+
case SerializationType.DESERIALIZE: {
|
|
392
|
+
if (isDefaultMap(defaultMap)) {
|
|
396
393
|
error(`Failed to deserialize a default map of "${traversalDescription}", since it was not a Lua table.`);
|
|
397
394
|
}
|
|
398
|
-
const defaultMapValue = defaultMap.get(
|
|
399
|
-
|
|
395
|
+
const defaultMapValue = defaultMap.get(SerializationBrand.DEFAULT_MAP_VALUE);
|
|
396
|
+
assertDefined(defaultMapValue, `Failed to deserialize a default map of "${traversalDescription}", since there was no serialization brand of: ${SerializationBrand.DEFAULT_MAP_VALUE}`);
|
|
400
397
|
// eslint-disable-next-line isaacscript/no-invalid-default-map
|
|
401
|
-
return new
|
|
398
|
+
return new DefaultMap(defaultMapValue);
|
|
402
399
|
}
|
|
403
400
|
}
|
|
404
401
|
}
|