isaacscript-common 1.2.45 → 1.2.48

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.
@@ -6,7 +6,7 @@ local hasSubscriptions, postPEffectUpdate, postPlayerInit, postPlayerUpdate, pos
6
6
  local ____exports = require("features.saveDataManager.exports")
7
7
  local saveDataManager = ____exports.saveDataManager
8
8
  local ____array = require("functions.array")
9
- local arrayEmpty = ____array.arrayEmpty
9
+ local emptyArray = ____array.emptyArray
10
10
  local ____player = require("functions.player")
11
11
  local getPlayerFromIndex = ____player.getPlayerFromIndex
12
12
  local getPlayerIndex = ____player.getPlayerIndex
@@ -89,7 +89,7 @@ function dequeue(self, playerIndexes, fireFunction)
89
89
  end
90
90
  ::__continue23::
91
91
  end
92
- arrayEmpty(nil, playerIndexes)
92
+ emptyArray(nil, playerIndexes)
93
93
  end
94
94
  v = {run = {
95
95
  postGameStartedFiredOnThisRun = false,
@@ -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
3
+ local Set = ____lualib.Set
4
4
  local __TS__New = ____lualib.__TS__New
5
+ local __TS__ArrayPush = ____lualib.__TS__ArrayPush
6
+ local Map = ____lualib.Map
5
7
  local ____exports = {}
6
- local hasSubscriptions, postPEffectUpdateReordered, v
8
+ local hasSubscriptions, postPEffectUpdateReordered, playerTransformationChanged, updateForgottenOrSoulTransformation, TRANSFORMATIONS, v
7
9
  local ____exports = require("features.saveDataManager.exports")
8
10
  local saveDataManager = ____exports.saveDataManager
9
11
  local ____array = require("functions.array")
10
- local arrayInit = ____array.arrayInit
12
+ local copyArray = ____array.copyArray
11
13
  local ____player = require("functions.player")
12
14
  local getPlayerIndex = ____player.getPlayerIndex
13
15
  local ____ModCallbacksCustom = require("types.ModCallbacksCustom")
@@ -22,25 +24,59 @@ function postPEffectUpdateReordered(self, player)
22
24
  if not hasSubscriptions(nil) then
23
25
  return
24
26
  end
25
- local index = getPlayerIndex(nil, player)
26
- local transformations = v.run.transformations:get(index)
27
+ local playerIndex = getPlayerIndex(nil, player)
28
+ local transformations = v.run.transformations:get(playerIndex)
29
+ if transformations == nil then
30
+ transformations = __TS__New(Map)
31
+ v.run.transformations:set(playerIndex, transformations)
32
+ end
33
+ for ____, playerForm in ipairs(TRANSFORMATIONS) do
34
+ local hasForm = player:HasPlayerForm(playerForm)
35
+ local storedForm = transformations:get(playerForm)
36
+ if storedForm == nil then
37
+ local defaultValue = false
38
+ storedForm = defaultValue
39
+ transformations:set(playerForm, defaultValue)
40
+ end
41
+ if hasForm ~= storedForm then
42
+ transformations:set(playerForm, hasForm)
43
+ playerTransformationChanged(nil, player, playerForm, hasForm)
44
+ end
45
+ end
46
+ end
47
+ function playerTransformationChanged(self, player, playerForm, hasForm)
48
+ postTransformationFire(nil, player, playerForm, hasForm)
49
+ updateForgottenOrSoulTransformation(nil, player, playerForm, hasForm)
50
+ end
51
+ function updateForgottenOrSoulTransformation(self, player, playerForm, hasForm)
52
+ local subPlayer = player:GetSubPlayer()
53
+ if subPlayer == nil then
54
+ return
55
+ end
56
+ local subPlayerIndex = getPlayerIndex(nil, subPlayer)
57
+ local transformations = v.run.transformations:get(subPlayerIndex)
27
58
  if transformations == nil then
28
- transformations = arrayInit(nil, false, PlayerForm.NUM_PLAYER_FORMS - 1)
29
- v.run.transformations:set(index, transformations)
59
+ transformations = __TS__New(Map)
60
+ v.run.transformations:set(subPlayerIndex, transformations)
30
61
  end
31
- do
32
- local playerForm = 0
33
- while playerForm < PlayerForm.NUM_PLAYER_FORMS do
34
- local hasForm = player:HasPlayerForm(playerForm)
35
- local storedForm = transformations[playerForm + 1]
36
- if hasForm ~= storedForm then
37
- transformations[playerForm + 1] = hasForm
38
- postTransformationFire(nil, player, playerForm, hasForm)
62
+ transformations:set(playerForm, hasForm)
63
+ end
64
+ local UNUSED_TRANSFORMATIONS = __TS__New(Set, {PlayerForm.PLAYERFORM_FLIGHT})
65
+ local tempTransformations = {}
66
+ do
67
+ local playerForm = 0
68
+ while playerForm < PlayerForm.NUM_PLAYER_FORMS do
69
+ do
70
+ if UNUSED_TRANSFORMATIONS:has(playerForm) then
71
+ goto __continue2
39
72
  end
40
- playerForm = playerForm + 1
73
+ __TS__ArrayPush(tempTransformations, playerForm)
41
74
  end
75
+ ::__continue2::
76
+ playerForm = playerForm + 1
42
77
  end
43
78
  end
79
+ TRANSFORMATIONS = copyArray(nil, tempTransformations)
44
80
  v = {run = {transformations = __TS__New(Map)}}
45
81
  function ____exports.postTransformationCallbackInit(self, mod)
46
82
  saveDataManager(nil, "postTransformation", v, hasSubscriptions)
@@ -21,7 +21,7 @@ export declare function disableAllInputs(key: string): void;
21
21
  * Helper function to enable all inputs besides the ones provided. This is useful because
22
22
  * `EntityPlayer.ControlsEnabled` can be changed by the game under certain conditions.
23
23
  *
24
- * Use the `enableAllInputs` helper function to set things back to normal.
24
+ * Use the [[`enableAllInputs`]] helper function to set things back to normal.
25
25
  *
26
26
  * @param key The name of the mod feature that is requesting the enable/disable. This is needed so
27
27
  * that multiple mod features can work in tandem.
@@ -32,7 +32,7 @@ export declare function enableAllInputsExceptFor(key: string, blacklist: Set<But
32
32
  * Helper function to disable all inputs besides the ones provided. This is useful because
33
33
  * `EntityPlayer.ControlsEnabled` can be changed by the game under certain conditions.
34
34
  *
35
- * Use the `enableAllInputs` helper function to set things back to normal.
35
+ * Use the [[`enableAllInputs`]] helper function to set things back to normal.
36
36
  *
37
37
  * @param key The name of the mod feature that is requesting the enable/disable. This is needed so
38
38
  * that multiple mod features can work in tandem.
@@ -44,7 +44,7 @@ export declare function disableAllInputsExceptFor(key: string, whitelist: Set<Bu
44
44
  * the UI). This is useful because `EntityPlayer.ControlsEnabled` can be changed by the game under
45
45
  * certain conditions.
46
46
  *
47
- * Use the `enableAllInputs` helper function to set things back to normal.
47
+ * Use the [[`enableAllInputs`]] helper function to set things back to normal.
48
48
  *
49
49
  * @param key The name of the mod feature that is requesting the enable/disable. This is needed so
50
50
  * that multiple mod features can work in tandem.
@@ -54,7 +54,7 @@ export declare function disableMovementInputs(key: string): void;
54
54
  * Helper function to disable only the inputs used for shooting tears. This is useful because
55
55
  * `EntityPlayer.ControlsEnabled` can be changed by the game under certain conditions.
56
56
  *
57
- * Use the `enableAllInputs` helper function to set things back to normal.
57
+ * Use the [[`enableAllInputs`]] helper function to set things back to normal.
58
58
  *
59
59
  * @param key The name of the mod feature that is requesting the enable/disable. This is needed so
60
60
  * that multiple mod features can work in tandem.
@@ -9,7 +9,7 @@ local ____deepCopy = require("functions.deepCopy")
9
9
  local deepCopy = ____deepCopy.deepCopy
10
10
  local SerializationType = ____deepCopy.SerializationType
11
11
  local ____table = require("functions.table")
12
- local tableClear = ____table.tableClear
12
+ local clearTable = ____table.clearTable
13
13
  local ____ModCallbacksCustom = require("types.ModCallbacksCustom")
14
14
  local ModCallbacksCustom = ____ModCallbacksCustom.ModCallbacksCustom
15
15
  local ____SaveData = require("types.SaveData")
@@ -85,7 +85,7 @@ function restoreDefaults(self, childTableName)
85
85
  end
86
86
  end
87
87
  function clearAndCopyAllElements(self, oldTable, newTable)
88
- tableClear(nil, oldTable)
88
+ clearTable(nil, oldTable)
89
89
  for key, value in pairs(newTable) do
90
90
  oldTable[key] = value
91
91
  end
@@ -21,7 +21,7 @@ local SerializationType = ____deepCopy.SerializationType
21
21
  local ____log = require("functions.log")
22
22
  local log = ____log.log
23
23
  local ____table = require("functions.table")
24
- local tableClear = ____table.tableClear
24
+ local clearTable = ____table.clearTable
25
25
  function ____exports.merge(self, oldObject, newTable, traversalDescription)
26
26
  local oldObjectType = type(oldObject)
27
27
  if oldObjectType ~= "table" then
@@ -48,7 +48,7 @@ function mergeArray(self, oldObject, newTable)
48
48
  if not isArray(nil, oldArray) or not isArray(nil, newTable) then
49
49
  return false
50
50
  end
51
- tableClear(nil, oldArray)
51
+ clearTable(nil, oldArray)
52
52
  for key, value in pairs(newTable) do
53
53
  oldArray[key] = value
54
54
  end
@@ -1,20 +1,19 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /// <reference types="typescript-to-lua/language-extensions" />
3
3
  /**
4
- * Helper function to combine arrays. Returns a new array that is the composition of all of the
5
- * specified arrays. This function is variadic, meaning that you can specify N arguments to combine
6
- * N arrays. Note that this will only perform a shallow copy of the array elements.
4
+ * Helper function to combine two or more arrays. Returns a new array that is the composition of all
5
+ * of the specified arrays. This function is variadic, meaning that you can specify N arguments to
6
+ * combine N arrays. Note that this will only perform a shallow copy of the array elements.
7
7
  */
8
- export declare function arrayCombine<T>(...arrays: Array<T[] | readonly T[]>): T[];
8
+ export declare function combineArray<T>(...arrays: Array<T[] | readonly T[]>): T[];
9
9
  /** Helper function to perform a shallow copy. */
10
- export declare function arrayCopy<T>(array: T[] | readonly T[]): T[];
11
- export declare function arrayEmpty<T>(array: T[]): void;
10
+ export declare function copyArray<T>(array: T[] | readonly T[]): T[];
11
+ export declare function emptyArray<T>(array: T[]): void;
12
12
  /**
13
13
  * Helper function for determining if two arrays contain the exact same elements. Note that this
14
14
  * only performs a shallow comparison.
15
15
  */
16
16
  export declare function arrayEquals<T>(array1: T[] | readonly T[], array2: T[] | readonly T[]): boolean;
17
- export declare function arrayInArray<T>(arrayToMatch: T[] | readonly T[], parentArray: Array<T[] | readonly T[]>): boolean;
18
17
  /**
19
18
  * Initializes an array with all elements containing the specified default value.
20
19
  *
@@ -23,20 +22,21 @@ export declare function arrayInArray<T>(arrayToMatch: T[] | readonly T[], parent
23
22
  * const playerTransformations = initArray(false, PlayerForm.NUM_PLAYER_FORMS - 1);
24
23
  * ```
25
24
  */
26
- export declare function arrayInit<T>(defaultValue: T, size: int): T[];
25
+ export declare function initArray<T>(defaultValue: T, size: int): T[];
26
+ export declare function isArrayInArray<T>(arrayToMatch: T[] | readonly T[], parentArray: Array<T[] | readonly T[]>): boolean;
27
27
  /**
28
28
  * Shallow copies and shuffles the array using the Fisher-Yates algorithm. Returns the copied array.
29
29
  *
30
30
  * From: https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array
31
31
  */
32
- export declare function arrayShuffle<T>(originalArray: T[] | readonly T[], seed?: number): T[];
32
+ export declare function shuffleArray<T>(originalArray: T[] | readonly T[], seed?: number): T[];
33
33
  /**
34
34
  * Shuffles the provided array in-place using the Fisher-Yates algorithm.
35
35
  *
36
36
  * From: https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array
37
37
  */
38
- export declare function arrayShuffleInPlace<T>(array: T[], seed?: number): void;
39
- export declare function arraySum(array: number[] | readonly number[]): number;
38
+ export declare function shuffleArrayInPlace<T>(array: T[], seed?: number): void;
39
+ export declare function sumArray(array: number[] | readonly number[]): number;
40
40
  export declare function arrayToString<T>(array: T[]): string;
41
41
  /**
42
42
  * Shallow copies and removes the specified element(s) from the array. Returns the copied array. If
@@ -11,7 +11,7 @@ local ____exports = {}
11
11
  local ____random = require("functions.random")
12
12
  local getRandomInt = ____random.getRandomInt
13
13
  local nextSeed = ____random.nextSeed
14
- function ____exports.arrayShuffleInPlace(self, array, seed)
14
+ function ____exports.shuffleArrayInPlace(self, array, seed)
15
15
  if seed == nil then
16
16
  seed = Random()
17
17
  end
@@ -36,7 +36,7 @@ function ____exports.getRandomArrayIndex(self, array, seed)
36
36
  local randomIndex = getRandomInt(nil, 0, #array - 1, seed)
37
37
  return randomIndex
38
38
  end
39
- function ____exports.arrayCombine(self, ...)
39
+ function ____exports.combineArray(self, ...)
40
40
  local arrays = {...}
41
41
  local elements = {}
42
42
  for ____, array in ipairs(arrays) do
@@ -46,10 +46,10 @@ function ____exports.arrayCombine(self, ...)
46
46
  end
47
47
  return elements
48
48
  end
49
- function ____exports.arrayCopy(self, array)
49
+ function ____exports.copyArray(self, array)
50
50
  return {table.unpack(array)}
51
51
  end
52
- function ____exports.arrayEmpty(self, array)
52
+ function ____exports.emptyArray(self, array)
53
53
  __TS__ArraySplice(array, 0, #array)
54
54
  end
55
55
  function ____exports.arrayEquals(self, array1, array2)
@@ -64,13 +64,7 @@ function ____exports.arrayEquals(self, array1, array2)
64
64
  end
65
65
  )
66
66
  end
67
- function ____exports.arrayInArray(self, arrayToMatch, parentArray)
68
- return __TS__ArraySome(
69
- parentArray,
70
- function(____, element) return ____exports.arrayEquals(nil, element, arrayToMatch) end
71
- )
72
- end
73
- function ____exports.arrayInit(self, defaultValue, size)
67
+ function ____exports.initArray(self, defaultValue, size)
74
68
  local array = {}
75
69
  do
76
70
  local i = 0
@@ -81,15 +75,21 @@ function ____exports.arrayInit(self, defaultValue, size)
81
75
  end
82
76
  return array
83
77
  end
84
- function ____exports.arrayShuffle(self, originalArray, seed)
78
+ function ____exports.isArrayInArray(self, arrayToMatch, parentArray)
79
+ return __TS__ArraySome(
80
+ parentArray,
81
+ function(____, element) return ____exports.arrayEquals(nil, element, arrayToMatch) end
82
+ )
83
+ end
84
+ function ____exports.shuffleArray(self, originalArray, seed)
85
85
  if seed == nil then
86
86
  seed = Random()
87
87
  end
88
- local array = ____exports.arrayCopy(nil, originalArray)
89
- ____exports.arrayShuffleInPlace(nil, array, seed)
88
+ local array = ____exports.copyArray(nil, originalArray)
89
+ ____exports.shuffleArrayInPlace(nil, array, seed)
90
90
  return array
91
91
  end
92
- function ____exports.arraySum(self, array)
92
+ function ____exports.sumArray(self, array)
93
93
  return __TS__ArrayReduce(
94
94
  array,
95
95
  function(____, accumulator, element) return accumulator + element end,
@@ -109,7 +109,7 @@ function ____exports.arrayToString(self, array)
109
109
  end
110
110
  function ____exports.arrayRemove(self, originalArray, ...)
111
111
  local elements = {...}
112
- local array = ____exports.arrayCopy(nil, originalArray)
112
+ local array = ____exports.copyArray(nil, originalArray)
113
113
  for ____, element in ipairs(elements) do
114
114
  local index = __TS__ArrayIndexOf(array, element)
115
115
  if index > -1 then
@@ -5,7 +5,7 @@ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
5
5
  local ____exports = {}
6
6
  local getTotalWeightOfJSONRooms, getJSONRoomWithChosenWeight
7
7
  local ____array = require("functions.array")
8
- local arraySum = ____array.arraySum
8
+ local sumArray = ____array.sumArray
9
9
  local ____log = require("functions.log")
10
10
  local log = ____log.log
11
11
  local ____random = require("functions.random")
@@ -22,7 +22,7 @@ function getTotalWeightOfJSONRooms(self, jsonRooms)
22
22
  return roomWeight
23
23
  end
24
24
  )
25
- return arraySum(nil, weights)
25
+ return sumArray(nil, weights)
26
26
  end
27
27
  function getJSONRoomWithChosenWeight(self, jsonRooms, chosenWeight)
28
28
  for ____, jsonRoom in ipairs(jsonRooms) do
@@ -9,7 +9,7 @@ local __TS__Iterator = ____lualib.__TS__Iterator
9
9
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
10
10
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
11
11
  local ____exports = {}
12
- local getPlayerIndexRNGCollectibleForCharacter, getAdjustedPlayerName, isTaintedModded, EXCLUDED_CHARACTERS
12
+ local getPlayerIndexCollectibleType, getAdjustedPlayerName, isTaintedModded, EXCLUDED_CHARACTERS
13
13
  local ____constants = require("constants")
14
14
  local CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART = ____constants.CHARACTERS_WITH_BLACK_HEART_FROM_ETERNAL_HEART
15
15
  local CHARACTERS_WITH_FREE_DEVIL_DEALS = ____constants.CHARACTERS_WITH_FREE_DEVIL_DEALS
@@ -21,7 +21,7 @@ local MAX_VANILLA_CHARACTER = ____constants.MAX_VANILLA_CHARACTER
21
21
  local ____HealthType = require("types.HealthType")
22
22
  local HealthType = ____HealthType.HealthType
23
23
  local ____array = require("functions.array")
24
- local arraySum = ____array.arraySum
24
+ local sumArray = ____array.sumArray
25
25
  local ____bitwise = require("functions.bitwise")
26
26
  local getKBitOfN = ____bitwise.getKBitOfN
27
27
  local getNumBitsOfN = ____bitwise.getNumBitsOfN
@@ -52,12 +52,12 @@ function ____exports.getCharacters(self)
52
52
  end
53
53
  function ____exports.getPlayerIndex(self, player)
54
54
  local character = player:GetPlayerType()
55
- local rngCollectible = getPlayerIndexRNGCollectibleForCharacter(nil, character)
56
- local collectibleRNG = player:GetCollectibleRNG(rngCollectible)
55
+ local collectibleType = getPlayerIndexCollectibleType(nil, character)
56
+ local collectibleRNG = player:GetCollectibleRNG(collectibleType)
57
57
  local seed = collectibleRNG:GetSeed()
58
58
  return seed
59
59
  end
60
- function getPlayerIndexRNGCollectibleForCharacter(self, character)
60
+ function getPlayerIndexCollectibleType(self, character)
61
61
  repeat
62
62
  local ____switch62 = character
63
63
  local ____cond62 = ____switch62 == PlayerType.PLAYER_THESOUL
@@ -433,7 +433,7 @@ function ____exports.getTotalPlayerCollectibles(self, collectibleType)
433
433
  players,
434
434
  function(____, player) return player:GetCollectibleNum(collectibleType) end
435
435
  )
436
- return arraySum(nil, numCollectiblesArray)
436
+ return sumArray(nil, numCollectiblesArray)
437
437
  end
438
438
  function ____exports.hasLostCurse(self, player)
439
439
  local effects = player:GetEffects()
@@ -3,4 +3,4 @@
3
3
  * In a Map, you can use the `clear` method to delete every element. However, in a LuaTable, the
4
4
  * `clear` method does not exist. Use this helper function as a drop-in replacement for this.
5
5
  */
6
- export declare function tableClear(table: LuaTable): void;
6
+ export declare function clearTable(table: LuaTable): void;
@@ -1,6 +1,6 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
- function ____exports.tableClear(self, ____table)
3
+ function ____exports.clearTable(self, ____table)
4
4
  for key in pairs(____table) do
5
5
  ____table[key] = nil
6
6
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.45",
3
+ "version": "1.2.48",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",