isaacscript-common 1.2.44 → 1.2.47

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)
@@ -104,12 +104,8 @@ export declare const MAX_VANILLA_CHARACTER = PlayerType.PLAYER_THESOUL_B;
104
104
  export declare const MAX_VANILLA_COLLECTIBLE_TYPE = CollectibleType.COLLECTIBLE_MOMS_RING;
105
105
  export declare const SECOND_IN_MILLISECONDS = 1000;
106
106
  export declare const MINUTE_IN_MILLISECONDS: number;
107
- export declare const MOVEMENT_ACTIONS: readonly ButtonAction[];
108
- export declare const MOVEMENT_ACTIONS_SET: ReadonlySet<ButtonAction>;
109
107
  export declare const ONE_BY_ONE_ROOM_GRID_SIZE = 135;
110
108
  export declare const SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES: ReadonlySet<CollectibleType>;
111
- export declare const SHOOTING_ACTIONS: readonly ButtonAction[];
112
- export declare const SHOOTING_ACTIONS_SET: ReadonlySet<ButtonAction>;
113
109
  export declare const STORY_BOSSES: ReadonlySet<EntityType>;
114
110
  /**
115
111
  * This is the number of draw coordinates that each heart spans on the UI in the upper left hand
@@ -90,8 +90,6 @@ ____exports.MAX_VANILLA_CHARACTER = PlayerType.PLAYER_THESOUL_B
90
90
  ____exports.MAX_VANILLA_COLLECTIBLE_TYPE = CollectibleType.COLLECTIBLE_MOMS_RING
91
91
  ____exports.SECOND_IN_MILLISECONDS = 1000
92
92
  ____exports.MINUTE_IN_MILLISECONDS = 60 * ____exports.SECOND_IN_MILLISECONDS
93
- ____exports.MOVEMENT_ACTIONS = {ButtonAction.ACTION_LEFT, ButtonAction.ACTION_RIGHT, ButtonAction.ACTION_UP, ButtonAction.ACTION_DOWN}
94
- ____exports.MOVEMENT_ACTIONS_SET = __TS__New(Set, ____exports.MOVEMENT_ACTIONS)
95
93
  ____exports.ONE_BY_ONE_ROOM_GRID_SIZE = 135
96
94
  ____exports.SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES = __TS__New(Set, {
97
95
  CollectibleType.COLLECTIBLE_FORGET_ME_NOW,
@@ -103,8 +101,6 @@ ____exports.SINGLE_USE_ACTIVE_COLLECTIBLE_TYPES = __TS__New(Set, {
103
101
  CollectibleType.COLLECTIBLE_DEATH_CERTIFICATE,
104
102
  CollectibleType.COLLECTIBLE_R_KEY
105
103
  })
106
- ____exports.SHOOTING_ACTIONS = {ButtonAction.ACTION_SHOOTLEFT, ButtonAction.ACTION_SHOOTRIGHT, ButtonAction.ACTION_SHOOTUP, ButtonAction.ACTION_SHOOTDOWN}
107
- ____exports.SHOOTING_ACTIONS_SET = __TS__New(Set, ____exports.SHOOTING_ACTIONS)
108
104
  ____exports.STORY_BOSSES = __TS__New(Set, {
109
105
  EntityType.ENTITY_MOM,
110
106
  EntityType.ENTITY_MOMS_HEART,
@@ -1,59 +1,62 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
- /** After having disabled inputs, use this function to set things back to normal. */
3
- export declare function enableAllInputs(): void;
4
2
  /**
5
- * Helper function to disable all inputs.
6
- * This is useful because `EntityPlayer.ControlsEnabled` can be changed by the game under certain
7
- * conditions.
3
+ * Helper function to enable all inputs. Use this function to set things back to normal after having
4
+ * used one of the other helper functions to disable inputs.
8
5
  *
9
- * Call `enableAllInputs()` to set things back to normal.
6
+ * @param key The name of the mod feature that is requesting the enable/disable. This is needed so
7
+ * that multiple mod features can work in tandem.
8
+ */
9
+ export declare function enableAllInputs(key: string): void;
10
+ /**
11
+ * Helper function to disable all inputs. This is useful because `EntityPlayer.ControlsEnabled` can
12
+ * be changed by the game under certain conditions.
13
+ *
14
+ * Use the [[`enableAllInputs`]] helper function to set things back to normal.
10
15
  *
11
- * Note that calling any of the various `enable` or `disable` functions will override the effects of
12
- * this function.
16
+ * @param key The name of the mod feature that is requesting the enable/disable. This is needed so
17
+ * that multiple mod features can work in tandem.
13
18
  */
