isaacscript-common 1.2.76 → 1.2.79

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.
@@ -9,8 +9,8 @@ local ____exports = {}
9
9
  local hasSubscriptions, postUpdate, checkPickupsPurchased, getPlayerThatIsNoLongerHoldingAnItem, storePickupsInMap, storePlayersInMap, pickupAtIndexStillExists, v
10
10
  local ____exports = require("features.saveDataManager.exports")
11
11
  local saveDataManager = ____exports.saveDataManager
12
- local ____entity = require("functions.entity")
13
- local getPickups = ____entity.getPickups
12
+ local ____pickups = require("functions.pickups")
13
+ local getPickups = ____pickups.getPickups
14
14
  local ____player = require("functions.player")
15
15
  local getPlayerIndex = ____player.getPlayerIndex
16
16
  local getPlayers = ____player.getPlayers
@@ -6,8 +6,8 @@ local ____exports = {}
6
6
  local hasSubscriptions, postUpdate, postNewRoom, checkNewEntity, v
7
7
  local ____exports = require("features.saveDataManager.exports")
8
8
  local saveDataManager = ____exports.saveDataManager
9
- local ____entity = require("functions.entity")
10
- local getSlots = ____entity.getSlots
9
+ local ____entitySpecific = require("functions.entitySpecific")
10
+ local getSlots = ____entitySpecific.getSlots
11
11
  local ____postSlotInit = require("callbacks.subscriptions.postSlotInit")
12
12
  local postSlotInitFire = ____postSlotInit.postSlotInitFire
13
13
  local postSlotInitHasSubscriptions = ____postSlotInit.postSlotInitHasSubscriptions
@@ -6,8 +6,8 @@ local ____exports = {}
6
6
  local hasSubscriptions, postRender, checkSlotBroken, BROKEN_ANIMATIONS, v
7
7
  local ____exports = require("features.saveDataManager.exports")
8
8
  local saveDataManager = ____exports.saveDataManager
9
- local ____entity = require("functions.entity")
10
- local getSlots = ____entity.getSlots
9
+ local ____entitySpecific = require("functions.entitySpecific")
10
+ local getSlots = ____entitySpecific.getSlots
11
11
  local ____postSlotDestroyed = require("callbacks.subscriptions.postSlotDestroyed")
12
12
  local postSlotDestroyedFire = ____postSlotDestroyed.postSlotDestroyedFire
13
13
  local postSlotDestroyedHasSubscriptions = ____postSlotDestroyed.postSlotDestroyedHasSubscriptions
@@ -24,6 +24,7 @@ export declare const CHARACTERS_WITH_NO_RED_HEARTS: ReadonlySet<PlayerType>;
24
24
  * includes The Lost and Tainted Lost.
25
25
  */
26
26
  export declare const CHARACTERS_WITH_NO_SOUL_HEARTS: ReadonlySet<PlayerType>;
