isaacscript-common 1.2.78 → 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")
@@ -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;
@@ -1,11 +1,10 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____lualib = require("lualib_bundle")
3
3
  local __TS__ArraySome = ____lualib.__TS__ArraySome
4
- local __TS__ArrayPush = ____lualib.__TS__ArrayPush
5
4
  local Set = ____lualib.Set
6
5
  local __TS__New = ____lualib.__TS__New
7
6
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
8
- local Map = ____lualib.Map
7
+ local __TS__ArrayPush = ____lualib.__TS__ArrayPush
9
8
  local ____exports = {}
10
9
  local ____constants = require("constants")
11
10
  local STORY_BOSSES = ____constants.STORY_BOSSES
@@ -14,20 +13,19 @@ local getRandom = ____random.getRandom
14
13
  local nextSeed = ____random.nextSeed
15
14
  local ____utils = require("functions.utils")
16
15
  local ____repeat = ____utils["repeat"]
17
- function ____exports.getEntities(self, matchingEntityType, matchingVariant, matchingSubType, ignoreFriendly)
18
- if matchingVariant == nil then
19
- matchingVariant = -1
20
- end
21
- if matchingSubType == nil then
22
- matchingSubType = -1
23
- end
24
- if ignoreFriendly == nil then
25
- ignoreFriendly = false
16
+ function ____exports.removeEntities(self, entities, cap)
17
+ if #entities == 0 then
18
+ return false
26
19
  end
27
- if matchingEntityType == nil then
28
- return Isaac.GetRoomEntities()
20
+ local numEntitiesRemoved = 0
21
+ for ____, entity in ipairs(entities) do
22
+ entity:Remove()
23
+ numEntitiesRemoved = numEntitiesRemoved + 1
24
+ if cap ~= nil and numEntitiesRemoved >= cap then
25
+ return true
26
+ end
29
27
  end
30
- return Isaac.FindByType(matchingEntityType, matchingVariant, matchingSubType, ignoreFriendly)
28
+ return true
31
29
  end
32
30
  function ____exports.anyEntityCloserThan(self, entities, position, distance)
33
31
  return __TS__ArraySome(
@@ -35,23 +33,6 @@ function ____exports.anyEntityCloserThan(self, entities, position, distance)
35
33
  function(____, entity) return position:Distance(entity.Position) <= distance end
36
34
  )
37
35
  end
38
- function ____exports.getBombs(self, matchingVariant, matchingSubType)
39
- if matchingVariant == nil then
40
- matchingVariant = -1
41
- end
42
- if matchingSubType == nil then
43
- matchingSubType = -1
44
- end
45
- local entities = ____exports.getEntities(nil, EntityType.ENTITY_BOMB, matchingVariant, matchingSubType)
46
- local bombs = {}
47
- for ____, entity in ipairs(entities) do
48
- local bomb = entity:ToBomb()
49
- if bomb ~= nil then
50
- __TS__ArrayPush(bombs, bomb)
51
- end
52
- end
53
- return bombs
54
- end
55
36
  function ____exports.getClosestEntityTo(self, referenceEntity, entities)
56
37
  local closestEntity = nil
57
38
  local closestDistance = math.huge
@@ -81,139 +62,20 @@ function ____exports.getFilteredNewEntities(self, oldEntities, newEntities)
81
62
  end
82
63
  )
83
64
  end