14
- export declare function disableAllInputs(): void;
19
+ export declare function disableAllInputs(key: string): void;
15
20
  /**
16
- * Helper function to enable all inputs besides the ones provided.
17
- * This is useful because `EntityPlayer.ControlsEnabled` can be changed by the game under certain
18
- * conditions.
21
+ * Helper function to enable all inputs besides the ones provided. This is useful because
22
+ * `EntityPlayer.ControlsEnabled` can be changed by the game under certain conditions.
19
23
  *
20
- * Call `enableAllInputs()` to set things back to normal.
24
+ * Use the [[`enableAllInputs`]] helper function to set things back to normal.
21
25
  *
22
- * Note that calling any of the various `enable` or `disable` functions will override the effects of
23
- * this function.
26
+ * @param key The name of the mod feature that is requesting the enable/disable. This is needed so
27
+ * that multiple mod features can work in tandem.
28
+ * @param blacklist A set of ButtonActions to disallow.
24
29
  */
25
- export declare function enableAllInputsExceptFor(blacklist: Set<ButtonAction> | ReadonlySet<ButtonAction>): void;
30
+ export declare function enableAllInputsExceptFor(key: string, blacklist: Set<ButtonAction> | ReadonlySet<ButtonAction>): void;
26
31
  /**
27
- * Helper function to disable all inputs besides the ones provided.
28
- * This is useful because `EntityPlayer.ControlsEnabled` can be changed by the game under certain
29
- * conditions.
32
+ * Helper function to disable all inputs besides the ones provided. This is useful because
33
+ * `EntityPlayer.ControlsEnabled` can be changed by the game under certain conditions.
30
34
  *
31
- * Call `enableAllInputs()` to set things back to normal.
35
+ * Use the [[`enableAllInputs`]] helper function to set things back to normal.
32
36
  *
33
- * Note that calling any of the various `enable` or `disable` functions will override the effects of
34
- * this function.
37
+ * @param key The name of the mod feature that is requesting the enable/disable. This is needed so
38
+ * that multiple mod features can work in tandem.
39
+ * @param whitelist A set of ButtonActions to allow.
35
40
  */
36
- export declare function disableAllInputsExceptFor(whitelist: Set<ButtonAction>): void;
41
+ export declare function disableAllInputsExceptFor(key: string, whitelist: Set<ButtonAction>): void;
37
42
  /**
38
43
  * Helper function to disable only the inputs used for moving the character (or moving the cursor in
39
- * the UI).
40
- * This is useful because `EntityPlayer.ControlsEnabled` can be changed by the game under certain
41
- * conditions.
44
+ * the UI). This is useful because `EntityPlayer.ControlsEnabled` can be changed by the game under
45
+ * certain conditions.
42
46
  *
43
- * Call `enableInputs()` to set things back to normal.
47
+ * Use the [[`enableAllInputs`]] helper function to set things back to normal.
44
48
  *
45
- * Note that calling any of the various `enable` or `disable` functions will override the effects of
46
- * this function.
49
+ * @param key The name of the mod feature that is requesting the enable/disable. This is needed so
50
+ * that multiple mod features can work in tandem.
47
51
  */