27
+ export declare const CHEST_PICKUP_VARIANTS: ReadonlySet<PickupVariant>;
27
28
  /**
28
29
  * A collection of common colors that can be reused. Note that if you want to further modify these
29
30
  * colors, you should copy them first with the `copyColor` function.
@@ -38,6 +38,20 @@ ____exports.CHARACTERS_WITH_NO_SOUL_HEARTS = __TS__New(Set, {
38
38
  PlayerType.PLAYER_THELOST_B,
39
39
  PlayerType.PLAYER_KEEPER_B
40
40
  })
41
+ ____exports.CHEST_PICKUP_VARIANTS = __TS__New(Set, {
42
+ PickupVariant.PICKUP_CHEST,
43
+ PickupVariant.PICKUP_BOMBCHEST,
44
+ PickupVariant.PICKUP_SPIKEDCHEST,
45
+ PickupVariant.PICKUP_ETERNALCHEST,
46
+ PickupVariant.PICKUP_MIMICCHEST,
47
+ PickupVariant.PICKUP_OLDCHEST,
48
+ PickupVariant.PICKUP_WOODENCHEST,
49
+ PickupVariant.PICKUP_MEGACHEST,
50
+ PickupVariant.PICKUP_HAUNTEDCHEST,
51
+ PickupVariant.PICKUP_LOCKEDCHEST,
52
+ PickupVariant.PICKUP_REDCHEST,
53
+ PickupVariant.PICKUP_MOMSCHEST
54
+ })
41
55
  ____exports.COLORS = {
42
56
  Black = Color(1, 1, 1),
43
57
  Red = Color(1, 0, 0),
@@ -10,6 +10,8 @@ import { JSONRoom } from "../types/JSONRoom";
10
10
  * @param jsonRoom The JSON room to deploy. In practice, this will be something like:
11
11
  * ```
12
12
  * import customRooms from "./customRooms";
13
+ import { removeAllPickups } from '../functions/pickups';
14
+ import { removeAllBombs } from '../functions/entitySpecific';
13
15
  *
14
16
  * const firstJSONRoom = customRooms.rooms.room[0];
15
17
  * deployJSONRoom(firstJSONRoom);
@@ -10,9 +10,9 @@ local postNewRoom, setDecorationsInvisible, respawnPersistentEntities, removeSpe
10
10
  local ____errors = require("errors")
11
11
  local getUpgradeErrorMsg = ____errors.getUpgradeErrorMsg
12
12
  local ____entity = require("functions.entity")
13
- local removeAllBombs = ____entity.removeAllBombs
14
13
  local removeAllMatchingEntities = ____entity.removeAllMatchingEntities
15
- local removeAllPickups = ____entity.removeAllPickups
14
+ local ____entitySpecific = require("functions.entitySpecific")
15
+ local removeAllBombs = ____entitySpecific.removeAllBombs
16
16
  local ____gridEntity = require("functions.gridEntity")
17
17
  local convertXMLGridEntityType = ____gridEntity.convertXMLGridEntityType
18
18
  local getGridEntities = ____gridEntity.getGridEntities
@@ -27,6 +27,8 @@ local ____math = require("functions.math")
27
27
  local range = ____math.range
28
28
  local ____npc = require("functions.npc")
29
29
  local getNPCs = ____npc.getNPCs
30
+ local ____pickups = require("functions.pickups")
31
+ local removeAllPickups = ____pickups.removeAllPickups
30
32
  local ____random = require("functions.random")
31
33
  local nextSeed = ____random.nextSeed
32
34
  local ____rooms = require("functions.rooms")
@@ -1,5 +1,10 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /// <reference types="typescript-to-lua/language-extensions" />
3
+ /**
4
+ * Helper function for determining if two arrays contain the exact same elements. Note that this
5
+ * only performs a shallow comparison.
6
+ */
7
+ export declare function arrayEquals<T>(array1: T[] | readonly T[], array2: T[] | readonly T[]): boolean;
3
8
  /**
4
9
  * Helper function to combine two or more arrays. Returns a new array that is the composition of all
5
10
  * of the specified arrays. This function is variadic, meaning that you can specify N arguments to
@@ -15,11 +20,8 @@ export declare function combineArray<T>(...arrays: Array<T[] | readonly T[]>): T
15
20
  */
16
21
  export declare function copyArray<T>(oldArray: T[] | readonly T[], numElements?: int): T[];
17
22
  export declare function emptyArray<T>(array: T[]): void;