84
- function ____exports.getEffects(self, matchingVariant, matchingSubType)
85
- if matchingVariant == nil then
86
- matchingVariant = -1
87
- end
88
- if matchingSubType == nil then
89
- matchingSubType = -1
90
- end
91
- local entities = ____exports.getEntities(nil, EntityType.ENTITY_EFFECT, matchingVariant, matchingSubType)
92
- local effects = {}
93
- for ____, entity in ipairs(entities) do
94
- local effect = entity:ToEffect()
95
- if effect ~= nil then
96
- __TS__ArrayPush(effects, effect)
97
- end
98
- end
99
- return effects
100
- end
101
- function ____exports.getEntityPositions(self, entities)
102
- if entities == nil then
103
- entities = ____exports.getEntities(nil)
104
- end
105
- local entityPositions = __TS__New(Map)
106
- for ____, entity in ipairs(entities) do
107
- local ptrHash = GetPtrHash(entity)
108
- entityPositions:set(ptrHash, entity.Position)
109
- end
110
- return entityPositions
111
- end
112
- function ____exports.getEntityVelocities(self, entities)
113
- if entities == nil then
114
- entities = ____exports.getEntities(nil)
115
- end
116
- local entityVelocities = __TS__New(Map)
117
- for ____, entity in ipairs(entities) do
118
- local ptrHash = GetPtrHash(entity)
119
- entityVelocities:set(ptrHash, entity.Velocity)
120
- end
121
- return entityVelocities
122
- end
123
- function ____exports.getKnives(self, matchingVariant, matchingSubType)
124
- if matchingVariant == nil then
125
- matchingVariant = -1
126
- end
127
- if matchingSubType == nil then
128
- matchingSubType = -1
129
- end
130
- local entities = ____exports.getEntities(nil, EntityType.ENTITY_KNIFE, matchingVariant, matchingSubType)
131
- local knives = {}
132
- for ____, entity in ipairs(entities) do
133
- local knife = entity:ToKnife()
134
- if knife ~= nil then
135
- __TS__ArrayPush(knives, knife)
136
- end
137
- end
138
- return knives
139
- end
140
- function ____exports.getLasers(self, matchingVariant, matchingSubType)
141
- if matchingVariant == nil then
142
- matchingVariant = -1
143
- end
144
- if matchingSubType == nil then
145
- matchingSubType = -1
146
- end
147
- local entities = ____exports.getEntities(nil, EntityType.ENTITY_LASER, matchingVariant, matchingSubType)
148
- local lasers = {}
149
- for ____, entity in ipairs(entities) do
150
- local laser = entity:ToLaser()
151
- if laser ~= nil then
152
- __TS__ArrayPush(lasers, laser)
153
- end
154
- end
155
- return lasers
156
- end
157
- function ____exports.getPickups(self, matchingVariant, matchingSubType)
158
- if matchingVariant == nil then
159
- matchingVariant = -1
160
- end
161
- if matchingSubType == nil then
162
- matchingSubType = -1
163
- end
164
- local entities = ____exports.getEntities(nil, EntityType.ENTITY_PICKUP, matchingVariant, matchingSubType)
165
- local pickups = {}
166
- for ____, entity in ipairs(entities) do
167
- local pickup = entity:ToPickup()
168
- if pickup ~= nil then
169
- __TS__ArrayPush(pickups, pickup)
170
- end
171
- end
172
- return pickups
173
- end
174
- function ____exports.getProjectiles(self, matchingVariant, matchingSubType)
175
- if matchingVariant == nil then
176
- matchingVariant = -1
177
- end
178
- if matchingSubType == nil then
179
- matchingSubType = -1
180
- end
181
- local entities = ____exports.getEntities(nil, EntityType.ENTITY_PROJECTILE, matchingVariant, matchingSubType)
182
- local projectiles = {}
183
- for ____, entity in ipairs(entities) do
184
- local projectile = entity:ToProjectile()
185
- if projectile ~= nil then
186
- __TS__ArrayPush(projectiles, projectile)
187
- end
188
- end
189
- return projectiles
190
- end
191
- function ____exports.getSlots(self, matchingVariant, matchingSubType)
65
+ function ____exports.getEntities(self, matchingEntityType, matchingVariant, matchingSubType, ignoreFriendly)
192
66
  if matchingVariant == nil then
193
67
  matchingVariant = -1
194
68
  end
195
69
  if matchingSubType == nil then
196
70
  matchingSubType = -1
197
71
  end
198
- local slots = ____exports.getEntities(nil, EntityType.ENTITY_SLOT, matchingVariant, matchingSubType)
199
- return slots
200
- end
201
- function ____exports.getTears(self, matchingVariant, matchingSubType)
202
- if matchingVariant == nil then
203
- matchingVariant = -1
204
- end
205
- if matchingSubType == nil then
206
- matchingSubType = -1
72
+ if ignoreFriendly == nil then
73
+ ignoreFriendly = false
207
74
  end
208
- local entities = ____exports.getEntities(nil, EntityType.ENTITY_TEAR, matchingVariant, matchingSubType)
209
- local tears = {}
210
- for ____, entity in ipairs(entities) do
211
- local tear = entity:ToTear()
212
- if tear ~= nil then
213
- __TS__ArrayPush(tears, tear)
214
- end
75
+ if matchingEntityType == nil then
76
+ return Isaac.GetRoomEntities()
215
77
  end
216
- return tears
78
+ return Isaac.FindByType(matchingEntityType, matchingVariant, matchingSubType, ignoreFriendly)
217
79
  end
218
80
  function ____exports.isEntityMoving(self, entity, threshold)
219
81
  if threshold == nil then
@@ -224,36 +86,6 @@ end
224
86
  function ____exports.isStoryBoss(self, entity)
225
87
  return STORY_BOSSES:has(entity.Type)
226
88
  end
227
- function ____exports.removeEntities(self, entities, cap)
228
- if #entities == 0 then
229
- return false
230
- end
231
- local numEntitiesRemoved = 0
232
- for ____, entity in ipairs(entities) do
233
- entity:Remove()
234
- numEntitiesRemoved = numEntitiesRemoved + 1
235
- if cap ~= nil and numEntitiesRemoved >= cap then
236
- return true
237
- end
238
- end
239
- return true
240
- end
241
- function ____exports.removeAllBombs(self, variant, subType, cap)
242
- local bombs = ____exports.getBombs(nil, variant, subType)
243
- return ____exports.removeEntities(nil, bombs, cap)
244
- end
245
- function ____exports.removeAllEffects(self, variant, subType, cap)
246
- local effects = ____exports.getEffects(nil, variant, subType)
247
- return ____exports.removeEntities(nil, effects, cap)
248
- end
249
- function ____exports.removeAllKnives(self, variant, subType, cap)
250
- local knives = ____exports.getKnives(nil, variant, subType)
251
- return ____exports.removeEntities(nil, knives, cap)
252
- end
253
- function ____exports.removeAllLasers(self, variant, subType, cap)
254
- local lasers = ____exports.getLasers(nil, variant, subType)
255
- return ____exports.removeEntities(nil, lasers, cap)
256
- end
257
89
  function ____exports.removeAllMatchingEntities(self, entityType, entityVariant, entitySubType, cap)
258
90
  if entityVariant == nil then
259
91
  entityVariant = -1
