isaacscript-common 1.0.549 → 1.0.553

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.
@@ -1,5 +1,13 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /// <reference types="typescript-to-lua/language-extensions" />
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.
7
+ */
8
+ export declare function arrayCombine<T>(...arrays: T[][]): T[];
9
+ /** Helper function to perform a shallow copy. */
10
+ export declare function arrayCopy<T>(array: T[]): T[];
3
11
  export declare function arrayEmpty<T>(array: T[]): void;
4
12
  /** Helper function for determining if two arrays contain the exact same elements. */
5
13
  export declare function arrayEquals<T>(array1: T[], array2: T[]): boolean;
@@ -27,6 +27,21 @@ function ____exports.getRandomArrayIndex(self, array, seed)
27
27
  local randomIndex = getRandomInt(nil, 0, #array - 1, seed)
28
28
  return randomIndex
29
29
  end
30
+ function ____exports.arrayCombine(self, ...)
31
+ local arrays = {...}
32
+ local elements = {}
33
+ for ____, array in ipairs(arrays) do
34
+ for ____, element in ipairs(array) do
35
+ __TS__ArrayPush(elements, element)
36
+ end
37
+ end
38
+ return elements
39
+ end
40
+ function ____exports.arrayCopy(self, array)
41
+ return {
42
+ table.unpack(array)
43
+ }
44
+ end
30
45
  function ____exports.arrayEmpty(self, array)
31
46
  __TS__ArraySplice(array, 0, #array)
32
47
  end
@@ -1,7 +1,7 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /** Returns the number of items that a player has towards a particular transformation. */
3
3
  export declare function getPlayerNumTransformationCollectibles(player: EntityPlayer, playerForm: PlayerForm): int;
4
- export declare function getTransformationsForItem(collectibleType: CollectibleType | int): Set<PlayerForm>;
4
+ export declare function getTransformationsForItem(collectibleType: CollectibleType | int): PlayerForm[];
5
5
  /**
6
6
  * Helper function to get a transformation name from a PlayerForm enum.
7
7
  *
@@ -1,5 +1,4 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
- require("lualib_bundle");
3
2
  local ____exports = {}
4
3
  local ____transformationMaps = require("maps.transformationMaps")
5
4
  local ITEM_TO_TRANSFORMATION_MAP = ____transformationMaps.ITEM_TO_TRANSFORMATION_MAP
@@ -7,8 +6,6 @@ local TRANSFORMATIONS_NOT_BASED_ON_ITEMS = ____transformationMaps.TRANSFORMATION
7
6
  local TRANSFORMATION_TO_ITEMS_MAP = ____transformationMaps.TRANSFORMATION_TO_ITEMS_MAP
8
7
  local ____transformationNameMap = require("maps.transformationNameMap")
9
8
  local TRANSFORMATION_NAME_MAP = ____transformationNameMap.TRANSFORMATION_NAME_MAP
10
- local ____util = require("functions.util")
11
- local copySet = ____util.copySet
12
9
  function ____exports.getPlayerNumTransformationCollectibles(self, player, playerForm)
13
10
  if TRANSFORMATIONS_NOT_BASED_ON_ITEMS:has(playerForm) then
14
11
  error(
@@ -22,16 +19,16 @@ function ____exports.getPlayerNumTransformationCollectibles(self, player, player
22
19
  )
23
20
  end
24
21
  local numCollectibles = 0
25
- for ____, collectibleType in __TS__Iterator(
26
- itemsForTransformation:values()
27
- ) do
22
+ for ____, collectibleType in ipairs(itemsForTransformation) do
28
23
  numCollectibles = numCollectibles + player:GetCollectibleNum(collectibleType)
29
24
  end
30
25
  return numCollectibles
31
26
  end
32
27
  function ____exports.getTransformationsForItem(self, collectibleType)
33
28
  local transformations = ITEM_TO_TRANSFORMATION_MAP:get(collectibleType)
34
- return ((transformations == nil) and __TS__New(Set)) or copySet(nil, transformations)
29
+ return ((transformations == nil) and ({})) or ({
30
+ table.unpack(transformations)
31
+ })
35
32
  end
36
33
  function ____exports.getTransformationName(self, transformation)
37
34
  local defaultName = "Unknown"
@@ -1,5 +1,5 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  export declare const TRANSFORMATION_TO_TAG_MAP: Map<PlayerForm, ItemConfigTag>;
3
3
  export declare const TRANSFORMATIONS_NOT_BASED_ON_ITEMS: Set<PlayerForm>;
4
- export declare const TRANSFORMATION_TO_ITEMS_MAP: Map<PlayerForm, Set<number>>;
5
- export declare const ITEM_TO_TRANSFORMATION_MAP: Map<number, Set<PlayerForm>>;
4
+ export declare const TRANSFORMATION_TO_ITEMS_MAP: Map<PlayerForm, number[]>;
5
+ export declare const ITEM_TO_TRANSFORMATION_MAP: Map<number, PlayerForm[]>;
@@ -9,10 +9,7 @@ function initMaps(self)
9
9
  for ____, playerForm in __TS__Iterator(
10
10
  ____exports.TRANSFORMATION_TO_TAG_MAP:keys()
11
11
  ) do
12
- ____exports.TRANSFORMATION_TO_ITEMS_MAP:set(
13
- playerForm,
14
- __TS__New(Set)
15
- )
12
+ ____exports.TRANSFORMATION_TO_ITEMS_MAP:set(playerForm, {})
16
13
  end
17
14
  do
18
15
  local collectibleType = 1
@@ -34,13 +31,13 @@ function initMaps(self)
34
31
  "Failed to get the items for transformation: " .. tostring(playerForm)
35
32
  )
36
33
  end
37
- items:add(collectibleType)
34
+ __TS__ArrayPush(items, collectibleType)
38
35
  local transformations = ____exports.ITEM_TO_TRANSFORMATION_MAP:get(collectibleType)
39
36
  if transformations == nil then
40
- transformations = __TS__New(Set)
37
+ transformations = {}
41
38
  ____exports.ITEM_TO_TRANSFORMATION_MAP:set(collectibleType, transformations)
42
39
  end
43
- transformations:add(playerForm)
40
+ __TS__ArrayPush(transformations, playerForm)
44
41
  end
45
42
  ::__continue5::
46
43
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.549",
3
+ "version": "1.0.553",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",