18
- /**
19
- * Helper function for determining if two arrays contain the exact same elements. Note that this
20
- * only performs a shallow comparison.
21
- */
22
- export declare function arrayEquals<T>(array1: T[] | readonly T[], array2: T[] | readonly T[]): boolean;
23
+ /** Helper function to return the last element of an array. */
24
+ export declare function getLastElement<T>(array: T[]): T;
23
25
  /**
24
26
  * Initializes an array with all elements containing the specified default value.
25
27
  *
@@ -1,8 +1,8 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____lualib = require("lualib_bundle")
3
+ local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
3
4
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
4
5
  local __TS__ArraySplice = ____lualib.__TS__ArraySplice
5
- local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
6
6
  local __TS__ArraySome = ____lualib.__TS__ArraySome
7
7
  local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
8
8
  local __TS__ArrayMap = ____lualib.__TS__ArrayMap
@@ -35,8 +35,19 @@ function ____exports.getRandomArrayIndex(self, array, seed)
35
35
  if #array == 0 then
36
36
  error("Failed to get a random array index since the provided array is empty.")
37
37
  end
38
- local randomIndex = getRandomInt(nil, 0, #array - 1, seed)
39
- return randomIndex
38
+ return getRandomInt(nil, 0, #array - 1, seed)
39
+ end
40
+ function ____exports.arrayEquals(self, array1, array2)
41
+ if #array1 ~= #array2 then
42
+ return false
43
+ end
44
+ return __TS__ArrayEvery(
45
+ array1,
46
+ function(____, array1Element, i)
47
+ local array2Element = array2[i + 1]
48
+ return array1Element == array2Element
49
+ end
50
+ )
40
51
  end
41
52
  function ____exports.combineArray(self, ...)
42
53
  local arrays = {...}
@@ -66,17 +77,8 @@ end
66
77
  function ____exports.emptyArray(self, array)
67
78
  __TS__ArraySplice(array, 0, #array)
68
79
  end
69
- function ____exports.arrayEquals(self, array1, array2)
70
- if #array1 ~= #array2 then
71
- return false
72
- end
73
- return __TS__ArrayEvery(
74
- array1,
75
- function(____, array1Element, i)
76
- local array2Element = array2[i + 1]
77
- return array1Element == array2Element
78
- end
79
- )
80
+ function ____exports.getLastElement(self, array)
81
+ return array[#array]
80
82
  end
81
83
  function ____exports.initArray(self, defaultValue, size)
82
84
  local array = {}
@@ -8,11 +8,11 @@ local ____collectibleDescriptionMap = require("maps.collectibleDescriptionMap")
8
8
  local COLLECTIBLE_DESCRIPTION_MAP = ____collectibleDescriptionMap.COLLECTIBLE_DESCRIPTION_MAP
9
9
  local ____collectibleNameMap = require("maps.collectibleNameMap")
10
10
  local COLLECTIBLE_NAME_MAP = ____collectibleNameMap.COLLECTIBLE_NAME_MAP
11
- local ____entity = require("functions.entity")
12
- local getPickups = ____entity.getPickups
13
- local removeAllPickups = ____entity.removeAllPickups
14
11
  local ____flag = require("functions.flag")
15
12
  local hasFlag = ____flag.hasFlag
13
+ local ____pickups = require("functions.pickups")
14
+ local getPickups = ____pickups.getPickups
15
+ local removeAllPickups = ____pickups.removeAllPickups
16
16
  local ____sprite = require("functions.sprite")
17
17
  local clearSprite = ____sprite.clearSprite
18
18
  function ____exports.setCollectibleSprite(self, collectible, pngPath)
@@ -1,18 +1,6 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  import { AnyEntity } from "../types/AnyEntity";
3
3
  export declare function anyEntityCloserThan(entities: Entity[], position: Vector, distance: int): boolean;
4
- /**
5
- * Helper function to get all of the bombs in the room.
6
- *
7
- * Example:
8
- * ```
9
- * // Make all of the bombs in the room invisible
10
- * for (const bomb of getBombs()) {
11
- * bomb.Visible = false;
12
- * }
13
- * ```
14
- */
15
- export declare function getBombs(matchingVariant?: BombVariant | int, matchingSubType?: number): EntityBomb[];
16
4
  /**
17
5
  * Given an array of entities, this helper function returns the closest one to a provided reference
18
6
  * entity.
@@ -24,24 +12,12 @@ export declare function getBombs(matchingVariant?: BombVariant | int, matchingSu
24
12
  * const closestGaper = getClosestEntityTo(player, gapers);
25
13
  * ```
26
14
  */