@@ -267,44 +99,20 @@ function ____exports.removeAllMatchingEntities(self, entityType, entityVariant,
267
99
  local entities = ____exports.getEntities(nil, entityType, entityVariant, entitySubType)
268
100
  return ____exports.removeEntities(nil, entities, cap)
269
101
  end
270
- function ____exports.removeAllPickups(self, variant, subType, cap)
271
- local pickups = ____exports.getPickups(nil, variant, subType)
272
- return ____exports.removeEntities(nil, pickups, cap)
273
- end
274
- function ____exports.removeAllProjectiles(self, variant, subType, cap)
275
- local projectiles = ____exports.getProjectiles(nil, variant, subType)
276
- return ____exports.removeEntities(nil, projectiles, cap)
277
- end
278
- function ____exports.removeAllTears(self, variant, subType, cap)
279
- local tears = ____exports.getTears(nil, variant, subType)
280
- return ____exports.removeEntities(nil, tears, cap)
281
- end
282
102
  function ____exports.rerollEnemy(self, entity)
283
103
  local game = Game()
284
104
  local oldEntities = ____exports.getEntities(nil)
285
105
  local wasRerolled = game:RerollEnemy(entity)
286
106
  if not wasRerolled then
287
- return entity
107
+ return nil
288
108
  end
289
109
  local newEntities = ____exports.getEntities(nil)
290
110
  local filteredNewEntities = ____exports.getFilteredNewEntities(nil, oldEntities, newEntities)
291
- if #filteredNewEntities ~= 0 then
111
+ if #filteredNewEntities == 0 then
292
112
  error("Failed to find the new entity generated by the \"RerollEnemy\" method.")
293
113
  end
294
114
  return filteredNewEntities[1]
295
115
  end
296
- function ____exports.setEntityPositions(self, entityPositions, entities)
297
- if entities == nil then
298
- entities = ____exports.getEntities(nil)
299
- end
300
- for ____, entity in ipairs(entities) do
301
- local ptrHash = GetPtrHash(entity)
302
- local entityPosition = entityPositions:get(ptrHash)
303
- if entityPosition ~= nil then
304
- entity.Position = entityPosition
305
- end
306
- end
307
- end
308
116
  function ____exports.setEntityRandomColor(self, entity)
309
117
  local colorValues = {}
310
118
  local seed = entity.InitSeed
@@ -326,16 +134,4 @@ function ____exports.setEntityRandomColor(self, entity)
326
134
  false
327
135
  )
328
136
  end
329
- function ____exports.setEntityVelocities(self, entityVelocities, entities)
330
- if entities == nil then
331
- entities = ____exports.getEntities(nil)
332
- end
333
- for ____, entity in ipairs(entities) do
334
- local ptrHash = GetPtrHash(entity)
335
- local entityVelocity = entityVelocities:get(ptrHash)
336
- if entityVelocity ~= nil then
337
- entity.Velocity = entityVelocity
338
- end
339
- end
340
- end
341
137
  return ____exports