48
- export declare function disableMovementInputs(): void;
52
+ export declare function disableMovementInputs(key: string): void;
49
53
  /**
50
- * Helper function to disable only the inputs used for shooting tears.
51
- * This is useful because `EntityPlayer.ControlsEnabled` can be changed by the game under certain
52
- * conditions.
54
+ * Helper function to disable only the inputs used for shooting tears. This is useful because
55
+ * `EntityPlayer.ControlsEnabled` can be changed by the game under certain conditions.
53
56
  *
54
- * Call `enableInputs()` to set things back to normal.
57
+ * Use the [[`enableAllInputs`]] helper function to set things back to normal.
55
58
  *
56
- * Note that calling any of the various `enable` or `disable` functions will override the effects of
57
- * this function.
59
+ * @param key The name of the mod feature that is requesting the enable/disable. This is needed so
60
+ * that multiple mod features can work in tandem.
58
61
  */
59
- export declare function disableShootingInputs(): void;
62
+ export declare function disableShootingInputs(key: string): void;
@@ -1,13 +1,16 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____lualib = require("lualib_bundle")
3
+ local Map = ____lualib.Map
4
+ local __TS__New = ____lualib.__TS__New
5
+ local __TS__Iterator = ____lualib.__TS__Iterator
3
6
  local Set = ____lualib.Set
4
7
  local ____exports = {}
5
8
  local isActionPressed, isActionTriggered, getActionValue, getReturnValue, v
6
- local ____constants = require("constants")
7
- local MOVEMENT_ACTIONS_SET = ____constants.MOVEMENT_ACTIONS_SET
8
- local SHOOTING_ACTIONS_SET = ____constants.SHOOTING_ACTIONS_SET
9
9
  local ____errors = require("errors")
10
10
  local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
11
+ local ____input = require("functions.input")
12
+ local getMoveActions = ____input.getMoveActions
13
+ local getShootActions = ____input.getShootActions
11
14
  local ____exports = require("features.saveDataManager.exports")
12
15
  local saveDataManager = ____exports.saveDataManager
13
16
  function isActionPressed(self, _entity, _inputHook, buttonAction)
@@ -27,20 +30,24 @@ function getReturnValue(self, buttonAction, booleanCallback)
27
30
  ____booleanCallback_0 = 0
28
31
  end
29
32
  local disableValue = ____booleanCallback_0
30
- if not v.run.enableSomeInputs then
31
- return disableValue
33
+ for ____, whitelist in __TS__Iterator(v.run.disableInputsWithWhitelistMap:values()) do
34
+ if not whitelist:has(buttonAction) then
35
+ return disableValue
36
+ end
32
37
  end
33
- if v.run.whitelist ~= nil and not v.run.whitelist:has(buttonAction) then
34
- return disableValue
35
- end
36
- if v.run.blacklist ~= nil and v.run.blacklist:has(buttonAction) then
37
- return disableValue
38
+ for ____, blacklist in __TS__Iterator(v.run.enableInputsWithBlacklistMap:values()) do
39
+ if blacklist:has(buttonAction) then
40
+ return disableValue
41
+ end
38
42
  end
39
43
  return nil
40
44
  end
41
45
  local FEATURE_NAME = "input disabler"
42
46
  local initialized = false
43
- v = {run = {enableSomeInputs = true, whitelist = nil, blacklist = nil}}
47
+ v = {run = {
48
+ disableInputsWithWhitelistMap = __TS__New(Map),
49
+ enableInputsWithBlacklistMap = __TS__New(Map)
50
+ }}
44
51
  function ____exports.disableInputsInit(self, mod)
45
52
  initialized = true
46
53
  saveDataManager(nil, "disableInputs", v)
@@ -48,46 +55,47 @@ function ____exports.disableInputsInit(self, mod)
48
55
  mod:AddCallback(ModCallbacks.MC_INPUT_ACTION, isActionTriggered, InputHook.IS_ACTION_TRIGGERED)