27
- export declare function getClosestEntityTo(referenceEntity: Entity, entities: Entity[]): Entity;
15
+ export declare function getClosestEntityTo<T extends AnyEntity>(referenceEntity: Entity, entities: T[]): T;
28
16
  /**
29
17
  * Helper function to compare two different arrays of entities. Returns the entities that are in the
30
18
  * second array but not in the first array.
31
19
  */
32
20
  export declare function getFilteredNewEntities<T extends AnyEntity>(oldEntities: T[], newEntities: T[]): T[];
33
- /**
34
- * Helper function to get all of the effects in the room.
35
- *
36
- * Example:
37
- * ```
38
- * // Make all of the effects in the room invisible
39
- * for (const effect of getEffects()) {
40
- * effect.Visible = false;
41
- * }
42
- * ```
43
- */
44
- export declare function getEffects(matchingVariant?: EffectVariant | int, matchingSubType?: number): EntityEffect[];
45
21
  /**
46
22
  * Helper function to get all of the entities in the room or all of the entities that match a
47
23
  * specific entity type / variant / sub-type.
@@ -66,86 +42,6 @@ export declare function getEffects(matchingVariant?: EffectVariant | int, matchi
66
42
  * returned. False by default. Will only be taken into account if `matchingEntityType` is specified.
67
43
  */
68
44
  export declare function getEntities(matchingEntityType?: EntityType | int, matchingVariant?: number, matchingSubType?: number, ignoreFriendly?: boolean): Entity[];
69
- /**
70
- * Helper function to get a map containing the positions of every entity in the current room.
71
- *
72
- * This is useful for rewinding entity positions at a later time. Also see `setEntityPositions()`.
73
- *
74
- * @param entities Optional. If provided, will only get the positions of the provided entities. This
75
- * can be used to cache the entities to avoid invoking `Isaac.GetRoomEntities()` multiple times.
76
- */
77
- export declare function getEntityPositions(entities?: Entity[]): Map<PtrHash, Vector>;
78
- /**
79
- * Helper function to get a map containing the velocities of every entity in the current room.
80
- *
81
- * This is useful for rewinding entity velocities at a later time. Also see `setEntityVelocities()`.
82
- *
83
- * @param entities Optional. If provided, will only get the velocities of the provided entities.
84
- * This can be used to cache the entities to avoid invoking `Isaac.GetRoomEntities()` multiple
85
- * times.
86
- */
87
- export declare function getEntityVelocities(entities?: Entity[]): Map<PtrHash, Vector>;
88
- /**
89
- * Helper function to get all of the knives in the room.
90
- *
91
- * Example:
92
- * ```
93
- * // Make all of the knives in the room invisible
94
- * for (const knife of getKnives()) {
95
- * knife.Visible = false;
96
- * }
97
- * ```
98
- */
99
- export declare function getKnives(matchingVariant?: KnifeVariant | int, matchingSubType?: number): EntityKnife[];
100
- /**
101
- * Helper function to get all of the lasers in the room.
102
- *
103
- * Example:
104
- * ```
105
- * // Make all of the lasers in the room invisible
106
- * for (const laser of getLasers()) {
107
- * laser.Visible = false;
108
- * }
109
- * ```
110
- */
111
- export declare function getLasers(matchingVariant?: LaserVariant | int, matchingSubType?: number): EntityLaser[];
112
- /**
113
- * Helper function to get all of the pickups in the room.
114
- *
115
- * Example:
116
- * ```
117
- * // Make all of the pickups in the room invisible
118
- * for (const pickup of getPickups()) {
119
- * pickup.Visible = false;
120
- * }
121
- * ```
122
- */
123
- export declare function getPickups(matchingVariant?: PickupVariant | int, matchingSubType?: number): EntityPickup[];
124
- /**
125
- * Helper function to get all of the projectiles in the room.
126
- *
127
- * Example:
128
- * ```
129
- * // Make all of the projectiles in the room invisible
130
- * for (const projectile of getProjectiles()) {
131
- * projectile.Visible = false;
132
- * }
133
- * ```
134
- */
135
- export declare function getProjectiles(matchingVariant?: ProjectileVariant | int, matchingSubType?: number): EntityProjectile[];
136
- export declare function getSlots(matchingVariant?: SlotVariant | int, matchingSubType?: number): Entity[];
137
- /**
138
- * Helper function to get all of the tears in the room.
139
- *
140
- * Example:
141
- * ```
142
- * // Make all of the tears in the room invisible
143
- * for (const tear of getTears()) {
144
- * tear.Visible = false;
145
- * }
146
- * ```
147
- */
148
- export declare function getTears(matchingVariant?: TearVariant | int, matchingSubType?: number): EntityTear[];
149
45
  /**
150
46
  * Helper function to measure an entity's velocity to see if it is moving.
151
47
  *
@@ -159,50 +55,6 @@ export declare function isEntityMoving(entity: Entity, threshold?: number): bool
159
55
  * to non-story bosses, like Vanishing Twin. Also see the `STORY_BOSSES` constant.
160
56
  */
