isaacscript-common 1.2.123 → 1.2.126

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.
@@ -5,8 +5,8 @@ local ____exports = {}
5
5
  local hasSubscriptions, postPEffectUpdateReordered, queueEmpty, queueNotEmpty, v
6
6
  local ____exports = require("features.saveDataManager.exports")
7
7
  local saveDataManager = ____exports.saveDataManager
8
- local ____player = require("functions.player")
9
- local getPlayerIndex = ____player.getPlayerIndex
8
+ local ____playerDataStructures = require("functions.playerDataStructures")
9
+ local defaultMapGetPlayer = ____playerDataStructures.defaultMapGetPlayer
10
10
  local ____DefaultMap = require("types.DefaultMap")
11
11
  local DefaultMap = ____DefaultMap.DefaultMap
12
12
  local ____ModCallbacksCustom = require("types.ModCallbacksCustom")
@@ -27,8 +27,7 @@ function postPEffectUpdateReordered(self, player)
27
27
  if not hasSubscriptions(nil) then
28
28
  return
29
29
  end
30
- local playerIndex = getPlayerIndex(nil, player)
31
- local pickingUpItem = v.run.playerPickingUpItemMap:getAndSetDefault(playerIndex)
30
+ local pickingUpItem = defaultMapGetPlayer(nil, v.run.playersPickingUpItemMap, player)
32
31
  if player:IsItemQueueEmpty() then
33
32
  queueEmpty(nil, player, pickingUpItem)
34
33
  else
@@ -53,7 +52,7 @@ function queueNotEmpty(self, player, pickingUpItem)
53
52
  preItemPickupFire(nil, player, pickingUpItem)
54
53
  end
55
54
  end