49
56
  mod:AddCallback(ModCallbacks.MC_INPUT_ACTION, getActionValue, InputHook.GET_ACTION_VALUE)
50
57
  end
51
- function ____exports.enableAllInputs(self)
58
+ function ____exports.enableAllInputs(self, key)
52
59
  if not initialized then
53
60
  local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
54
61
  error(msg)
55
62
  end
56
- v.run.enableSomeInputs = true
57
- v.run.whitelist = nil
58
- v.run.blacklist = nil
63
+ v.run.disableInputsWithWhitelistMap:delete(key)
64
+ v.run.enableInputsWithBlacklistMap:delete(key)
59
65
  end
60
- function ____exports.disableAllInputs(self)
66
+ function ____exports.disableAllInputs(self, key)
61
67
  if not initialized then
62
68
  local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
63
69
  error(msg)
64
70
  end
65
- v.run.enableSomeInputs = false
66
- v.run.whitelist = nil
67
- v.run.blacklist = nil
71
+ v.run.disableInputsWithWhitelistMap:set(
72
+ key,
73
+ __TS__New(Set)
74
+ )
75
+ v.run.enableInputsWithBlacklistMap:delete(key)
68
76
  end
69
- function ____exports.enableAllInputsExceptFor(self, blacklist)
77
+ function ____exports.enableAllInputsExceptFor(self, key, blacklist)
70
78
  if not initialized then
71
79
  local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
72
80
  error(msg)
73
81
  end
74
- v.run.enableSomeInputs = true
75
- v.run.whitelist = nil
76
- v.run.blacklist = blacklist
82
+ v.run.disableInputsWithWhitelistMap:delete(key)
83
+ v.run.enableInputsWithBlacklistMap:set(key, blacklist)
77
84
  end
78
- function ____exports.disableAllInputsExceptFor(self, whitelist)
85
+ function ____exports.disableAllInputsExceptFor(self, key, whitelist)
79
86
  if not initialized then
80
87
  local msg = getUpgradeErrorMsg(nil, FEATURE_NAME)
81
88
  error(msg)
82
89
  end
83
- v.run.enableSomeInputs = true
84
- v.run.whitelist = whitelist
85
- v.run.blacklist = nil
90
+ v.run.disableInputsWithWhitelistMap:set(key, whitelist)
91
+ v.run.enableInputsWithBlacklistMap:delete(key)
86
92
  end
87
- function ____exports.disableMovementInputs(self)
88
- ____exports.enableAllInputsExceptFor(nil, MOVEMENT_ACTIONS_SET)
93
+ function ____exports.disableMovementInputs(self, key)
94
+ local moveActions = getMoveActions(nil)
95
+ ____exports.enableAllInputsExceptFor(nil, key, moveActions)
89
96
  end
90
- function ____exports.disableShootingInputs(self)
91
- ____exports.enableAllInputsExceptFor(nil, SHOOTING_ACTIONS_SET)
97
+ function ____exports.disableShootingInputs(self, key)
98
+ local shootActions = getShootActions(nil)
99
+ ____exports.enableAllInputsExceptFor(nil, key, shootActions)
92
100
  end
93
101
  return ____exports
@@ -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
@@ -1,6 +1,8 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /** Helper function to get the enum name for the specified `Controller` value. */
3
3
  export declare function controllerToString(controller: Controller): string;
4
+ export declare function getMoveActions(): Set<ButtonAction>;
5
+ export declare function getShootActions(): Set<ButtonAction>;
4
6
  /** Iterates over all inputs to determine if a particular button is pressed (i.e. held down). */
5
7
  export declare function isActionPressedOnAnyInput(buttonAction: ButtonAction): boolean;
6
8
  /**
@@ -9,8 +11,10 @@ export declare function isActionPressedOnAnyInput(buttonAction: ButtonAction): b
9
11
  */