@@ -0,0 +1,148 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /**
3
+ * Helper function to get all of the bombs in the room.
4
+ *
5
+ * Example:
6
+ * ```
7
+ * // Make all of the bombs in the room invisible
8
+ * for (const bomb of getBombs()) {
9
+ * bomb.Visible = false;
10
+ * }
11
+ * ```
12
+ */
13
+ export declare function getBombs(matchingVariant?: BombVariant | int, matchingSubType?: number): EntityBomb[];
14
+ /**
15
+ * Helper function to get all of the effects in the room.
16
+ *
17
+ * Example:
18
+ * ```
19
+ * // Make all of the effects in the room invisible
20
+ * for (const effect of getEffects()) {
21
+ * effect.Visible = false;
22
+ * }
23
+ * ```
24
+ */
25
+ export declare function getEffects(matchingVariant?: EffectVariant | int, matchingSubType?: number): EntityEffect[];
26
+ /**
27
+ * Helper function to get all of the knives in the room.
28
+ *
29
+ * Example:
30
+ * ```
31
+ * // Make all of the knives in the room invisible
32
+ * for (const knife of getKnives()) {
33
+ * knife.Visible = false;
34
+ * }
35
+ * ```
36
+ */
37
+ export declare function getKnives(matchingVariant?: KnifeVariant | int, matchingSubType?: number): EntityKnife[];
38
+ /**
39
+ * Helper function to get all of the lasers in the room.
40
+ *
41
+ * Example:
42
+ * ```
43
+ * // Make all of the lasers in the room invisible
44
+ * for (const laser of getLasers()) {
45
+ * laser.Visible = false;
46
+ * }
47
+ * ```
48
+ */
49
+ export declare function getLasers(matchingVariant?: LaserVariant | int, matchingSubType?: number): EntityLaser[];
50
+ /**
51
+ * Helper function to get all of the projectiles in the room.
52
+ *
53
+ * Example:
54
+ * ```
55
+ * // Make all of the projectiles in the room invisible
56
+ * for (const projectile of getProjectiles()) {
57
+ * projectile.Visible = false;
58
+ * }
59
+ * ```
60
+ */
61
+ export declare function getProjectiles(matchingVariant?: ProjectileVariant | int, matchingSubType?: number): EntityProjectile[];
62
+ /**
63
+ * Helper function to get all of the slots in the room.
64
+ *
65
+ * Example:
66
+ * ```
67
+ * // Make all of the slots in the room invisible
68
+ * for (const slot of getSlots()) {
69
+ * slot.Visible = false;
70
+ * }
71
+ * ```
72
+ */
73
+ export declare function getSlots(matchingVariant?: SlotVariant | int, matchingSubType?: number): Entity[];
74
+ /**
75
+ * Helper function to get all of the tears in the room.
76
+ *
77
+ * Example:
78
+ * ```
79
+ * // Make all of the tears in the room invisible
80
+ * for (const tear of getTears()) {
81
+ * tear.Visible = false;
82
+ * }
83
+ * ```
84
+ */
85
+ export declare function getTears(matchingVariant?: TearVariant | int, matchingSubType?: number): EntityTear[];
86
+ /**
87
+ * Helper function to remove all of the bombs in the room.
88
+ *
89
+ * @param variant Optional. If specified, will only remove bombs that match this variant.
90
+ * @param subType Optional. If specified, will only remove bombs that match this sub-type.
91
+ * @param cap Optional. If specified, will only remove the given amount of bombs.
92
+ * @returns True if one or more bombs was removed, false otherwise.
93
+ */
94
+ export declare function removeAllBombs(variant?: BombVariant | int, subType?: int, cap?: int): boolean;
95
+ /**
96
+ * Helper function to remove all of the effects in the room.
97
+ *
98
+ * @param variant Optional. If specified, will only remove effects that match this variant.
99
+ * @param subType Optional. If specified, will only remove effects that match this sub-type.
100
+ * @param cap Optional. If specified, will only remove the given amount of effects.
101
+ * @returns True if one or more effects was removed, false otherwise.
102
+ */
103
+ export declare function removeAllEffects(variant?: EffectVariant | int, subType?: int, cap?: int): boolean;
104
+ /**
105
+ * Helper function to remove all of the knives in the room.
106
+ *
107
+ * @param variant Optional. If specified, will only remove knives that match this variant.
108
+ * @param subType Optional. If specified, will only remove knives that match this sub-type.
109
+ * @param cap Optional. If specified, will only remove the given amount of knives.
110
+ * @returns True if one or more knives was removed, false otherwise.
111
+ */
112
+ export declare function removeAllKnives(variant?: KnifeVariant | int, subType?: int, cap?: int): boolean;
113
+ /**
114
+ * Helper function to remove all of the lasers in the room.
115
+ *
116
+ * @param variant Optional. If specified, will only remove lasers that match this variant.
117
+ * @param subType Optional. If specified, will only remove lasers that match this sub-type.
118
+ * @param cap Optional. If specified, will only remove the given amount of lasers.
119
+ * @returns True if one or more lasers was removed, false otherwise.
120
+ */
121
+ export declare function removeAllLasers(variant?: LaserVariant | int, subType?: int, cap?: int): boolean;
122
+ /**
123
+ * Helper function to remove all of the projectiles in the room.
124
+ *
125
+ * @param variant Optional. If specified, will only remove projectiles that match this variant.
126
+ * @param subType Optional. If specified, will only remove projectiles that match this sub-type.
127
+ * @param cap Optional. If specified, will only remove the given amount of projectiles.
128
+ * @returns True if one or more projectiles was removed, false otherwise.
129
+ */
130
+ export declare function removeAllProjectiles(variant?: ProjectileVariant | int, subType?: int, cap?: int): boolean;
131
+ /**
132
+ * Helper function to remove all of the slots in the room.
133
+ *
134
+ * @param variant Optional. If specified, will only remove slots that match this variant.
135
+ * @param subType Optional. If specified, will only remove slots that match this sub-type.
136
+ * @param cap Optional. If specified, will only remove the given amount of slots.
137
+ * @returns True if one or more slots was removed, false otherwise.
138
+ */
139
+ export declare function removeAllSlots(variant?: SlotVariant | int, subType?: int, cap?: int): boolean;
140
+ /**
141
+ * Helper function to remove all of the tears in the room.
142
+ *
143
+ * @param variant Optional. If specified, will only remove tears that match this variant.
144
+ * @param subType Optional. If specified, will only remove tears that match this sub-type.
145
+ * @param cap Optional. If specified, will only remove the given amount of tears.
146
+ * @returns True if one or more tears was removed, false otherwise.
147
+ */
148
+ export declare function removeAllTears(variant?: TearVariant | int, subType?: int, cap?: int): boolean;
@@ -0,0 +1,148 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____lualib = require("lualib_bundle")
3
+ local __TS__ArrayPush = ____lualib.__TS__ArrayPush
4
+ local ____exports = {}
5
+ local ____entity = require("functions.entity")
6
+ local getEntities = ____entity.getEntities
7
+ local removeEntities = ____entity.removeEntities
8
+ function ____exports.getBombs(self, matchingVariant, matchingSubType)
9
+ if matchingVariant == nil then
10
+ matchingVariant = -1
11
+ end
12
+ if matchingSubType == nil then
13
+ matchingSubType = -1
14
+ end
15
+ local entities = getEntities(nil, EntityType.ENTITY_BOMB, matchingVariant, matchingSubType)
16
+ local bombs = {}
17
+ for ____, entity in ipairs(entities) do
18
+ local bomb = entity:ToBomb()
19
+ if bomb ~= nil then
20
+ __TS__ArrayPush(bombs, bomb)
21
+ end
22
+ end
23
+ return bombs
24
+ end
25
+ function ____exports.getEffects(self, matchingVariant, matchingSubType)
26
+ if matchingVariant == nil then
27
+ matchingVariant = -1
28
+ end
29
+ if matchingSubType == nil then
30
+ matchingSubType = -1
31
+ end
32
+ local entities = getEntities(nil, EntityType.ENTITY_EFFECT, matchingVariant, matchingSubType)
33
+ local effects = {}
34
+ for ____, entity in ipairs(entities) do
35
+ local effect = entity:ToEffect()
36
+ if effect ~= nil then
37
+ __TS__ArrayPush(effects, effect)
38
+ end
39
+ end
40
+ return effects
41
+ end
42
+ function ____exports.getKnives(self, matchingVariant, matchingSubType)
43
+ if matchingVariant == nil then
44
+ matchingVariant = -1
45
+ end
46
+ if matchingSubType == nil then
47
+ matchingSubType = -1
48
+ end
49
+ local entities = getEntities(nil, EntityType.ENTITY_KNIFE, matchingVariant, matchingSubType)
50
+ local knives = {}
51
+ for ____, entity in ipairs(entities) do
52
+ local knife = entity:ToKnife()
53
+ if knife ~= nil then
54
+ __TS__ArrayPush(knives, knife)
55
+ end
56
+ end
57
+ return knives
58
+ end
59
+ function ____exports.getLasers(self, matchingVariant, matchingSubType)
60
+ if matchingVariant == nil then
61
+ matchingVariant = -1
62
+ end
63
+ if matchingSubType == nil then
64
+ matchingSubType = -1
65
+ end
66
+ local entities = getEntities(nil, EntityType.ENTITY_LASER, matchingVariant, matchingSubType)
67
+ local lasers = {}
68
+ for ____, entity in ipairs(entities) do
69
+ local laser = entity:ToLaser()
70
+ if laser ~= nil then
71
+ __TS__ArrayPush(lasers, laser)
72
+ end
73
+ end
74
+ return lasers
75
+ end
76
+ function ____exports.getProjectiles(self, matchingVariant, matchingSubType)
77
+ if matchingVariant == nil then
78
+ matchingVariant = -1
79
+ end
80
+ if matchingSubType == nil then
81
+ matchingSubType = -1
82
+ end
83
+ local entities = getEntities(nil, EntityType.ENTITY_PROJECTILE, matchingVariant, matchingSubType)
84
+ local projectiles = {}
85
+ for ____, entity in ipairs(entities) do
86
+ local projectile = entity:ToProjectile()
87
+ if projectile ~= nil then
88
+ __TS__ArrayPush(projectiles, projectile)
89
+ end
90
+ end
91
+ return projectiles
92
+ end
93
+ function ____exports.getSlots(self, matchingVariant, matchingSubType)
94
+ if matchingVariant == nil then
95
+ matchingVariant = -1
96
+ end
97
+ if matchingSubType == nil then
98
+ matchingSubType = -1
99
+ end
100
+ local slots = getEntities(nil, EntityType.ENTITY_SLOT, matchingVariant, matchingSubType)
101
+ return slots
102
+ end
103
+ function ____exports.getTears(self, matchingVariant, matchingSubType)
104
+ if matchingVariant == nil then
105
+ matchingVariant = -1
106
+ end
107
+ if matchingSubType == nil then
108
+ matchingSubType = -1
109
+ end
110
+ local entities = getEntities(nil, EntityType.ENTITY_TEAR, matchingVariant, matchingSubType)
111
+ local tears = {}
112
+ for ____, entity in ipairs(entities) do
113
+ local tear = entity:ToTear()
114
+ if tear ~= nil then
115
+ __TS__ArrayPush(tears, tear)
116
+ end
117
+ end
118
+ return tears
119
+ end
120
+ function ____exports.removeAllBombs(self, variant, subType, cap)
121
+ local bombs = ____exports.getBombs(nil, variant, subType)
122
+ return removeEntities(nil, bombs, cap)
123
+ end
124
+ function ____exports.removeAllEffects(self, variant, subType, cap)
125
+ local effects = ____exports.getEffects(nil, variant, subType)
126
+ return removeEntities(nil, effects, cap)
127
+ end
128
+ function ____exports.removeAllKnives(self, variant, subType, cap)
129
+ local knives = ____exports.getKnives(nil, variant, subType)
130
+ return removeEntities(nil, knives, cap)
131
+ end
132
+ function ____exports.removeAllLasers(self, variant, subType, cap)
133
+ local lasers = ____exports.getLasers(nil, variant, subType)
134
+ return removeEntities(nil, lasers, cap)
135
+ end
136
+ function ____exports.removeAllProjectiles(self, variant, subType, cap)
137
+ local projectiles = ____exports.getProjectiles(nil, variant, subType)
138
+ return removeEntities(nil, projectiles, cap)
139
+ end
140
+ function ____exports.removeAllSlots(self, variant, subType, cap)
141
+ local slots = ____exports.getSlots(nil, variant, subType)
142
+ return removeEntities(nil, slots, cap)
143
+ end
144
+ function ____exports.removeAllTears(self, variant, subType, cap)
145
+ local tears = ____exports.getTears(nil, variant, subType)
146
+ return removeEntities(nil, tears, cap)
147
+ end
148
+ return ____exports
@@ -11,8 +11,9 @@ local EGGY_STATE_FRAME_OF_FINAL_SPIDER = ____constants.EGGY_STATE_FRAME_OF_FINAL
11
11
  local ____entity = require("functions.entity")