56
- v = {run = {playerPickingUpItemMap = __TS__New(
55
+ v = {run = {playersPickingUpItemMap = __TS__New(
57
56
  DefaultMap,
58
57
  function() return newPickingUpItem(nil) end
59
58
  )}}
@@ -9,8 +9,10 @@ local saveDataManager = ____exports.saveDataManager
9
9
  local ____flag = require("functions.flag")
10
10
  local hasFlag = ____flag.hasFlag
11
11
  local ____player = require("functions.player")
12
- local getPlayerIndex = ____player.getPlayerIndex
13
12
  local getPlayerNumHitsRemaining = ____player.getPlayerNumHitsRemaining
13
+ local ____playerDataStructures = require("functions.playerDataStructures")
14
+ local mapGetPlayer = ____playerDataStructures.mapGetPlayer
15
+ local mapSetPlayer = ____playerDataStructures.mapSetPlayer
14
16
  local ____postCursedTeleport = require("callbacks.subscriptions.postCursedTeleport")
15
17
  local postCursedTeleportFire = ____postCursedTeleport.postCursedTeleportFire
16
18
  local postCursedTeleportHasSubscriptions = ____postCursedTeleport.postCursedTeleportHasSubscriptions
@@ -31,8 +33,7 @@ function setDamageFrame(self, tookDamage, damageFlags)
31
33
  if player == nil then
32
34
  return
33
35
  end
34
- local playerIndex = getPlayerIndex(nil, player)
35
- local trackingArray = v.run.damageFrameMap:get(playerIndex)
36
+ local trackingArray = mapGetPlayer(nil, v.run.playersDamageFrameMap, player)
36
37
  if trackingArray ~= nil then
37
38
  local lastDamageFrame, callbackFiredOnThisFrame = table.unpack(trackingArray)
38
39
  if lastDamageFrame == gameFrameCount and callbackFiredOnThisFrame then
@@ -42,7 +43,8 @@ function setDamageFrame(self, tookDamage, damageFlags)
42
43
  if isPotentialNaturalTeleportFromSacrificeRoom(nil, damageFlags) then
43
44
  return
44
45
  end
45
- v.run.damageFrameMap:set(playerIndex, {gameFrameCount, false})
46
+ local newTrackingArray = {gameFrameCount, false}
47
+ mapSetPlayer(nil, v.run.playersDamageFrameMap, player, newTrackingArray)
46
48
  end
47
49
  function isPotentialNaturalTeleportFromSacrificeRoom(self, damageFlags)
48
50
  local game = Game()
@@ -65,10 +67,7 @@ function postPlayerRenderPlayer(self, player)
65
67
  if not hasSubscriptions(nil) then
66
68
  return
67
69
  end
68
- local game = Game()
69
- local gameFrameCount = game:GetFrameCount()
70
- local playerIndex = getPlayerIndex(nil, player)
71
- local trackingArray = v.run.damageFrameMap:get(playerIndex)
70
+ local trackingArray = mapGetPlayer(nil, v.run.playersDamageFrameMap, player)
72
71
  if trackingArray == nil then
73
72
  return
74
73
  end
@@ -79,7 +78,10 @@ function postPlayerRenderPlayer(self, player)
79
78
  if callbackActivatedOnThisFrame then
80
79
  return
81
80
  end
82
- v.run.damageFrameMap:set(playerIndex, {gameFrameCount, true})
81
+ local game = Game()
82
+ local gameFrameCount = game:GetFrameCount()
83
+ local newTrackingArray = {gameFrameCount, true}
84
+ mapSetPlayer(nil, v.run.playersDamageFrameMap, player, newTrackingArray)
83
85
  postCursedTeleportFire(nil, player)
84
86
  end
85
87
  function playerIsTeleportingFromCursedTeleport(self, player, lastDamageFrame)
@@ -102,7 +104,7 @@ function playerIsTeleportingFromCursedTeleport(self, player, lastDamageFrame)
102
104
  return false
103
105
  end
104
106
  v = {
105
- run = {damageFrameMap = __TS__New(Map)},
107
+ run = {playersDamageFrameMap = __TS__New(Map)},
106
108
  level = {numSacrifices = 0}
107
109
  }
108
110
  function ____exports.postCursedTeleportCallbackInit(self, mod)
@@ -1,13 +1,15 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____lualib = require("lualib_bundle")
3
- local Map = ____lualib.Map
4
3
  local __TS__New = ____lualib.__TS__New
5
4
  local ____exports = {}
6
5
  local hasSubscriptions, postPEffectUpdateReordered, v
7
6
  local ____exports = require("features.saveDataManager.exports")
8
7
  local saveDataManager = ____exports.saveDataManager
9
- local ____player = require("functions.player")
10
- local getPlayerIndex = ____player.getPlayerIndex
8
+ local ____playerDataStructures = require("functions.playerDataStructures")
9
+ local defaultMapGetPlayer = ____playerDataStructures.defaultMapGetPlayer
10
+ local mapSetPlayer = ____playerDataStructures.mapSetPlayer
11
+ local ____DefaultMap = require("types.DefaultMap")
12
+ local DefaultMap = ____DefaultMap.DefaultMap
11
13
  local ____ModCallbacksCustom = require("types.ModCallbacksCustom")
12
14
  local ModCallbacksCustom = ____ModCallbacksCustom.ModCallbacksCustom
13
15
  local ____postPlayerChangeType = require("callbacks.subscriptions.postPlayerChangeType")
@@ -21,18 +23,16 @@ function postPEffectUpdateReordered(self, player)
21
23
  return
22
24
  end
23
25
  local character = player:GetPlayerType()
24
- local playerIndex = getPlayerIndex(nil, player)
25
- local storedCharacter = v.run.characterMap:get(playerIndex)
26
- if storedCharacter == nil then
27
- v.run.characterMap:set(playerIndex, character)
28
- return
29
- end
26
+ local storedCharacter = defaultMapGetPlayer(nil, v.run.playersCharacterMap, player, character)
30
27
  if character ~= storedCharacter then
31
- v.run.characterMap:set(playerIndex, character)
28
+ mapSetPlayer(nil, v.run.playersCharacterMap, player, character)
32
29
  postPlayerChangeTypeFire(nil, player, storedCharacter, character)
33
30
  end
34
31
  end
35
- v = {run = {characterMap = __TS__New(Map)}}
32
+ v = {run = {playersCharacterMap = __TS__New(
33
+ DefaultMap,
34
+ function(____, _key, character) return character end
35
+ )}}
36
36
  function ____exports.postPlayerChangeTypeCallbackInit(self, mod)
37
37
  saveDataManager(nil, "postPlayerChangeType", v, hasSubscriptions)
38
38
  mod:AddCallbackCustom(ModCallbacksCustom.MC_POST_PEFFECT_UPDATE_REORDERED, postPEffectUpdateReordered)
@@ -6,8 +6,10 @@ local hasSubscriptions, entityTakeDmgPlayer, v
6
6
  local ____exports = require("features.saveDataManager.exports")
7
7
  local saveDataManager = ____exports.saveDataManager
8
8
  local ____player = require("functions.player")
9
- local getPlayerIndex = ____player.getPlayerIndex
10
9
  local isChildPlayer = ____player.isChildPlayer
10
+ local ____playerDataStructures = require("functions.playerDataStructures")
11
+ local defaultMapGetPlayer = ____playerDataStructures.defaultMapGetPlayer
12
+ local mapSetPlayer = ____playerDataStructures.mapSetPlayer
11
13
  local ____revive = require("functions.revive")
12
14
  local isDamageToPlayerFatal = ____revive.isDamageToPlayerFatal
13
15
  local willPlayerRevive = ____revive.willPlayerRevive
@@ -32,8 +34,8 @@ function entityTakeDmgPlayer(self, tookDamage, damageAmount, damageFlags, damage
32
34
  end
33
35
  local game = Game()
34
36
  local gameFrameCount = game:GetFrameCount()
35
- local playerIndex = getPlayerIndex(nil, player)
36
- local lastDamageGameFrame = v.run.playersLastDamageGameFrame:getAndSetDefault(playerIndex, gameFrameCount)
37
+ local lastDamageGameFrame = defaultMapGetPlayer(nil, v.run.playersLastDamageGameFrame, player)
38
+ mapSetPlayer(nil, v.run.playersLastDamageGameFrame, player, gameFrameCount)
37
39
  if willPlayerRevive(nil, player) then
38
40
  return nil
39
41
  end
@@ -59,10 +61,7 @@ function entityTakeDmgPlayer(self, tookDamage, damageAmount, damageFlags, damage
59
61
  end
60
62
  return nil
61
63
  end
62
- v = {run = {playersLastDamageGameFrame = __TS__New(
63
- DefaultMap,
64
- function(____, _key, gameFrameCount) return gameFrameCount end
65
- )}}
64
+ v = {run = {playersLastDamageGameFrame = __TS__New(DefaultMap, nil)}}
66
65
  function ____exports.postPlayerFatalDamageCallbackInit(self, mod)
67
66
  saveDataManager(nil, "postPlayerFatalDamage", v)
68
67
  mod:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, entityTakeDmgPlayer, EntityType.ENTITY_PLAYER)
@@ -6,8 +6,9 @@ local ____exports = {}
6
6
  local hasSubscriptions, postPlayerUpdate, v
7
7
  local ____exports = require("features.saveDataManager.exports")
8
8
  local saveDataManager = ____exports.saveDataManager
9
- local ____player = require("functions.player")
10
- local getPlayerIndex = ____player.getPlayerIndex
9
+ local ____playerDataStructures = require("functions.playerDataStructures")
10
+ local setAddPlayer = ____playerDataStructures.setAddPlayer
11
+ local setHasPlayer = ____playerDataStructures.setHasPlayer
11
12
  local ____postPlayerInitLate = require("callbacks.subscriptions.postPlayerInitLate")
12
13
  local postPlayerInitLateFire = ____postPlayerInitLate.postPlayerInitLateFire
13
14
  local postPlayerInitLateHasSubscriptions = ____postPlayerInitLate.postPlayerInitLateHasSubscriptions
@@ -18,13 +19,12 @@ function postPlayerUpdate(self, player)
18
19
  if not hasSubscriptions(nil) then
19
20
  return
20
21
  end
21
- local playerIndex = getPlayerIndex(nil, player)
22
- if not v.run.firedSet:has(playerIndex) then
23
- v.run.firedSet:add(playerIndex)
22
+ if not setHasPlayer(nil, v.run.playersFiredSet, player) then
23
+ setAddPlayer(nil, v.run.playersFiredSet, player)
24
24
  postPlayerInitLateFire(nil, player)
25
25
  end
26
26
  end
27
- v = {run = {firedSet = __TS__New(Set)}}
27
+ v = {run = {playersFiredSet = __TS__New(Set)}}
28
28
  function ____exports.postPlayerInitLateCallbackInit(self, mod)
29
29
  saveDataManager(nil, "postPlayerInitLate", v, hasSubscriptions)
30
30
  mod:AddCallback(ModCallbacks.MC_POST_PLAYER_UPDATE, postPlayerUpdate)
@@ -8,8 +8,9 @@ local ____exports = require("features.saveDataManager.exports")
8
8
  local saveDataManager = ____exports.saveDataManager
9
9
  local ____pickups = require("functions.pickups")
10
10
  local getPickups = ____pickups.getPickups
11
- local ____player = require("functions.player")
12
- local getPlayerIndex = ____player.getPlayerIndex
11
+ local ____playerDataStructures = require("functions.playerDataStructures")
12
+ local defaultMapGetPlayer = ____playerDataStructures.defaultMapGetPlayer
13
+ local mapSetPlayer = ____playerDataStructures.mapSetPlayer
13
14
  local ____DefaultMap = require("types.DefaultMap")
14
15
  local DefaultMap = ____DefaultMap.DefaultMap
15
16
  local ____postPurchase = require("callbacks.subscriptions.postPurchase")
@@ -23,9 +24,8 @@ function postPEffectUpdate(self, player)
23
24
  return
24
25
  end
25
26
  local isHoldingItem = player:IsHoldingItem()
26
- local playerIndex = getPlayerIndex(nil, player)
27
- local wasHoldingItemOnLastFrame = v.room.playersHoldingItemOnLastFrameMap:getAndSetDefault(playerIndex)
28
- v.room.playersHoldingItemOnLastFrameMap:set(playerIndex, isHoldingItem)
27
+ local wasHoldingItemOnLastFrame = defaultMapGetPlayer(nil, v.room.playersHoldingItemOnLastFrameMap, player)
28
+ mapSetPlayer(nil, v.room.playersHoldingItemOnLastFrameMap, player, isHoldingItem)
29
29
  if not wasHoldingItemOnLastFrame and isHoldingItem then
30
30
  playerPickedUpNewItem(nil, player)
31
31
  end
@@ -9,8 +9,8 @@ local ____exports = require("features.saveDataManager.exports")
9
9
  local saveDataManager = ____exports.saveDataManager
10
10
  local ____math = require("functions.math")
11
11
  local range = ____math.range
12
- local ____player = require("functions.player")
13
- local getPlayerIndex = ____player.getPlayerIndex
12
+ local ____playerDataStructures = require("functions.playerDataStructures")
13
+ local defaultMapGetPlayer = ____playerDataStructures.defaultMapGetPlayer
14
14
  local ____DefaultMap = require("types.DefaultMap")
15
15
  local DefaultMap = ____DefaultMap.DefaultMap
16
16
  local ____ModCallbacksCustom = require("types.ModCallbacksCustom")
@@ -25,8 +25,7 @@ function postPEffectUpdateReordered(self, player)
25
25
  if not hasSubscriptions(nil) then
26
26
  return
27
27
  end
28
- local playerIndex = getPlayerIndex(nil, player)
29
- local playerTransformationsMap = v.run.playersTransformationsMap:getAndSetDefault(playerIndex)
28
+ local playerTransformationsMap = defaultMapGetPlayer(nil, v.run.playersTransformationsMap, player)
30
29
  for ____, playerForm in ipairs(VALID_TRANSFORMATIONS) do
31
30
  local hasForm = player:HasPlayerForm(playerForm)
32
31
  local storedForm = playerTransformationsMap:getAndSetDefault(playerForm)
@@ -5,8 +5,8 @@ local ____exports = {}
5
5
  local hasSubscriptions, entityTakeDmgPlayer, postPEffectUpdateReordered, TRINKETS_THAT_CAN_BREAK, v
6
6
  local ____exports = require("features.saveDataManager.exports")
7
7
  local saveDataManager = ____exports.saveDataManager
8
- local ____player = require("functions.player")
9
- local getPlayerIndex = ____player.getPlayerIndex
8
+ local ____playerDataStructures = require("functions.playerDataStructures")
9
+ local defaultMapGetPlayer = ____playerDataStructures.defaultMapGetPlayer
10
10
  local ____DefaultMap = require("types.DefaultMap")
11
11
  local DefaultMap = ____DefaultMap.DefaultMap
12
12
  local ____ModCallbacksCustom = require("types.ModCallbacksCustom")
@@ -25,8 +25,7 @@ function entityTakeDmgPlayer(self, tookDamage, _damageAmount, _damageFlags, _dam
25
25
  if player == nil then
26
26
  return
27
27
  end
28
- local playerIndex = getPlayerIndex(nil, player)
29
- local trinketMap = v.run.playersTrinketMap:getAndSetDefault(playerIndex)
28
+ local trinketMap = defaultMapGetPlayer(nil, v.run.playersTrinketMap, player)
30
29
  for ____, trinketType in ipairs(TRINKETS_THAT_CAN_BREAK) do
31
30
  do
32
31
  local numTrinketsHeld = player:GetTrinketMultiplier(trinketType)
@@ -48,8 +47,7 @@ function postPEffectUpdateReordered(self, player)
48
47
  if not hasSubscriptions(nil) then
49
48
  return
50
49
  end
51
- local playerIndex = getPlayerIndex(nil, player)
52
- local trinketMap = v.run.playersTrinketMap:getAndSetDefault(playerIndex)
50
+ local trinketMap = defaultMapGetPlayer(nil, v.run.playersTrinketMap, player)
53
51
  for ____, trinketType in ipairs(TRINKETS_THAT_CAN_BREAK) do
54
52
  local numTrinkets = player:GetTrinketMultiplier(trinketType)
55
53
  trinketMap:set(trinketType, numTrinkets)
@@ -63,7 +63,6 @@ export declare const FINAL_STAGE: number;
63
63
  * second TMTRAINER item subtracts one from that, and so on.
64
64
  */
65
65
  export declare const FIRST_GLITCHED_COLLECTIBLE_TYPE: number;
66
- export declare const GOLDEN_TRINKET_SHIFT: number;
67
66
  export declare const GRID_INDEX_CENTER_OF_1X1_ROOM = 67;
68
67
  export declare const GAME_FRAMES_PER_SECOND = 30;
69
68
  export declare const ISAAC_FRAMES_PER_SECOND = 60;
@@ -105,8 +104,36 @@ export declare const NUM_DIMENSIONS = 3;
105
104
  export declare const SECOND_IN_MILLISECONDS = 1000;
106
105
  export declare const MINUTE_IN_MILLISECONDS: number;
107
106
  export declare const ONE_BY_ONE_ROOM_GRID_SIZE = 135;
107
+ /**
108
+ * In vanilla, this is part of the `PillColor` enum, but we implement it as a constant in
109
+ * IsaacScript since it is not a real pill color.
110
+ *
111
+ * 1 << 11
112
+ */
113
+ export declare const PILL_GIANT_FLAG = 2048;
114
+ /**
115
+ * In vanilla, this is part of the `PillColor` enum, but we implement it as a constant in
116
+ * IsaacScript since it is not a real pill color.
117
+ *
118
+ * (1 << 11) - 1
119
+ */
120
+ export declare const PILL_COLOR_MASK = 2047;
108
121
  export declare const SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES: ReadonlySet<CollectibleType>;
109
122
  export declare const STORY_BOSSES: ReadonlySet<EntityType>;
123
+ /**
124
+ * In vanilla, this is part of the `TrinketType` enum, but we implement it as a constant in
125
+ * IsaacScript since it is not a real trinket type.
126
+ *
127
+ * 1 << 15
128
+ */
129
+ export declare const TRINKET_GOLDEN_FLAG = 32768;
130
+ /**
131
+ * In vanilla, this is part of the `TrinketType` enum, but we implement it as a constant in
132
+ * IsaacScript since it is not a real trinket type.
133
+ *
134
+ * (1 << 15) - 1
135
+ */
136
+ export declare const TRINKET_ID_MASK = 32767;
110
137
  /**
111
138
  * This is the number of draw coordinates that each heart spans on the UI in the upper left hand
112
139
  * corner.
@@ -79,7 +79,6 @@ ____exports.FAMILIARS_THAT_SHOOT_PLAYER_TEARS = __TS__New(Set, {
79
79
  })
80
80
  ____exports.FINAL_STAGE = LevelStage.NUM_STAGES - 1
81
81
  ____exports.FIRST_GLITCHED_COLLECTIBLE_TYPE = (1 << 32) - 1
82
- ____exports.GOLDEN_TRINKET_SHIFT = 1 << 15
83
82
  ____exports.GRID_INDEX_CENTER_OF_1X1_ROOM = 67
84
83
  ____exports.GAME_FRAMES_PER_SECOND = 30
85
84
  ____exports.ISAAC_FRAMES_PER_SECOND = 60
@@ -104,6 +103,8 @@ ____exports.NUM_DIMENSIONS = 3
104
103
  ____exports.SECOND_IN_MILLISECONDS = 1000
105
104
  ____exports.MINUTE_IN_MILLISECONDS = 60 * ____exports.SECOND_IN_MILLISECONDS
106
105
  ____exports.ONE_BY_ONE_ROOM_GRID_SIZE = 135
106
+ ____exports.PILL_GIANT_FLAG = 2048
107
+ ____exports.PILL_COLOR_MASK = 2047
107
108
  ____exports.SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES = __TS__New(Set, {
108
109
  CollectibleType.COLLECTIBLE_FORGET_ME_NOW,
109
110
  CollectibleType.COLLECTIBLE_EDENS_SOUL,
@@ -129,5 +130,7 @@ ____exports.STORY_BOSSES = __TS__New(Set, {
129
130
  EntityType.ENTITY_DOGMA,
130
131
  EntityType.ENTITY_BEAST
131
132
  })
133
+ ____exports.TRINKET_GOLDEN_FLAG = 32768
134
+ ____exports.TRINKET_ID_MASK = 32767
132
135
  ____exports.UI_HEART_WIDTH = 12
133
136
  return ____exports
@@ -8,16 +8,17 @@ local ____errors = require("errors")
8
8
  local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
9
9
  local ____flag = require("functions.flag")
10
10
  local hasFlag = ____flag.hasFlag
11
- local ____player = require("functions.player")
12
- local getPlayerIndex = ____player.getPlayerIndex
11
+ local ____playerDataStructures = require("functions.playerDataStructures")
12
+ local setAddPlayer = ____playerDataStructures.setAddPlayer
13
+ local setDeletePlayer = ____playerDataStructures.setDeletePlayer
14
+ local setHasPlayer = ____playerDataStructures.setHasPlayer
13
15
  local ____exports = require("features.saveDataManager.exports")
14
16
  local saveDataManager = ____exports.saveDataManager
15
17
  function postPEffectUpdate(self, player)
16
18
  local effects = player:GetEffects()
17
19
  local entityFlags = player:GetEntityFlags()
18
20
  local hasPonyCollectibleEffect = effects:HasCollectibleEffect(CollectibleType.COLLECTIBLE_PONY) or effects:HasCollectibleEffect(CollectibleType.COLLECTIBLE_WHITE_PONY)
19
- local playerIndex = getPlayerIndex(nil, player)
20
- local isPonyActiveOnPreviousFrame = v.run.playersIsPonyActive:has(playerIndex)
21
+ local isPonyActiveOnPreviousFrame = setHasPlayer(nil, v.run.playersIsPonyActive, player)
21
22
  local hasPonyFlags = hasFlag(
22
23
  nil,
23
24
  entityFlags,
@@ -25,9 +26,9 @@ function postPEffectUpdate(self, player)
25
26
  )
26
27
  local isPonyActiveNow = hasPonyCollectibleEffect or isPonyActiveOnPreviousFrame and hasPonyFlags
27
28
  if isPonyActiveNow then
28
- v.run.playersIsPonyActive:add(playerIndex)
29
+ setAddPlayer(nil, v.run.playersIsPonyActive, player)
29
30
  else
30
- v.run.playersIsPonyActive:delete(playerIndex)
31
+ setDeletePlayer(nil, v.run.playersIsPonyActive, player)
31
32
  end
32
33
  end
33
34
  local FEATURE_NAME = "pony activation detector"
@@ -44,7 +45,6 @@ function ____exports.isPonyActive(self, player)
44
45
  local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
45
46
  error(msg)
46
47
  end
47
- local playerIndex = getPlayerIndex(nil, player)
48
- return v.run.playersIsPonyActive:has(playerIndex)
48
+ return setHasPlayer(nil, v.run.playersIsPonyActive, player)
49
49
  end
50
50
  return ____exports
@@ -1,20 +1,8 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
- import { DefaultMap } from "../types/DefaultMap";
3
- import { PlayerIndex } from "../types/PlayerIndex";
4
2
  /** Helper function to copy a map. (You can also use a Map constructor to accomplish this task.) */
5
3
  export declare function copyMap<K, V>(oldMap: Map<K, V>): Map<K, V>;
6
4
  /**
7
- * Helper function to make using default maps with an index of `PlayerIndex` easier. Use this
8
- * instead of the `DefaultMap.getAndSetDefault` method.
5
+ * Helper function to make using map with `Seed` values easier. Use this instead of manually getting
6
+ * the current value, incrementing it, and then re-setting it.
9
7
  */
10
- export declare function defaultMapGetPlayer<V>(map: DefaultMap<PlayerIndex, V>, player: EntityPlayer): V | undefined;
11
- /**
12
- * Helper function to make using maps with an index of `PlayerIndex` easier. Use this instead of the
13
- * `Map.get` method.
14
- */
15
- export declare function mapGetPlayer<V>(map: Map<PlayerIndex, V>, player: EntityPlayer): V | undefined;
16
- /**
17
- * Helper function to make using maps with an index of `PlayerIndex` easier. Use this instead of the
18
- * `Map.set` method.
19
- */
20
- export declare function mapSetPlayer<V>(map: Map<PlayerIndex, V>, player: EntityPlayer, value: V): void;
8
+ export declare function mapGetNextSeed<K>(map: Map<K, Seed>, key: K): Seed | undefined;
@@ -4,8 +4,8 @@ local Map = ____lualib.Map
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local __TS__Iterator = ____lualib.__TS__Iterator
6
6
  local ____exports = {}
7
- local ____player = require("functions.player")
8
- local getPlayerIndex = ____player.getPlayerIndex
7
+ local ____random = require("functions.random")
8
+ local nextSeed = ____random.nextSeed
9
9
  function ____exports.copyMap(self, oldMap)
10
10
  local newMap = __TS__New(Map)
11
11
  for ____, ____value in __TS__Iterator(oldMap:entries()) do
@@ -15,16 +15,16 @@ function ____exports.copyMap(self, oldMap)
15
15
  end
16
16
  return newMap
17
17
  end
18
- function ____exports.defaultMapGetPlayer(self, map, player)
19
- local playerIndex = getPlayerIndex(nil, player)
20
- return map:getAndSetDefault(playerIndex)
21
- end
22
- function ____exports.mapGetPlayer(self, map, player)
23
- local playerIndex = getPlayerIndex(nil, player)
24
- return map:get(playerIndex)
25
- end
26
- function ____exports.mapSetPlayer(self, map, player, value)
27
- local playerIndex = getPlayerIndex(nil, player)
28
- map:set(playerIndex, value)
18
+ function ____exports.mapGetNextSeed(self, map, key)
19
+ local seed = map:get(key)
20
+ if seed == nil then
21
+ return nil
22
+ end
23
+ if seed == 0 then
24
+ error("The seed map had a value of 0 for the key of: " .. tostring(key))
25
+ end
26
+ local newSeed = nextSeed(nil, seed)
27
+ map:set(key, newSeed)
28
+ return newSeed
29
29
  end
30
30
  return ____exports
@@ -0,0 +1,33 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ import { DefaultMap } from "../types/DefaultMap";
3
+ import { PlayerIndex } from "../types/PlayerIndex";
4
+ /**
5
+ * Helper function to make using default maps with an index of `PlayerIndex` easier. Use this
6
+ * instead of the `DefaultMap.getAndSetDefault` method if you have a default map of this type.
7
+ */
8
+ export declare function defaultMapGetPlayer<V, A extends unknown[]>(map: DefaultMap<PlayerIndex, V, A>, player: EntityPlayer, ...extraArgs: A): V;
9
+ /**
10
+ * Helper function to make using maps with an index of `PlayerIndex` easier. Use this instead of the
11
+ * `Map.get` method if you have a map of this type.
12
+ */
13
+ export declare function mapGetPlayer<V>(map: Map<PlayerIndex, V>, player: EntityPlayer): V | undefined;
14
+ /**
15
+ * Helper function to make using maps with an index of `PlayerIndex` easier. Use this instead of the
16
+ * `Map.set` method if you have a map of this type.
17
+ */
18
+ export declare function mapSetPlayer<V>(map: Map<PlayerIndex, V>, player: EntityPlayer, value: V): void;
19
+ /**
20
+ * Helper function to make using sets with an type of `PlayerIndex` easier. Use this instead of the
21
+ * `Set.add` method if you have a set of this type.
22
+ */
23
+ export declare function setAddPlayer(set: Set<PlayerIndex>, player: EntityPlayer): Set<PlayerIndex>;
24
+ /**
25
+ * Helper function to make using sets with an type of `PlayerIndex` easier. Use this instead of the
26
+ * `Set.delete` method if you have a set of this type.
27
+ */
28
+ export declare function setDeletePlayer(set: Set<PlayerIndex>, player: EntityPlayer): boolean;
29
+ /**
30
+ * Helper function to make using sets with an type of `PlayerIndex` easier. Use this instead of the
31
+ * `Set.has` method if you have a set of this type.
32
+ */
33
+ export declare function setHasPlayer(set: Set<PlayerIndex>, player: EntityPlayer): boolean;
@@ -0,0 +1,32 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____lualib = require("lualib_bundle")
3
+ local Map = ____lualib.Map
4
+ local Set = ____lualib.Set
5
+ local ____exports = {}
6
+ local ____player = require("functions.player")
7
+ local getPlayerIndex = ____player.getPlayerIndex
8
+ function ____exports.defaultMapGetPlayer(self, map, player, ...)
9
+ local playerIndex = getPlayerIndex(nil, player)
10
+ return map:getAndSetDefault(playerIndex, ...)
11
+ end
12
+ function ____exports.mapGetPlayer(self, map, player)
13
+ local playerIndex = getPlayerIndex(nil, player)
14
+ return map:get(playerIndex)
15
+ end
16
+ function ____exports.mapSetPlayer(self, map, player, value)
17
+ local playerIndex = getPlayerIndex(nil, player)
18
+ map:set(playerIndex, value)
19
+ end
20
+ function ____exports.setAddPlayer(self, set, player)
21
+ local playerIndex = getPlayerIndex(nil, player)
22
+ return set:add(playerIndex)
23
+ end
24
+ function ____exports.setDeletePlayer(self, set, player)
25
+ local playerIndex = getPlayerIndex(nil, player)
26
+ return set:delete(playerIndex)
27
+ end
28
+ function ____exports.setHasPlayer(self, set, player)
29
+ local playerIndex = getPlayerIndex(nil, player)
30
+ return set:has(playerIndex)
31
+ end
32
+ return ____exports
@@ -3,7 +3,7 @@
3
3
  * Uses the player's current health and other miscellaneous things to determine if incoming damage
4
4
  * will be fatal.
5
5
  */
6
- export declare function isDamageToPlayerFatal(player: EntityPlayer, damageAmount: int, damageSource: EntityRef, lastDamageGameFrame: int): boolean;
6
+ export declare function isDamageToPlayerFatal(player: EntityPlayer, damageAmount: int, damageSource: EntityRef, lastDamageGameFrame: int | null): boolean;
7
7
  /**
8
8
  * The `EntityPlayer.WillPlayerRevive()` function does not properly account for Mysterious Paper, so
9
9
  * use this helper function instead for more robust revival detection.
@@ -1,7 +1,7 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
3
  local ____constants = require("constants")
4
- local GOLDEN_TRINKET_SHIFT = ____constants.GOLDEN_TRINKET_SHIFT
4
+ local TRINKET_GOLDEN_FLAG = ____constants.TRINKET_GOLDEN_FLAG
5
5
  local ____player = require("functions.player")
6
6
  local useActiveItemTemp = ____player.useActiveItemTemp
7
7
  local ____utils = require("functions.utils")
@@ -18,11 +18,11 @@ function ____exports.temporarilyRemoveTrinket(self, player, trinketType)
18
18
  numTrinkets = numTrinkets + 1
19
19
  end
20
20
  local numSmeltedTrinkets = numTrinkets
21
- local trinketWasInSlot1 = trinket1 == trinketType or trinket1 + GOLDEN_TRINKET_SHIFT == trinketType
21
+ local trinketWasInSlot1 = trinket1 == trinketType or trinket1 + TRINKET_GOLDEN_FLAG == trinketType
22
22
  if trinketWasInSlot1 then
23
23
  numSmeltedTrinkets = numSmeltedTrinkets - 1
24
24
  end
25
- local trinketWasInSlot2 = trinket2 == trinketType or trinket2 + GOLDEN_TRINKET_SHIFT == trinketType
25
+ local trinketWasInSlot2 = trinket2 == trinketType or trinket2 + TRINKET_GOLDEN_FLAG == trinketType
26
26
  if trinketWasInSlot2 then
27
27
  numSmeltedTrinkets = numSmeltedTrinkets - 1
28
28
  end
@@ -1,7 +1,7 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
3
  local ____constants = require("constants")
4
- local GOLDEN_TRINKET_SHIFT = ____constants.GOLDEN_TRINKET_SHIFT
4
+ local TRINKET_GOLDEN_FLAG = ____constants.TRINKET_GOLDEN_FLAG
5
5
  local ____trinketDescriptionMap = require("maps.trinketDescriptionMap")
6
6
  local TRINKET_DESCRIPTION_MAP = ____trinketDescriptionMap.TRINKET_DESCRIPTION_MAP
7
7
  local ____trinketNameMap = require("maps.trinketNameMap")
@@ -83,7 +83,7 @@ function ____exports.hasOpenTrinketSlot(self, player)
83
83
  return openTrinketSlot ~= nil
84
84
  end
85
85
  function ____exports.isGoldenTrinket(self, trinketType)
86
- return trinketType > GOLDEN_TRINKET_SHIFT
86
+ return trinketType > TRINKET_GOLDEN_FLAG
87
87
  end
88
88
  function ____exports.smeltTrinket(self, player, trinketType, numTrinkets)
89
89
  if numTrinkets == nil then
package/dist/index.d.ts CHANGED
@@ -41,6 +41,7 @@ export * from "./functions/npc";
41
41
  export * from "./functions/pickups";
42
42
  export * from "./functions/pills";
43
43
  export * from "./functions/player";
44
+ export * from "./functions/playerDataStructures";
44
45
  export * from "./functions/playerHealth";
45
46
  export * from "./functions/pocketItems";
46
47
  export * from "./functions/positionVelocity";
package/dist/index.lua CHANGED
@@ -337,6 +337,14 @@ do
337
337
  end
338
338
  end
339
339
  end
340
+ do
341
+ local ____export = require("functions.playerDataStructures")
342
+ for ____exportKey, ____exportValue in pairs(____export) do
343
+ if ____exportKey ~= "default" then
344
+ ____exports[____exportKey] = ____exportValue
345
+ end
346
+ end
347
+ end
340
348
  do
341
349
  local ____export = require("functions.playerHealth")
342
350
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -1,10 +1,11 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /**
3
3
  * PlayerIndex is a specific type of string; see the documentation for the [[`getPlayerIndex`]]
4
- * function. Mods can signify that data structures handle EntityPlayers by using this type:
4
+ * function. Mods can signify that data structures handle EntityPlayers by using this type.
5
5
  *
6
+ * For example:
6
7
  * ```
7
- * const myPlayerMap = new Map<PlayerIndex, string>();
8
+ * const playersNameMap = new Map<PlayerIndex, string>();
8
9
  * ```
9
10
  *
10
11
  * This type is branded for extra type safety.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.123",
3
+ "version": "1.2.126",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "devDependencies": {
28
28
  "@zamiell/typescript-to-lua": "^1.4.2",
29
- "isaac-typescript-definitions": "^1.0.360",
29
+ "isaac-typescript-definitions": "^1.0.361",
30
30
  "isaacscript-lint": "^1.0.84",
31
31
  "isaacscript-tsconfig": "^1.1.8",
32
32
  "typedoc": "^0.22.13",