10
12
  export declare function isActionTriggeredOnAnyInput(buttonAction: ButtonAction): boolean;
11
13
  export declare function isKeyboardPressed(key: Keyboard): boolean;
14
+ export declare function isMoveAction(buttonAction: ButtonAction): boolean;
12
15
  export declare function isMoveActionPressedOnAnyInput(): boolean;
13
16
  export declare function isMoveActionTriggeredOnAnyInput(): boolean;
17
+ export declare function isShootAction(buttonAction: ButtonAction): boolean;
14
18
  export declare function isShootActionPressedOnAnyInput(): boolean;
15
19
  export declare function isShootActionTriggeredOnAnyInput(): boolean;
16
20
  /** Helper function to get the enum name for the specified `Keyboard` value. */
@@ -1,5 +1,7 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____lualib = require("lualib_bundle")
3
+ local Set = ____lualib.Set
4
+ local __TS__New = ____lualib.__TS__New
3
5
  local __TS__StringReplace = ____lualib.__TS__StringReplace
4
6
  local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
5
7
  local __TS__ArraySome = ____lualib.__TS__ArraySome
@@ -7,10 +9,10 @@ local __TS__StringSlice = ____lualib.__TS__StringSlice
7
9
  local ____exports = {}
8
10
  local ____constants = require("constants")
9
11
  local MAX_NUM_INPUTS = ____constants.MAX_NUM_INPUTS
10
- local MOVEMENT_ACTIONS = ____constants.MOVEMENT_ACTIONS
11
- local SHOOTING_ACTIONS = ____constants.SHOOTING_ACTIONS
12
12
  local ____math = require("functions.math")
13
13
  local range = ____math.range
14
+ local ____set = require("functions.set")
15
+ local copySet = ____set.copySet
14
16
  local ControllerLiteral = ControllerLiteral or ({})
15
17
  ControllerLiteral.DPAD_LEFT = 0
16
18
  ControllerLiteral[ControllerLiteral.DPAD_LEFT] = "DPAD_LEFT"
@@ -44,6 +46,10 @@ ControllerLiteral.BUTTON_BACK = 14
44
46
  ControllerLiteral[ControllerLiteral.BUTTON_BACK] = "BUTTON_BACK"
45
47
  ControllerLiteral.BUTTON_START = 15
46
48
  ControllerLiteral[ControllerLiteral.BUTTON_START] = "BUTTON_START"
49
+ local MOVEMENT_ACTIONS = {ButtonAction.ACTION_LEFT, ButtonAction.ACTION_RIGHT, ButtonAction.ACTION_UP, ButtonAction.ACTION_DOWN}
50
+ local MOVEMENT_ACTIONS_SET = __TS__New(Set, MOVEMENT_ACTIONS)
51
+ local SHOOTING_ACTIONS = {ButtonAction.ACTION_SHOOTLEFT, ButtonAction.ACTION_SHOOTRIGHT, ButtonAction.ACTION_SHOOTUP, ButtonAction.ACTION_SHOOTDOWN}
52
+ local SHOOTING_ACTIONS_SET = __TS__New(Set, SHOOTING_ACTIONS)
47
53
  function ____exports.controllerToString(self, controller)
48
54
  for ____, ____value in ipairs(__TS__ObjectEntries(ControllerLiteral)) do
49
55
  local key = ____value[1]
@@ -72,6 +78,12 @@ function ____exports.controllerToString(self, controller)
72
78
  end
73
79
  return "unknown"
74
80
  end
81
+ function ____exports.getMoveActions(self)
82
+ return copySet(nil, MOVEMENT_ACTIONS_SET)
83
+ end
84
+ function ____exports.getShootActions(self)
85
+ return copySet(nil, SHOOTING_ACTIONS_SET)
86
+ end
75
87
  function ____exports.isActionPressedOnAnyInput(self, buttonAction)