12
12
  local getEntities = ____entity.getEntities
13
13
  local getFilteredNewEntities = ____entity.getFilteredNewEntities
14
- local getProjectiles = ____entity.getProjectiles
15
14
  local removeEntities = ____entity.removeEntities
15
+ local ____entitySpecific = require("functions.entitySpecific")
16
+ local getProjectiles = ____entitySpecific.getProjectiles
16
17
  function ____exports.getAliveNPCs(self)
17
18
  local npcs = ____exports.getNPCs(nil)
18
19
  return __TS__ArrayFilter(
@@ -1,4 +1,16 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ /**
3
+ * Helper function to get all of the pickups in the room.
4
+ *
5
+ * Example:
6
+ * ```
7
+ * // Make all of the pickups in the room invisible
8
+ * for (const pickup of getPickups()) {
9
+ * pickup.Visible = false;
10
+ * }
11
+ * ```
12
+ */
13
+ export declare function getPickups(matchingVariant?: PickupVariant | int, matchingSubType?: number): EntityPickup[];
2
14
  /**
3
15
  * Has as an equal chance of returning any value in the `HeartSubType` enum. Useful for spawning a random type of heart.
4
16
  *
@@ -7,3 +19,12 @@
7
19
  */
8
20
  export declare function getRandomHeartSubType(seed?: number, exceptions?: HeartSubType[]): HeartSubType;
9
21
  export declare function isChest(pickup: EntityPickup): boolean;
22
+ /**
23
+ * Helper function to remove all of the pickups in the room.
24
+ *
25
+ * @param variant Optional. If specified, will only remove pickups that match this variant.
26
+ * @param subType Optional. If specified, will only remove pickups that match this sub-type.
27
+ * @param cap Optional. If specified, will only remove the given amount of pickups.
28
+ * @returns True if one or more pickups was removed, false otherwise.
29
+ */
30
+ export declare function removeAllPickups(variant?: PickupVariant | int, subType?: int, cap?: int): boolean;
@@ -1,12 +1,33 @@
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
+ local __TS__ArrayPush = ____lualib.__TS__ArrayPush
5
4
  local ____exports = {}
5
+ local ____constants = require("constants")
6
+ local CHEST_PICKUP_VARIANTS = ____constants.CHEST_PICKUP_VARIANTS
6
7
  local ____array = require("functions.array")
7
8
  local getRandomArrayElement = ____array.getRandomArrayElement
9
+ local ____entity = require("functions.entity")
10
+ local getEntities = ____entity.getEntities
11
+ local removeEntities = ____entity.removeEntities
8
12
  local ____utils = require("functions.utils")
9
13
  local getEnumValues = ____utils.getEnumValues
14
+ function ____exports.getPickups(self, matchingVariant, matchingSubType)
15
+ if matchingVariant == nil then
16
+ matchingVariant = -1
17
+ end
18
+ if matchingSubType == nil then
19
+ matchingSubType = -1
20
+ end
21
+ local entities = getEntities(nil, EntityType.ENTITY_PICKUP, matchingVariant, matchingSubType)
22
+ local pickups = {}
23
+ for ____, entity in ipairs(entities) do
24
+ local pickup = entity:ToPickup()
25
+ if pickup ~= nil then
26
+ __TS__ArrayPush(pickups, pickup)
27
+ end
28
+ end
29
+ return pickups
30
+ end
10
31
  function ____exports.getRandomHeartSubType(self, seed, exceptions)
11
32
  if seed == nil then
12
33
  seed = Random()
@@ -17,21 +38,11 @@ function ____exports.getRandomHeartSubType(self, seed, exceptions)
17
38
  local heartSubTypes = getEnumValues(nil, HeartSubType)
18
39
  return getRandomArrayElement(nil, heartSubTypes, seed, exceptions)
19
40
  end
20
- local CHEST_PICKUP_VARIANTS = __TS__New(Set, {
21
- PickupVariant.PICKUP_CHEST,
22
- PickupVariant.PICKUP_BOMBCHEST,
23
- PickupVariant.PICKUP_SPIKEDCHEST,
24
- PickupVariant.PICKUP_ETERNALCHEST,
25
- PickupVariant.PICKUP_MIMICCHEST,
26
- PickupVariant.PICKUP_OLDCHEST,
27
- PickupVariant.PICKUP_WOODENCHEST,
28
- PickupVariant.PICKUP_MEGACHEST,
29
- PickupVariant.PICKUP_HAUNTEDCHEST,
30
- PickupVariant.PICKUP_LOCKEDCHEST,
31
- PickupVariant.PICKUP_REDCHEST,
32
- PickupVariant.PICKUP_MOMSCHEST
33
- })
34
41
  function ____exports.isChest(self, pickup)
35
42
  return CHEST_PICKUP_VARIANTS:has(pickup.Variant)
36
43
  end
44
+ function ____exports.removeAllPickups(self, variant, subType, cap)
45
+ local pickups = ____exports.getPickups(nil, variant, subType)
46
+ return removeEntities(nil, pickups, cap)
47
+ end
37
48
  return ____exports
@@ -0,0 +1,59 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /**
3
+ * Helper function to get a room position that is not overlapping with a grid entity, a heaven door,
4
+ * or a player. The `Room.FindFreePickupSpawnPosition()` function will return locations that overlap
5
+ * with heaven doors and partially overlap with players, if the thing being spawned is bigger than a
6
+ * tile (like a Blood Donation Machine). Use this function instead if you want to account for those
7
+ * specific situations.
8
+ *
9
+ * @param startingPosition The position to start searching from. If this position is not overlapping
10
+ * with anything, then it will be returned.
11
+ * @param avoidActiveEntities Optional. False by default.
12
+ */
13
+ export declare function findFreePosition(startingPosition: Vector, avoidActiveEntities?: boolean): Vector;
14
+ /**
15
+ * Helper function to get a map containing the positions of every entity in the current room.
16
+ *
17
+ * This is useful for rewinding entity positions at a later time. Also see `setEntityPositions()`.
18
+ *
19
+ * @param entities Optional. If provided, will only get the positions of the provided entities. This
20
+ * can be used to cache the entities to avoid invoking `Isaac.GetRoomEntities()` multiple times.
21
+ */
22
+ export declare function getEntityPositions(entities?: Entity[]): Map<PtrHash, Vector>;
23
+ /**
24
+ * Helper function to get a map containing the velocities of every entity in the current room.
25
+ *
26
+ * This is useful for rewinding entity velocities at a later time. Also see `setEntityVelocities()`.
27
+ *
28
+ * @param entities Optional. If provided, will only get the velocities of the provided entities.
29
+ * This can be used to cache the entities to avoid invoking `Isaac.GetRoomEntities()` multiple
30
+ * times.
31
+ */
32
+ export declare function getEntityVelocities(entities?: Entity[]): Map<PtrHash, Vector>;
33
+ /**
34
+ * Helper function to set the position of every entity in the room based on a map of positions. If
35
+ * an entity is found that does not have matching element in the provided map, then that entity will
36
+ * be skipped.
37
+ *
38
+ * This function is useful for rewinding entity positions at a later time. Also see
39
+ * `getEntityPositions()`.
40
+ *
41
+ * @param entityPositions The map providing the positions for every entity.
42
+ * @param entities Optional. If provided, will only set the positions of the provided entities. This
43
+ * can be used to cache the entities to avoid invoking `Isaac.GetRoomEntities()` multiple times.
44
+ */
45
+ export declare function setEntityPositions(entityPositions: Map<PtrHash, Vector>, entities?: Entity[]): void;
46
+ /**
47
+ * Helper function to set the velocity of every entity in the room based on a map of velocities. If
48
+ * an entity is found that does not have matching element in the provided map, then that entity will
49
+ * be skipped.
50
+ *
51
+ * This function is useful for rewinding entity velocities at a later time. Also see
52
+ * `getEntityVelocities()`.
53
+ *
54
+ * @param entityVelocities The map providing the velocities for every entity.
55
+ * @param entities Optional. If provided, will only set the velocities of the provided entities.
56
+ * This can be used to cache the entities to avoid invoking `Isaac.GetRoomEntities()` multiple
57
+ * times.
58
+ */
59
+ export declare function setEntityVelocities(entityVelocities: Map<PtrHash, Vector>, entities?: Entity[]): void;
@@ -0,0 +1,90 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____lualib = require("lualib_bundle")
3
+ local Map = ____lualib.Map
4
+ local __TS__New = ____lualib.__TS__New
5
+ local ____exports = {}
6
+ local ____constants = require("constants")
7
+ local DISTANCE_OF_GRID_TILE = ____constants.DISTANCE_OF_GRID_TILE
8
+ local ____entity = require("functions.entity")
9
+ local anyEntityCloserThan = ____entity.anyEntityCloserThan
10
+ local getEntities = ____entity.getEntities
11
+ local ____entitySpecific = require("functions.entitySpecific")
12
+ local getEffects = ____entitySpecific.getEffects
13
+ local ____player = require("functions.player")
14
+ local getPlayerCloserThan = ____player.getPlayerCloserThan
15
+ local MAX_FIND_FREE_POSITION_ATTEMPTS = 100
16
+ function ____exports.findFreePosition(self, startingPosition, avoidActiveEntities)
17
+ if avoidActiveEntities == nil then
18
+ avoidActiveEntities = false
19
+ end
20
+ local game = Game()
21
+ local room = game:GetRoom()
22
+ local heavenDoors = getEffects(nil, EffectVariant.HEAVEN_LIGHT_DOOR, 0)
23
+ do
24
+ local i = 0
25
+ while i < MAX_FIND_FREE_POSITION_ATTEMPTS do
26
+ do
27
+ local position = room:FindFreePickupSpawnPosition(startingPosition, i, avoidActiveEntities)
28
+ local closePlayer = getPlayerCloserThan(nil, position, DISTANCE_OF_GRID_TILE)
29
+ if closePlayer ~= nil then
30
+ goto __continue3
31
+ end
32
+ local isCloseHeavenDoor = anyEntityCloserThan(nil, heavenDoors, position, DISTANCE_OF_GRID_TILE)
33
+ if isCloseHeavenDoor then
34
+ goto __continue3
35
+ end
36
+ return position
37
+ end
38
+ ::__continue3::
39
+ i = i + 1
40
+ end
41
+ end
42
+ return room:FindFreePickupSpawnPosition(startingPosition)
43
+ end
44
+ function ____exports.getEntityPositions(self, entities)
45
+ if entities == nil then
46
+ entities = getEntities(nil)
47
+ end
48
+ local entityPositions = __TS__New(Map)
49
+ for ____, entity in ipairs(entities) do
50
+ local ptrHash = GetPtrHash(entity)
51
+ entityPositions:set(ptrHash, entity.Position)
52
+ end
53
+ return entityPositions
54
+ end
55
+ function ____exports.getEntityVelocities(self, entities)
56
+ if entities == nil then
57
+ entities = getEntities(nil)
58
+ end
59
+ local entityVelocities = __TS__New(Map)
60
+ for ____, entity in ipairs(entities) do
61
+ local ptrHash = GetPtrHash(entity)
62
+ entityVelocities:set(ptrHash, entity.Velocity)
63
+ end
64
+ return entityVelocities
65
+ end
66
+ function ____exports.setEntityPositions(self, entityPositions, entities)
67
+ if entities == nil then
68
+ entities = getEntities(nil)
69
+ end
70
+ for ____, entity in ipairs(entities) do
71
+ local ptrHash = GetPtrHash(entity)
72
+ local entityPosition = entityPositions:get(ptrHash)
73
+ if entityPosition ~= nil then
74
+ entity.Position = entityPosition
75
+ end
76
+ end
77
+ end
78
+ function ____exports.setEntityVelocities(self, entityVelocities, entities)
79
+ if entities == nil then
80
+ entities = getEntities(nil)
81
+ end
82
+ for ____, entity in ipairs(entities) do
83
+ local ptrHash = GetPtrHash(entity)
84
+ local entityVelocity = entityVelocities:get(ptrHash)
85
+ if entityVelocity ~= nil then
86
+ entity.Velocity = entityVelocity
87
+ end
88
+ end
89
+ end
90
+ return ____exports
@@ -21,14 +21,15 @@ local isHiddenSecretRoomDoor = ____doors.isHiddenSecretRoomDoor
21
21
  local openDoorFast = ____doors.openDoorFast
22
22
  local ____entity = require("functions.entity")
23
23
  local getEntities = ____entity.getEntities
24
- local getEntityPositions = ____entity.getEntityPositions
25
- local getEntityVelocities = ____entity.getEntityVelocities
26
- local setEntityPositions = ____entity.setEntityPositions
27
- local setEntityVelocities = ____entity.setEntityVelocities
28
24
  local ____flag = require("functions.flag")
29
25
  local hasFlag = ____flag.hasFlag
30
26
  local ____math = require("functions.math")
31
27
  local range = ____math.range
28
+ local ____positionVelocity = require("functions.positionVelocity")
29
+ local getEntityPositions = ____positionVelocity.getEntityPositions
30
+ local getEntityVelocities = ____positionVelocity.getEntityVelocities
31
+ local setEntityPositions = ____positionVelocity.setEntityPositions
32
+ local setEntityVelocities = ____positionVelocity.setEntityVelocities
32
33
  function ____exports.getCurrentRoomDescriptorReadOnly(self)
33
34
  local game = Game()
34
35
  local level = game:GetLevel()
@@ -6,10 +6,10 @@ local ____trinketDescriptionMap = require("maps.trinketDescriptionMap")
6
6
  local TRINKET_DESCRIPTION_MAP = ____trinketDescriptionMap.TRINKET_DESCRIPTION_MAP
7
7
  local ____trinketNameMap = require("maps.trinketNameMap")
8
8
  local TRINKET_NAME_MAP = ____trinketNameMap.TRINKET_NAME_MAP
9
- local ____entity = require("functions.entity")
10
- local getPickups = ____entity.getPickups
11
9
  local ____flag = require("functions.flag")
12
10
  local hasFlag = ____flag.hasFlag
11
+ local ____pickups = require("functions.pickups")
12
+ local getPickups = ____pickups.getPickups
13
13
  local ____player = require("functions.player")
14
14
  local useActiveItemTemp = ____player.useActiveItemTemp
15
15
  local ____trinketGive = require("functions.trinketGive")
package/dist/index.d.ts CHANGED
@@ -22,6 +22,7 @@ export { deepCopy } from "./functions/deepCopy";
22
22
  export { deepCopyTests } from "./functions/deepCopyTests";
23
23
  export * from "./functions/doors";
24
24
  export * from "./functions/entity";
25
+ export * from "./functions/entitySpecific";
25
26
  export * from "./functions/familiars";
26
27
  export * from "./functions/flag";
27
28
  export * from "./functions/flying";
@@ -40,7 +41,7 @@ export * from "./functions/pills";
40
41
  export * from "./functions/player";
41
42
  export * from "./functions/playerHealth";
42
43
  export * from "./functions/pocketItems";
43
- export * from "./functions/position";
44
+ export * from "./functions/positionVelocity";
44
45
  export * from "./functions/random";
45
46
  export * from "./functions/revive";
46
47
  export * from "./functions/rooms";
package/dist/index.lua CHANGED
@@ -186,6 +186,14 @@ do
186
186
  end
187
187
  end
188
188
  end
189
+ do
190
+ local ____export = require("functions.entitySpecific")
191
+ for ____exportKey, ____exportValue in pairs(____export) do
192
+ if ____exportKey ~= "default" then
193
+ ____exports[____exportKey] = ____exportValue
194
+ end
195
+ end
196
+ end
189
197
  do
190
198
  local ____export = require("functions.familiars")
191
199
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -331,7 +339,7 @@ do
331
339
  end
332
340
  end
333
341
  do
334
- local ____export = require("functions.position")
342
+ local ____export = require("functions.positionVelocity")
335
343
  for ____exportKey, ____exportValue in pairs(____export) do
336
344
  if ____exportKey ~= "default" then
337
345
  ____exports[____exportKey] = ____exportValue
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.78",
3
+ "version": "1.2.79",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",