161
57
  export declare function isStoryBoss(entity: Entity): boolean;
162
- /**
163
- * Helper function to remove all of the entities in the supplied array.
164
- *
165
- * @param entities The array of entities to remove.
166
- * @param cap Optional. If specified, will only remove the given amount of entities.
167
- * @returns True if one or more entities was removed, false otherwise.
168
- */
169
- export declare function removeEntities(entities: Entity[], cap?: int): boolean;
170
- /**
171
- * Helper function to remove all of the bombs in the room.
172
- *
173
- * @param variant Optional. If specified, will only remove bombs that match this variant.
174
- * @param subType Optional. If specified, will only remove bombs that match this sub-type.
175
- * @param cap Optional. If specified, will only remove the given amount of bombs.
176
- * @returns True if one or more bombs was removed, false otherwise.
177
- */
178
- export declare function removeAllBombs(variant?: BombVariant | int, subType?: int, cap?: int): boolean;
179
- /**
180
- * Helper function to remove all of the effects in the room.
181
- *
182
- * @param variant Optional. If specified, will only remove effects that match this variant.
183
- * @param subType Optional. If specified, will only remove effects that match this sub-type.
184
- * @param cap Optional. If specified, will only remove the given amount of effects.
185
- * @returns True if one or more effects was removed, false otherwise.
186
- */
187
- export declare function removeAllEffects(variant?: EffectVariant | int, subType?: int, cap?: int): boolean;
188
- /**
189
- * Helper function to remove all of the knives in the room.
190
- *
191
- * @param variant Optional. If specified, will only remove knives that match this variant.
192
- * @param subType Optional. If specified, will only remove knives that match this sub-type.
193
- * @param cap Optional. If specified, will only remove the given amount of knives.
194
- * @returns True if one or more knives was removed, false otherwise.
195
- */
196
- export declare function removeAllKnives(variant?: KnifeVariant | int, subType?: int, cap?: int): boolean;
197
- /**
198
- * Helper function to remove all of the lasers in the room.
199
- *
200
- * @param variant Optional. If specified, will only remove lasers that match this variant.
201
- * @param subType Optional. If specified, will only remove lasers that match this sub-type.
202
- * @param cap Optional. If specified, will only remove the given amount of lasers.
203
- * @returns True if one or more lasers was removed, false otherwise.
204
- */
205
- export declare function removeAllLasers(variant?: LaserVariant | int, subType?: int, cap?: int): boolean;
206
58
  /**
207
59
  * Helper function to remove all of the matching entities in the room.
208
60
  *
@@ -216,66 +68,20 @@ export declare function removeAllLasers(variant?: LaserVariant | int, subType?:
216
68
  */
217
69
  export declare function removeAllMatchingEntities(entityType: int, entityVariant?: number, entitySubType?: number, cap?: int | undefined): boolean;