76
88
  local validInputs = range(nil, 0, MAX_NUM_INPUTS - 1)
77
89
  return __TS__ArraySome(
@@ -89,6 +101,9 @@ end
89
101
  function ____exports.isKeyboardPressed(self, key)
90
102
  return Input.IsButtonPressed(key, 0)
91
103
  end
104
+ function ____exports.isMoveAction(self, buttonAction)
105
+ return MOVEMENT_ACTIONS_SET:has(buttonAction)
106
+ end
92
107
  function ____exports.isMoveActionPressedOnAnyInput(self)
93
108
  return __TS__ArraySome(
94
109
  MOVEMENT_ACTIONS,
@@ -101,6 +116,9 @@ function ____exports.isMoveActionTriggeredOnAnyInput(self)
101
116
  function(____, moveAction) return ____exports.isActionTriggeredOnAnyInput(nil, moveAction) end
102
117
  )
103
118
  end
119
+ function ____exports.isShootAction(self, buttonAction)
120
+ return SHOOTING_ACTIONS_SET:has(buttonAction)
121
+ end
104
122
  function ____exports.isShootActionPressedOnAnyInput(self)
105
123
  return __TS__ArraySome(
106
124
  SHOOTING_ACTIONS,
@@ -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
@@ -60,8 +60,8 @@ export declare function getClosestPlayer(position: Vector): EntityPlayer;
60
60
  */
61
61
  export declare function getDeathAnimationName(player: EntityPlayer): string;
62
62
  /**
63
- * Helper function to return the player with the highest index, according to the
64
- * `Isaac.GetPlayer()` method.
63
+ * Helper function to return the player with the highest ID, according to the `Isaac.GetPlayer()`
64
+ * method.
65
65
  */
66
66
  export declare function getFinalPlayer(): EntityPlayer;
67
67
  /**
@@ -116,12 +116,17 @@ export declare function getPlayerFromIndex(playerIndex: PlayerIndex): EntityPlay
116
116
  * continuing.
117
117
  * - We cannot use `GetPtrHash()` as an index because it does not persist across exiting and
118
118
  * relaunching the game.
119
+ * - We cannot use `EntityPlayer.InitSeed` because it is not consistent with additional players
120
+ * beyond the first.
119
121
  *
120
- * Instead, we use `EntityPlayer.GetCollectibleRNG()` with an arbitrary value of 1 (i.e. Sad Onion).
121
- * This works even if the player does not have any Sad Onions.
122
+ * Instead, we use `EntityPlayer.GetCollectibleRNG()` with an arbitrary value of Sad Onion (1). This
123
+ * works even if the player does not have any Sad Onions.
122
124
  *
123
- * Finally, this index fails in the case of Tainted Lazarus, since the RNG will be the same for both
124
- * Tainted Lazarus and Dead Tainted Lazarus. We revert to using the RNG of Inner Eye for this case.
125
+ * Since the RNG value is the same for both The Forgotten and The Soul, we revert to using the RNG
126
+ * of Inner Eye (2) for The Soul.
127
+ *
128
+ * Since the RNG value is the same for both Tainted Lazarus and Dead Tainted Lazarus, we revert to
129
+ * using the RNG of Spoon Bender (3) for Dead Tainted Lazarus.
125
130
  */
126
131
  export declare function getPlayerIndex(player: EntityPlayer): PlayerIndex;
127
132
  /**
@@ -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 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,11 +52,33 @@ function ____exports.getCharacters(self)
52
52
  end
53
53
  function ____exports.getPlayerIndex(self, player)
54
54
  local character = player:GetPlayerType()
55
- local collectibleToUse = character == PlayerType.PLAYER_LAZARUS2_B and CollectibleType.COLLECTIBLE_INNER_EYE or CollectibleType.COLLECTIBLE_SAD_ONION
56
- local collectibleRNG = player:GetCollectibleRNG(collectibleToUse)
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 getPlayerIndexCollectibleType(self, character)
61
+ repeat
62
+ local ____switch62 = character
63
+ local ____cond62 = ____switch62 == PlayerType.PLAYER_THESOUL
64
+ if ____cond62 then
65
+ do
66
+ return CollectibleType.COLLECTIBLE_INNER_EYE
67
+ end
68
+ end
69
+ ____cond62 = ____cond62 or ____switch62 == PlayerType.PLAYER_LAZARUS2_B
70
+ if ____cond62 then
71
+ do
72
+ return CollectibleType.COLLECTIBLE_SPOON_BENDER
73
+ end
74
+ end
75
+ do
76
+ do
77
+ return CollectibleType.COLLECTIBLE_SAD_ONION
78
+ end
79
+ end
80
+ until true
81
+ end
60
82
  function ____exports.getPlayerMaxHeartContainers(self, player)
61
83
  local character = player:GetPlayerType()
62
84
  local maxHeartContainers = ____exports.getCharacterMaxHeartContainers(nil, character)
@@ -73,39 +95,39 @@ end
73
95
  function getAdjustedPlayerName(self, player)
74
96
  local character = player:GetPlayerType()
75
97
  repeat
76
- local ____switch71 = character
77
- local ____cond71 = ____switch71 == PlayerType.PLAYER_BLUEBABY or ____switch71 == PlayerType.PLAYER_BLUEBABY_B
78
- if ____cond71 then
98
+ local ____switch75 = character
99
+ local ____cond75 = ____switch75 == PlayerType.PLAYER_BLUEBABY or ____switch75 == PlayerType.PLAYER_BLUEBABY_B
100
+ if ____cond75 then
79
101
  do
80
102
  return "Blue Baby"
81
103
  end
82
104
  end
83
- ____cond71 = ____cond71 or ____switch71 == PlayerType.PLAYER_LAZARUS2
84
- if ____cond71 then
105
+ ____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_LAZARUS2
106
+ if ____cond75 then
85
107
  do
86
108
  return "Lazarus II"
87
109
  end
88
110
  end
89
- ____cond71 = ____cond71 or ____switch71 == PlayerType.PLAYER_BLACKJUDAS
90
- if ____cond71 then
111
+ ____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_BLACKJUDAS
112
+ if ____cond75 then
91
113
  do
92
114
  return "Dark Judas"
93
115
  end
94
116
  end
95
- ____cond71 = ____cond71 or ____switch71 == PlayerType.PLAYER_JACOB
96
- if ____cond71 then
117
+ ____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_JACOB
118
+ if ____cond75 then
97
119
  do
98
120
  return "Jacob & Esau"
99
121
  end
100
122
  end
101
- ____cond71 = ____cond71 or ____switch71 == PlayerType.PLAYER_LAZARUS2_B
102
- if ____cond71 then
123
+ ____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_LAZARUS2_B
124
+ if ____cond75 then
103
125
  do
104
126
  return "Dead Tainted Lazarus"
105
127
  end
106
128
  end
107
- ____cond71 = ____cond71 or ____switch71 == PlayerType.PLAYER_JACOB2_B
108
- if ____cond71 then
129
+ ____cond75 = ____cond75 or ____switch75 == PlayerType.PLAYER_JACOB2_B
130
+ if ____cond75 then
109
131
  do
110
132
  return "Dead Tainted Jacob"
111
133
  end
@@ -128,19 +150,16 @@ function ____exports.getPlayers(self, performExclusions)
128
150
  while i < game:GetNumPlayers() do
129
151
  do
130
152
  local player = Isaac.GetPlayer(i)
131
- if player == nil then
132
- goto __continue81
133
- end
134
153
  if ____exports.isChildPlayer(nil, player) then
135
- goto __continue81
154
+ goto __continue85
136
155
  end
137
156
  local character = player:GetPlayerType()
138
157
  if performExclusions and EXCLUDED_CHARACTERS:has(character) then
139
- goto __continue81
158
+ goto __continue85
140
159
  end
141
160
  __TS__ArrayPush(players, player)
142
161
  end
143
- ::__continue81::
162
+ ::__continue85::
144
163
  i = i + 1
145
164
  end
146
165
  end
@@ -365,17 +384,11 @@ function ____exports.getPlayerIndexVanilla(self, playerToFind)
365
384
  do
366
385
  local i = 0
367
386
  while i < game:GetNumPlayers() do
368
- do
369
- local player = Isaac.GetPlayer(i)
370
- if player == nil then
371
- goto __continue62
372
- end
373
- local playerHash = GetPtrHash(player)
374
- if playerHash == playerToFindHash then
375
- return i
376
- end
387
+ local player = Isaac.GetPlayer(i)
388
+ local playerHash = GetPtrHash(player)
389
+ if playerHash == playerToFindHash then
390
+ return i
377
391
  end
378
- ::__continue62::
379
392
  i = i + 1
380
393
  end
381
394
  end
@@ -420,7 +433,7 @@ function ____exports.getTotalPlayerCollectibles(self, collectibleType)
420
433
  players,
421
434
  function(____, player) return player:GetCollectibleNum(collectibleType) end
422
435
  )
423
- return arraySum(nil, numCollectiblesArray)
436
+ return sumArray(nil, numCollectiblesArray)
424
437
  end
425
438
  function ____exports.hasLostCurse(self, player)
426
439
  local effects = player:GetEffects()
@@ -545,9 +558,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
545
558
  itemPool:RemoveCollectible(collectibleType)
546
559
  end
547
560
  repeat
548
- local ____switch124 = activeSlot
549
- local ____cond124 = ____switch124 == ActiveSlot.SLOT_PRIMARY
550
- if ____cond124 then
561
+ local ____switch127 = activeSlot
562
+ local ____cond127 = ____switch127 == ActiveSlot.SLOT_PRIMARY
563
+ if ____cond127 then
551
564
  do
552
565
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
553
566
  player:RemoveCollectible(primaryCollectibleType)
@@ -556,8 +569,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
556
569
  break
557
570
  end
558
571
  end
559
- ____cond124 = ____cond124 or ____switch124 == ActiveSlot.SLOT_SECONDARY
560
- if ____cond124 then
572
+ ____cond127 = ____cond127 or ____switch127 == ActiveSlot.SLOT_SECONDARY
573
+ if ____cond127 then
561
574
  do
562
575
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
563
576
  player:RemoveCollectible(primaryCollectibleType)
@@ -572,16 +585,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
572
585
  break
573
586
  end
574
587
  end
575
- ____cond124 = ____cond124 or ____switch124 == ActiveSlot.SLOT_POCKET
576
- if ____cond124 then
588
+ ____cond127 = ____cond127 or ____switch127 == ActiveSlot.SLOT_POCKET
589
+ if ____cond127 then
577
590
  do
578
591
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
579
592
  player:SetActiveCharge(charge, activeSlot)
580
593
  break
581
594
  end
582
595
  end
583
- ____cond124 = ____cond124 or ____switch124 == ActiveSlot.SLOT_POCKET2
584
- if ____cond124 then
596
+ ____cond127 = ____cond127 or ____switch127 == ActiveSlot.SLOT_POCKET2
597
+ if ____cond127 then
585
598
  do
586
599
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
587
600
  break
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.44",
3
+ "version": "1.2.47",
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.0",
29
- "isaac-typescript-definitions": "^1.0.347",
29
+ "isaac-typescript-definitions": "^1.0.348",
30
30
  "isaacscript-lint": "^1.0.79",
31
31
  "isaacscript-tsconfig": "^1.1.8",
32
32
  "typedoc": "^0.22.12",