isaacscript-common 6.6.3 → 6.7.0
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.
- package/dist/callbacks/customRevive.lua +4 -4
- package/dist/callbacks/postCursedTeleport.lua +2 -2
- package/dist/callbacks/postCustomDoorEnter.d.ts +1 -1
- package/dist/callbacks/postCustomDoorEnter.lua +6 -6
- package/dist/callbacks/postDiceRoomActivated.lua +2 -2
- package/dist/callbacks/postFlip.lua +3 -3
- package/dist/callbacks/postGridEntity.lua +3 -3
- package/dist/callbacks/postGridEntityCollision.lua +3 -3
- package/dist/callbacks/postGridEntityRender.lua +2 -2
- package/dist/callbacks/postNewRoomEarly.lua +5 -5
- package/dist/callbacks/postPickupCollect.lua +2 -2
- package/dist/callbacks/postPitRender.lua +2 -2
- package/dist/callbacks/postPitUpdate.lua +2 -2
- package/dist/callbacks/postPlayerCollectible.lua +2 -2
- package/dist/callbacks/postPoopRender.lua +2 -2
- package/dist/callbacks/postPoopUpdate.lua +2 -2
- package/dist/callbacks/postPressurePlateRender.lua +2 -2
- package/dist/callbacks/postPressurePlateUpdate.lua +2 -2
- package/dist/callbacks/postPurchase.lua +2 -2
- package/dist/callbacks/postRockRender.lua +2 -2
- package/dist/callbacks/postRockUpdate.lua +2 -2
- package/dist/callbacks/postSlotInitUpdate.lua +2 -2
- package/dist/callbacks/postSlotRender.lua +2 -2
- package/dist/callbacks/postSpikesRender.lua +2 -2
- package/dist/callbacks/postSpikesUpdate.lua +2 -2
- package/dist/callbacks/postTNTRender.lua +2 -2
- package/dist/callbacks/postTNTUpdate.lua +2 -2
- package/dist/callbacks/preBerserkDeath.lua +2 -2
- package/dist/callbacks/preNewLevel.lua +2 -2
- package/dist/callbacks/subscriptions/postDoorRender.d.ts +2 -3
- package/dist/callbacks/subscriptions/postDoorRender.d.ts.map +1 -1
- package/dist/callbacks/subscriptions/postDoorRender.lua +3 -3
- package/dist/callbacks/subscriptions/postDoorUpdate.d.ts +2 -3
- package/dist/callbacks/subscriptions/postDoorUpdate.d.ts.map +1 -1
- package/dist/callbacks/subscriptions/postDoorUpdate.lua +3 -3
- package/dist/callbacks/subscriptions/postPitRender.d.ts +2 -3
- package/dist/callbacks/subscriptions/postPitRender.d.ts.map +1 -1
- package/dist/callbacks/subscriptions/postPitRender.lua +3 -3
- package/dist/callbacks/subscriptions/postPitUpdate.d.ts +2 -3
- package/dist/callbacks/subscriptions/postPitUpdate.d.ts.map +1 -1
- package/dist/callbacks/subscriptions/postPitUpdate.lua +3 -3
- package/dist/callbacks/subscriptions/postPoopRender.d.ts +2 -3
- package/dist/callbacks/subscriptions/postPoopRender.d.ts.map +1 -1
- package/dist/callbacks/subscriptions/postPoopRender.lua +3 -3
- package/dist/callbacks/subscriptions/postPoopUpdate.d.ts +2 -3
- package/dist/callbacks/subscriptions/postPoopUpdate.d.ts.map +1 -1
- package/dist/callbacks/subscriptions/postPoopUpdate.lua +3 -3
- package/dist/callbacks/subscriptions/postPressurePlateRender.d.ts +2 -3
- package/dist/callbacks/subscriptions/postPressurePlateRender.d.ts.map +1 -1
- package/dist/callbacks/subscriptions/postPressurePlateRender.lua +3 -3
- package/dist/callbacks/subscriptions/postPressurePlateUpdate.d.ts +2 -3
- package/dist/callbacks/subscriptions/postPressurePlateUpdate.d.ts.map +1 -1
- package/dist/callbacks/subscriptions/postPressurePlateUpdate.lua +3 -3
- package/dist/enums/private/SerializationBrand.d.ts +0 -4
- package/dist/enums/private/SerializationBrand.d.ts.map +1 -1
- package/dist/features/characterStats.lua +2 -2
- package/dist/features/collectibleItemPoolType.lua +2 -2
- package/dist/features/customGridEntity.d.ts.map +1 -1
- package/dist/features/customGridEntity.lua +5 -5
- package/dist/features/customStage/backdrop.lua +2 -2
- package/dist/features/customStage/{gridEntities.d.ts → customStageGridEntities.d.ts} +1 -1
- package/dist/features/customStage/customStageGridEntities.d.ts.map +1 -0
- package/dist/features/customStage/{gridEntities.lua → customStageGridEntities.lua} +8 -8
- package/dist/features/customStage/{util.d.ts → customStageUtils.d.ts} +1 -1
- package/dist/features/customStage/customStageUtils.d.ts.map +1 -0
- package/dist/features/customStage/{util.lua → customStageUtils.lua} +0 -0
- package/dist/features/customStage/exports.lua +4 -4
- package/dist/features/customStage/init.lua +6 -6
- package/dist/features/customStage/shadows.lua +2 -2
- package/dist/features/customStage/versusScreen.lua +4 -4
- package/dist/features/debugDisplay/v.lua +4 -4
- package/dist/features/deployJSONRoom.lua +20 -20
- package/dist/features/extraConsoleCommands/commandsSubroutines.lua +3 -3
- package/dist/features/extraConsoleCommands/listCommands.d.ts.map +1 -1
- package/dist/features/extraConsoleCommands/listCommands.lua +14 -14
- package/dist/features/pause.lua +2 -2
- package/dist/features/persistentEntities.lua +2 -2
- package/dist/features/preventCollectibleRotation.lua +2 -2
- package/dist/features/saveDataManager/exports.d.ts.map +1 -1
- package/dist/features/saveDataManager/merge.lua +4 -3
- package/dist/features/sirenHelpers.lua +2 -2
- package/dist/functions/ambush.lua +5 -5
- package/dist/functions/array.d.ts.map +1 -1
- package/dist/functions/array.lua +1 -1
- package/dist/functions/{boss.d.ts → bosses.d.ts} +22 -4
- package/dist/functions/bosses.d.ts.map +1 -0
- package/dist/functions/{boss.lua → bosses.lua} +38 -13
- package/dist/functions/collectibleTag.lua +2 -2
- package/dist/functions/collectibles.lua +5 -5
- package/dist/functions/deepCopy.d.ts +8 -5
- package/dist/functions/deepCopy.d.ts.map +1 -1
- package/dist/functions/deepCopy.lua +142 -38
- package/dist/functions/deepCopyTests.d.ts +6 -1
- package/dist/functions/deepCopyTests.d.ts.map +1 -1
- package/dist/functions/deepCopyTests.lua +19 -16
- package/dist/functions/{entity.d.ts → entities.d.ts} +21 -19
- package/dist/functions/entities.d.ts.map +1 -0
- package/dist/functions/{entity.lua → entities.lua} +25 -20
- package/dist/functions/{entitySpecific.d.ts → entitiesSpecific.d.ts} +145 -68
- package/dist/functions/entitiesSpecific.d.ts.map +1 -0
- package/dist/functions/{entitySpecific.lua → entitiesSpecific.lua} +203 -65
- package/dist/functions/familiars.lua +2 -2
- package/dist/functions/{gridEntity.d.ts → gridEntities.d.ts} +48 -17
- package/dist/functions/gridEntities.d.ts.map +1 -0
- package/dist/functions/{gridEntity.lua → gridEntities.lua} +140 -90
- package/dist/functions/gridEntitiesSpecific.d.ts +141 -0
- package/dist/functions/gridEntitiesSpecific.d.ts.map +1 -0
- package/dist/functions/gridEntitiesSpecific.lua +366 -0
- package/dist/functions/log.d.ts +1 -1
- package/dist/functions/log.d.ts.map +1 -1
- package/dist/functions/log.lua +16 -12
- package/dist/functions/mergeTests.d.ts +7 -1
- package/dist/functions/mergeTests.d.ts.map +1 -1
- package/dist/functions/mergeTests.lua +86 -7
- package/dist/functions/{npc.d.ts → npcs.d.ts} +24 -2
- package/dist/functions/npcs.d.ts.map +1 -0
- package/dist/functions/{npc.lua → npcs.lua} +44 -9
- package/dist/functions/pickups.d.ts +4 -119
- package/dist/functions/pickups.d.ts.map +1 -1
- package/dist/functions/pickups.lua +10 -439
- package/dist/functions/pickupsSpecific.d.ts +229 -0
- package/dist/functions/pickupsSpecific.d.ts.map +1 -0
- package/dist/functions/pickupsSpecific.lua +560 -0
- package/dist/functions/playerHealth.lua +6 -6
- package/dist/functions/{player.d.ts → players.d.ts} +1 -1
- package/dist/functions/players.d.ts.map +1 -0
- package/dist/functions/{player.lua → players.lua} +0 -0
- package/dist/functions/pocketItems.lua +2 -2
- package/dist/functions/positionVelocity.lua +6 -6
- package/dist/functions/pressurePlate.d.ts +10 -0
- package/dist/functions/pressurePlate.d.ts.map +1 -0
- package/dist/functions/pressurePlate.lua +29 -0
- package/dist/functions/revive.lua +7 -7
- package/dist/functions/rooms.lua +2 -2
- package/dist/functions/saveFile.lua +3 -3
- package/dist/functions/spawnCollectible.lua +4 -4
- package/dist/functions/{sprite.d.ts → sprites.d.ts} +1 -1
- package/dist/functions/sprites.d.ts.map +1 -0
- package/dist/functions/{sprite.lua → sprites.lua} +0 -0
- package/dist/functions/table.d.ts +1 -1
- package/dist/functions/table.lua +1 -1
- package/dist/functions/transformations.lua +2 -2
- package/dist/functions/trinketGive.lua +2 -2
- package/dist/functions/trinkets.lua +6 -6
- package/dist/functions/utils.d.ts +7 -0
- package/dist/functions/utils.d.ts.map +1 -1
- package/dist/functions/utils.lua +35 -22
- package/dist/index.d.ts +10 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.lua +26 -10
- package/dist/types/AnyGridEntity.d.ts +10 -0
- package/dist/types/AnyGridEntity.d.ts.map +1 -0
- package/dist/types/AnyGridEntity.lua +2 -0
- package/package.json +2 -2
- package/src/callbacks/customRevive.ts +2 -2
- package/src/callbacks/postCursedTeleport.ts +2 -2
- package/src/callbacks/postCustomDoorEnter.ts +3 -3
- package/src/callbacks/postDiceRoomActivated.ts +1 -1
- package/src/callbacks/postFlip.ts +1 -1
- package/src/callbacks/postGridEntity.ts +1 -1
- package/src/callbacks/postGridEntityCollision.ts +1 -1
- package/src/callbacks/postGridEntityRender.ts +1 -1
- package/src/callbacks/postNewRoomEarly.ts +9 -3
- package/src/callbacks/postPickupCollect.ts +1 -1
- package/src/callbacks/postPitRender.ts +1 -1
- package/src/callbacks/postPitUpdate.ts +1 -1
- package/src/callbacks/postPlayerCollectible.ts +2 -2
- package/src/callbacks/postPoopRender.ts +1 -1
- package/src/callbacks/postPoopUpdate.ts +1 -1
- package/src/callbacks/postPressurePlateRender.ts +1 -1
- package/src/callbacks/postPressurePlateUpdate.ts +1 -1
- package/src/callbacks/postPurchase.ts +1 -1
- package/src/callbacks/postRockRender.ts +1 -1
- package/src/callbacks/postRockUpdate.ts +1 -1
- package/src/callbacks/postSacrifice.ts +1 -1
- package/src/callbacks/postSlotInitUpdate.ts +1 -1
- package/src/callbacks/postSlotRender.ts +1 -1
- package/src/callbacks/postSpikesRender.ts +1 -1
- package/src/callbacks/postSpikesUpdate.ts +1 -1
- package/src/callbacks/postTNTRender.ts +1 -1
- package/src/callbacks/postTNTUpdate.ts +1 -1
- package/src/callbacks/preBerserkDeath.ts +1 -1
- package/src/callbacks/preNewLevel.ts +1 -1
- package/src/callbacks/subscriptions/postDoorRender.ts +7 -5
- package/src/callbacks/subscriptions/postDoorUpdate.ts +7 -5
- package/src/callbacks/subscriptions/postPitRender.ts +6 -7
- package/src/callbacks/subscriptions/postPitUpdate.ts +6 -7
- package/src/callbacks/subscriptions/postPoopRender.ts +7 -5
- package/src/callbacks/subscriptions/postPoopUpdate.ts +7 -5
- package/src/callbacks/subscriptions/postPressurePlateRender.ts +7 -5
- package/src/callbacks/subscriptions/postPressurePlateUpdate.ts +7 -5
- package/src/enums/private/SerializationBrand.ts +0 -4
- package/src/features/characterStats.ts +1 -1
- package/src/features/collectibleItemPoolType.ts +1 -1
- package/src/features/customGridEntity.ts +6 -3
- package/src/features/customStage/backdrop.ts +1 -1
- package/src/features/customStage/{gridEntities.ts → customStageGridEntities.ts} +3 -3
- package/src/features/customStage/{util.ts → customStageUtils.ts} +0 -0
- package/src/features/customStage/exports.ts +2 -2
- package/src/features/customStage/init.ts +1 -1
- package/src/features/customStage/shadows.ts +1 -1
- package/src/features/customStage/versusScreen.ts +2 -2
- package/src/features/debugDisplay/v.ts +2 -2
- package/src/features/deployJSONRoom.ts +11 -7
- package/src/features/extraConsoleCommands/commandsSubroutines.ts +2 -2
- package/src/features/extraConsoleCommands/listCommands.ts +13 -9
- package/src/features/pause.ts +1 -1
- package/src/features/persistentEntities.ts +2 -2
- package/src/features/preventCollectibleRotation.ts +1 -1
- package/src/features/saveDataManager/exports.ts +7 -4
- package/src/features/saveDataManager/merge.ts +3 -3
- package/src/features/sirenHelpers.ts +1 -1
- package/src/functions/ambush.ts +2 -2
- package/src/functions/array.ts +5 -2
- package/src/functions/bitwise.ts +2 -2
- package/src/functions/{boss.ts → bosses.ts} +29 -21
- package/src/functions/collectibleTag.ts +1 -1
- package/src/functions/collectibles.ts +2 -2
- package/src/functions/deepCopy.ts +98 -19
- package/src/functions/deepCopyTests.ts +75 -19
- package/src/functions/{entity.ts → entities.ts} +23 -21
- package/src/functions/{entitySpecific.ts → entitiesSpecific.ts} +170 -99
- package/src/functions/familiars.ts +1 -1
- package/src/functions/{gridEntity.ts → gridEntities.ts} +110 -34
- package/src/functions/gridEntitiesSpecific.ts +490 -0
- package/src/functions/log.ts +19 -10
- package/src/functions/mergeTests.ts +152 -4
- package/src/functions/{npc.ts → npcs.ts} +42 -11
- package/src/functions/pickups.ts +8 -475
- package/src/functions/pickupsSpecific.ts +613 -0
- package/src/functions/playerHealth.ts +1 -1
- package/src/functions/{player.ts → players.ts} +0 -0
- package/src/functions/pocketItems.ts +1 -1
- package/src/functions/positionVelocity.ts +3 -3
- package/src/functions/pressurePlate.ts +29 -0
- package/src/functions/revive.ts +2 -2
- package/src/functions/rooms.ts +1 -1
- package/src/functions/saveFile.ts +1 -1
- package/src/functions/spawnCollectible.ts +2 -2
- package/src/functions/{sprite.ts → sprites.ts} +0 -0
- package/src/functions/table.ts +1 -1
- package/src/functions/transformations.ts +1 -1
- package/src/functions/trinketGive.ts +4 -4
- package/src/functions/trinkets.ts +3 -3
- package/src/functions/tstlClass.ts +1 -1
- package/src/functions/ui.ts +3 -3
- package/src/functions/utils.ts +32 -13
- package/src/index.ts +10 -8
- package/src/types/AnyGridEntity.ts +9 -0
- package/dist/features/customStage/gridEntities.d.ts.map +0 -1
- package/dist/features/customStage/util.d.ts.map +0 -1
- package/dist/functions/boss.d.ts.map +0 -1
- package/dist/functions/entity.d.ts.map +0 -1
- package/dist/functions/entitySpecific.d.ts.map +0 -1
- package/dist/functions/gridEntity.d.ts.map +0 -1
- package/dist/functions/gridEntitySpecific.d.ts +0 -29
- package/dist/functions/gridEntitySpecific.d.ts.map +0 -1
- package/dist/functions/gridEntitySpecific.lua +0 -114
- package/dist/functions/npc.d.ts.map +0 -1
- package/dist/functions/player.d.ts.map +0 -1
- package/dist/functions/sprite.d.ts.map +0 -1
- package/src/functions/gridEntitySpecific.ts +0 -143
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CrawlSpaceVariant,
|
|
2
3
|
GridCollisionClass,
|
|
3
4
|
GridEntityType,
|
|
4
5
|
GridEntityXMLType,
|
|
@@ -16,10 +17,12 @@ import {
|
|
|
16
17
|
ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP,
|
|
17
18
|
} from "../maps/roomShapeToTopLeftWallGridIndexMap";
|
|
18
19
|
import { BACKDROP_TYPE_TO_ROCK_ALT_TYPE } from "../objects/backdropTypeToRockAltType";
|
|
20
|
+
import { AnyGridEntity } from "../types/AnyGridEntity";
|
|
19
21
|
import { isCircleIntersectingRectangle } from "./math";
|
|
20
22
|
import { getRandomSeed } from "./rng";
|
|
21
23
|
import { roomUpdateSafe } from "./rooms";
|
|
22
|
-
import { clearSprite } from "./
|
|
24
|
+
import { clearSprite } from "./sprites";
|
|
25
|
+
import { isNumber } from "./types";
|
|
23
26
|
import { erange } from "./utils";
|
|
24
27
|
import { isVector } from "./vector";
|
|
25
28
|
|
|
@@ -127,6 +130,22 @@ export function getCollidingEntitiesWithGridEntity(
|
|
|
127
130
|
);
|
|
128
131
|
}
|
|
129
132
|
|
|
133
|
+
/**
|
|
134
|
+
* Helper function to get all of the crawl spaces in the room.
|
|
135
|
+
*
|
|
136
|
+
* @param crawlSpaceVariant Optional. If specified, will only get the crawl spaces that match the
|
|
137
|
+
* variant. Default is -1, which matches every variant.
|
|
138
|
+
*/
|
|
139
|
+
export function getCrawlSpaces(
|
|
140
|
+
crawlSpaceVariant: CrawlSpaceVariant = -1,
|
|
141
|
+
): GridEntity[] {
|
|
142
|
+
if ((crawlSpaceVariant as int) === -1) {
|
|
143
|
+
return getGridEntities(GridEntityType.CRAWL_SPACE);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return getMatchingGridEntities(GridEntityType.CRAWL_SPACE, crawlSpaceVariant);
|
|
147
|
+
}
|
|
148
|
+
|
|
130
149
|
/**
|
|
131
150
|
* Helper function to get every grid entity in the current room.
|
|
132
151
|
*
|
|
@@ -245,6 +264,8 @@ export function getGridEntityIDFromConstituents(
|
|
|
245
264
|
/**
|
|
246
265
|
* Helper function to get all of the grid entities in the room that specifically match the type and
|
|
247
266
|
* variant provided.
|
|
267
|
+
*
|
|
268
|
+
* If you want to match every variant, use the `getGridEntities` function instead.
|
|
248
269
|
*/
|
|
249
270
|
export function getMatchingGridEntities(
|
|
250
271
|
gridEntityType: GridEntityType,
|
|
@@ -329,6 +350,25 @@ export function getTopLeftWallGridIndex(): int {
|
|
|
329
350
|
: topLeftWallGridIndex;
|
|
330
351
|
}
|
|
331
352
|
|
|
353
|
+
/**
|
|
354
|
+
* Helper function to get all of the grid entities of type `GridEntityType.TRAPDOOR` in the room.
|
|
355
|
+
* Specify a specific trapdoor variant to select only trapdoors of that variant.
|
|
356
|
+
*/
|
|
357
|
+
export function getTrapdoors(trapdoorVariant?: TrapdoorVariant): GridEntity[] {
|
|
358
|
+
if (trapdoorVariant === undefined) {
|
|
359
|
+
return getGridEntities(GridEntityType.TRAPDOOR);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return getMatchingGridEntities(GridEntityType.TRAPDOOR, trapdoorVariant);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Helper function to see if the provided gridEntity is in its respective broken state. See the
|
|
367
|
+
* `GRID_ENTITY_TYPE_TO_BROKEN_STATE_MAP` constant for more details.
|
|
368
|
+
*
|
|
369
|
+
* Note that in the case of `GridEntityType.LOCK` (11), the state will turn to being broken before
|
|
370
|
+
* the actual collision for the entity is removed.
|
|
371
|
+
*/
|
|
332
372
|
export function isGridEntityBreakableByExplosion(
|
|
333
373
|
gridEntity: GridEntity,
|
|
334
374
|
): boolean {
|
|
@@ -345,11 +385,9 @@ export function isGridEntityBreakableByExplosion(
|
|
|
345
385
|
}
|
|
346
386
|
|
|
347
387
|
/**
|
|
348
|
-
* Helper function to
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
* Note that in the case of `GridEntityType.LOCK` (11), the state will turn to being broken before
|
|
352
|
-
* the actual collision for the entity is removed.
|
|
388
|
+
* Helper function to detect whether a given Void Portal is one that randomly spawns after a boss is
|
|
389
|
+
* defeated or is one that naturally spawns in the room after Hush. (This is determined by looking
|
|
390
|
+
* at the VarData of the entity.)
|
|
353
391
|
*/
|
|
354
392
|
export function isGridEntityBroken(gridEntity: GridEntity): boolean {
|
|
355
393
|
const gridEntityType = gridEntity.GetType();
|
|
@@ -358,9 +396,8 @@ export function isGridEntityBroken(gridEntity: GridEntity): boolean {
|
|
|
358
396
|
}
|
|
359
397
|
|
|
360
398
|
/**
|
|
361
|
-
* Helper function to
|
|
362
|
-
*
|
|
363
|
-
* at the VarData of the entity.)
|
|
399
|
+
* Helper function to determine if all of the pressure plates in the current room are pushed.
|
|
400
|
+
* Returns true if there are no pressure plates in the room.
|
|
364
401
|
*/
|
|
365
402
|
export function isPostBossVoidPortal(gridEntity: GridEntity): boolean {
|
|
366
403
|
// - The VarData of Void Portals that are spawned after bosses will be equal to 1.
|
|
@@ -385,7 +422,7 @@ export function isPostBossVoidPortal(gridEntity: GridEntity): boolean {
|
|
|
385
422
|
* );
|
|
386
423
|
* ```
|
|
387
424
|
*
|
|
388
|
-
* @returns
|
|
425
|
+
* @returns The grid entities that were removed.
|
|
389
426
|
*/
|
|
390
427
|
export function removeAllGridExcept(
|
|
391
428
|
...gridEntityTypes: GridEntityType[]
|
|
@@ -396,7 +433,7 @@ export function removeAllGridExcept(
|
|
|
396
433
|
for (const gridEntity of gridEntities) {
|
|
397
434
|
const gridEntityType = gridEntity.GetType();
|
|
398
435
|
if (!gridEntityTypeExceptions.has(gridEntityType)) {
|
|
399
|
-
|
|
436
|
+
removeGridEntity(gridEntity, false);
|
|
400
437
|
removedGridEntities.push(gridEntity);
|
|
401
438
|
}
|
|
402
439
|
}
|
|
@@ -436,7 +473,7 @@ export function removeAllMatchingGridEntities(
|
|
|
436
473
|
}
|
|
437
474
|
|
|
438
475
|
for (const gridEntity of gridEntities) {
|
|
439
|
-
|
|
476
|
+
removeGridEntity(gridEntity, false);
|
|
440
477
|
}
|
|
441
478
|
|
|
442
479
|
roomUpdateSafe();
|
|
@@ -444,24 +481,63 @@ export function removeAllMatchingGridEntities(
|
|
|
444
481
|
}
|
|
445
482
|
|
|
446
483
|
/**
|
|
447
|
-
* Helper function to remove
|
|
448
|
-
*
|
|
484
|
+
* Helper function to remove all of the grid entities in the supplied array.
|
|
485
|
+
*
|
|
486
|
+
* @param gridEntities The array of grid entities to remove.
|
|
487
|
+
* @param updateRoom Whether or not to update the room after the grid entities are removed. This is
|
|
488
|
+
* generally a good idea because if the room is not updated, you will be unable to
|
|
489
|
+
* spawn another grid entity on the same tile until a frame has passed. However,
|
|
490
|
+
* doing this is expensive, since it involves a call to `Isaac.GetRoomEntities`,
|
|
491
|
+
* so set this to false if you need to invoke this function multiple times.
|
|
492
|
+
* @param cap Optional. If specified, will only remove the given amount of entities.
|
|
493
|
+
* @returns An array of the entities that were removed.
|
|
494
|
+
*/
|
|
495
|
+
export function removeGridEntities<T extends AnyGridEntity>(
|
|
496
|
+
gridEntities: T[],
|
|
497
|
+
updateRoom: boolean,
|
|
498
|
+
cap?: int,
|
|
499
|
+
): T[] {
|
|
500
|
+
if (gridEntities.length === 0) {
|
|
501
|
+
return [];
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
const gridEntitiesRemoved: T[] = [];
|
|
505
|
+
for (const gridEntity of gridEntities) {
|
|
506
|
+
removeGridEntity(gridEntity, false);
|
|
507
|
+
|
|
508
|
+
gridEntitiesRemoved.push(gridEntity);
|
|
509
|
+
if (cap !== undefined && gridEntitiesRemoved.length >= cap) {
|
|
510
|
+
break;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
if (updateRoom) {
|
|
515
|
+
roomUpdateSafe();
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
return gridEntitiesRemoved;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Helper function to remove a grid entity by providing the grid entity object or the grid index
|
|
523
|
+
* inside of the room.
|
|
449
524
|
*
|
|
450
525
|
* @param gridEntityOrGridIndex The grid entity or grid index to remove.
|
|
451
|
-
* @param updateRoom
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
455
|
-
*
|
|
456
|
-
* function multiple times.
|
|
526
|
+
* @param updateRoom Whether or not to update the room after the grid entity is removed. This is
|
|
527
|
+
* generally a good idea because if the room is not updated, you will be unable to
|
|
528
|
+
* spawn another grid entity on the same tile until a frame has passed. However,
|
|
529
|
+
* doing this is expensive, since it involves a call to `Isaac.GetRoomEntities`,
|
|
530
|
+
* so set this to false if you need to invoke this function multiple times.
|
|
457
531
|
*/
|
|
458
|
-
export function
|
|
459
|
-
gridEntityOrGridIndex: GridEntity,
|
|
460
|
-
updateRoom
|
|
532
|
+
export function removeGridEntity(
|
|
533
|
+
gridEntityOrGridIndex: GridEntity | int,
|
|
534
|
+
updateRoom: boolean,
|
|
461
535
|
): void {
|
|
462
536
|
const room = game.GetRoom();
|
|
463
537
|
|
|
464
|
-
const gridIndex = gridEntityOrGridIndex
|
|
538
|
+
const gridIndex = isNumber(gridEntityOrGridIndex)
|
|
539
|
+
? gridEntityOrGridIndex
|
|
540
|
+
: gridEntityOrGridIndex.GetGridIndex();
|
|
465
541
|
room.RemoveGridEntity(gridIndex, 0, false);
|
|
466
542
|
|
|
467
543
|
if (updateRoom) {
|
|
@@ -492,22 +568,22 @@ export function spawnGiantPoop(topLeftGridIndex: int): void {
|
|
|
492
568
|
const bottomLeftGridIndex = topLeftGridIndex + gridWidth;
|
|
493
569
|
const bottomRightGridIndex = bottomLeftGridIndex + 1;
|
|
494
570
|
|
|
495
|
-
|
|
571
|
+
spawnGridEntityWithVariant(
|
|
496
572
|
GridEntityType.POOP,
|
|
497
573
|
PoopGridEntityVariant.GIGA_TOP_LEFT,
|
|
498
574
|
topLeftGridIndex,
|
|
499
575
|
);
|
|
500
|
-
|
|
576
|
+
spawnGridEntityWithVariant(
|
|
501
577
|
GridEntityType.POOP,
|
|
502
578
|
PoopGridEntityVariant.GIGA_TOP_RIGHT,
|
|
503
579
|
topRightGridIndex,
|
|
504
580
|
);
|
|
505
|
-
|
|
581
|
+
spawnGridEntityWithVariant(
|
|
506
582
|
GridEntityType.POOP,
|
|
507
583
|
PoopGridEntityVariant.GIGA_BOTTOM_LEFT,
|
|
508
584
|
bottomLeftGridIndex,
|
|
509
585
|
);
|
|
510
|
-
|
|
586
|
+
spawnGridEntityWithVariant(
|
|
511
587
|
GridEntityType.POOP,
|
|
512
588
|
PoopGridEntityVariant.GIGA_BOTTOM_RIGHT,
|
|
513
589
|
bottomRightGridIndex,
|
|
@@ -518,18 +594,18 @@ export function spawnGiantPoop(topLeftGridIndex: int): void {
|
|
|
518
594
|
* Helper function to spawn a grid entity.
|
|
519
595
|
*
|
|
520
596
|
* This function assumes you want to give the grid entity a variant of 0. If you want to specify a
|
|
521
|
-
* variant, use the `
|
|
597
|
+
* variant, use the `spawnGridEntityWithVariant` helper function instead.
|
|
522
598
|
*
|
|
523
599
|
* Use this instead of the `Isaac.GridSpawn` method since it:
|
|
524
600
|
* - handles giving pits collision
|
|
525
601
|
* - removes existing grid entities on the same tile, if any
|
|
526
602
|
* - allows you to specify either the grid index or the position
|
|
527
603
|
*/
|
|
528
|
-
export function
|
|
604
|
+
export function spawnGridEntity(
|
|
529
605
|
gridEntityType: GridEntityType,
|
|
530
606
|
gridIndexOrPosition: int | Vector,
|
|
531
607
|
): GridEntity | undefined {
|
|
532
|
-
return
|
|
608
|
+
return spawnGridEntityWithVariant(gridEntityType, 0, gridIndexOrPosition);
|
|
533
609
|
}
|
|
534
610
|
|
|
535
611
|
/**
|
|
@@ -540,7 +616,7 @@ export function spawnGrid(
|
|
|
540
616
|
* - removes existing grid entities on the same tile, if any
|
|
541
617
|
* - allows you to specify the grid index or the position
|
|
542
618
|
*/
|
|
543
|
-
export function
|
|
619
|
+
export function spawnGridEntityWithVariant(
|
|
544
620
|
gridEntityType: GridEntityType,
|
|
545
621
|
variant: int,
|
|
546
622
|
gridIndexOrPosition: int | Vector,
|
|
@@ -551,7 +627,7 @@ export function spawnGridWithVariant(
|
|
|
551
627
|
? room.GetGridEntityFromPos(gridIndexOrPosition)
|
|
552
628
|
: room.GetGridEntity(gridIndexOrPosition);
|
|
553
629
|
if (existingGridEntity !== undefined) {
|
|
554
|
-
|
|
630
|
+
removeGridEntity(existingGridEntity, true);
|
|
555
631
|
}
|
|
556
632
|
|
|
557
633
|
const position = isVector(gridIndexOrPosition)
|
|
@@ -634,7 +710,7 @@ export function spawnRockAltReward(
|
|
|
634
710
|
* with the appropriate variant, as the game does not give it the correct sprite automatically.
|
|
635
711
|
*/
|
|
636
712
|
export function spawnVoidPortal(gridIndex: int): GridEntity | undefined {
|
|
637
|
-
const voidPortal =
|
|
713
|
+
const voidPortal = spawnGridEntityWithVariant(
|
|
638
714
|
GridEntityType.TRAPDOOR,
|
|
639
715
|
TrapdoorVariant.VOID_PORTAL,
|
|
640
716
|
gridIndex,
|