218
70
  /**
219
- * Helper function to remove all of the pickups in the room.
220
- *
221
- * @param variant Optional. If specified, will only remove pickups that match this variant.
222
- * @param subType Optional. If specified, will only remove pickups that match this sub-type.
223
- * @param cap Optional. If specified, will only remove the given amount of pickups.
224
- * @returns True if one or more pickups was removed, false otherwise.
225
- */
226
- export declare function removeAllPickups(variant?: PickupVariant | int, subType?: int, cap?: int): boolean;
227
- /**
228
- * Helper function to remove all of the projectiles in the room.
229
- *
230
- * @param variant Optional. If specified, will only remove projectiles that match this variant.
231
- * @param subType Optional. If specified, will only remove projectiles that match this sub-type.
232
- * @param cap Optional. If specified, will only remove the given amount of projectiles.
233
- * @returns True if one or more projectiles was removed, false otherwise.
234
- */
235
- export declare function removeAllProjectiles(variant?: ProjectileVariant | int, subType?: int, cap?: int): boolean;
236
- /**
237
- * Helper function to remove all of the tears in the room.
238
- *
239
- * @param variant Optional. If specified, will only remove tears that match this variant.
240
- * @param subType Optional. If specified, will only remove tears that match this sub-type.
241
- * @param cap Optional. If specified, will only remove the given amount of tears.
242
- * @returns True if one or more tears was removed, false otherwise.
243
- */
244
- export declare function removeAllTears(variant?: TearVariant | int, subType?: int, cap?: int): boolean;
245
- /**
246
- * Game().RerollEnemy rerolls a boolean of whether or not the enemy was rerolled. However, you
247
- * cannot use the same entity object after a reroll. This function calls game.RerollEnemy and
248
- * returns the new entity object.
71
+ * Helper function to remove all of the entities in the supplied array.
249
72
  *
250
- * @param entity The entity to reroll
251
- * @returns If the entity was not rerolled, returns the original entity. otherwise, returns the resulting entity from the reroll
73
+ * @param entities The array of entities to remove.
74
+ * @param cap Optional. If specified, will only remove the given amount of entities.
75
+ * @returns True if one or more entities was removed, false otherwise.
252
76
  */
253
- export declare function rerollEnemy(entity: Entity): Entity;
77
+ export declare function removeEntities(entities: Entity[], cap?: int): boolean;
254
78
  /**
255
- * Helper function to set the position of every entity in the room based on a map of positions. If
256
- * an entity is found that does not have matching element in the provided map, then that entity will
257
- * be skipped.
258
- *
259
- * This function is useful for rewinding entity positions at a later time. Also see
260
- * `getEntityPositions()`.
79
+ * Helper function to reroll an enemy. Use this instead of the vanilla "Game.RerollEnemy" function
80
+ * if you want the rerolled enemy to be returned.
261
81
  *
262
- * @param entityPositions The map providing the positions for every entity.
263
- * @param entities Optional. If provided, will only set the positions of the provided entities. This
264
- * can be used to cache the entities to avoid invoking `Isaac.GetRoomEntities()` multiple times.
82
+ * @param entity The entity to reroll.
83
+ * @returns If the game failed to reroll the enemy, returns undefined. Otherwise, returns the
84
+ * rerolled entity.
265
85
  */
266
- export declare function setEntityPositions(entityPositions: Map<PtrHash, Vector>, entities?: Entity[]): void;
86
+ export declare function rerollEnemy(entity: Entity): Entity | undefined;
267
87
  export declare function setEntityRandomColor(entity: Entity): void;
268
- /**
269
- * Helper function to set the velocity of every entity in the room based on a map of velocities. If
270
- * an entity is found that does not have matching element in the provided map, then that entity will
271
- * be skipped.
272
- *
273
- * This function is useful for rewinding entity velocities at a later time. Also see
274
- * `getEntityVelocities()`.
275
- *
276
- * @param entityVelocities The map providing the velocities for every entity.
277
- * @param entities Optional. If provided, will only set the velocities of the provided entities.
278
- * This can be used to cache the entities to avoid invoking `Isaac.GetRoomEntities()` multiple
279
- * times.
280
- */
281
- export declare function setEntityVelocities(entityVelocities: Map<PtrHash, Vector>, entities?: Entity[]): void;