isaacscript-common 7.4.2 → 7.4.3
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.
|
@@ -168,6 +168,9 @@ export declare function removeGridEntities<T extends AnyGridEntity>(gridEntities
|
|
|
168
168
|
* Helper function to remove a grid entity by providing the grid entity object or the grid index
|
|
169
169
|
* inside of the room.
|
|
170
170
|
*
|
|
171
|
+
* If removing a Devil Statue or an Angel Statue, this will also remove the associated effect
|
|
172
|
+
* (`EffectVariant.DEVIL` (6) or `EffectVariant.ANGEL` (9), respectively.)
|
|
173
|
+
*
|
|
171
174
|
* @param gridEntityOrGridIndex The grid entity or grid index to remove.
|
|
172
175
|
* @param updateRoom Whether or not to update the room after the grid entity is removed. This is
|
|
173
176
|
* generally a good idea because if the room is not updated, you will be unable to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gridEntities.d.ts","sourceRoot":"","sources":["../../src/functions/gridEntities.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,
|
|
1
|
+
{"version":3,"file":"gridEntities.d.ts","sourceRoot":"","sources":["../../src/functions/gridEntities.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAGjB,cAAc,EACd,iBAAiB,EAGjB,eAAe,EAChB,MAAM,8BAA8B,CAAC;AAStC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAgCvD;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,iBAAiB,EAAE,iBAAiB,EACpC,oBAAoB,EAAE,GAAG,GACxB,CAAC,cAAc,EAAE,GAAG,CAAC,GAAG,SAAS,CAqBnC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,GAAG,EAAE,CAKzC;AAED;;;;;;GAMG;AACH,wBAAgB,kCAAkC,CAChD,UAAU,EAAE,UAAU,GACrB,MAAM,EAAE,CA4BV;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,iBAAiB,GA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AG,eAAe,EAAE,cAAc,EAAE,GACnC,UAAU,EAAE,CAiBd;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,6BAA6B,CAC3C,GAAG,cAAc,EAAE,cAAc,EAAE,GAClC,UAAU,EAAE,CAYd;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,aAAa,EACxD,YAAY,EAAE,CAAC,EAAE,EACjB,UAAU,EAAE,OAAO,EACnB,GAAG,CAAC,EAAE,GAAG,GACR,CAAC,EAAE,CAoBL;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC9B,qBAAqB,EAAE,UAAU,GAAG,GAAG,EACvC,UAAU,EAAE,OAAO,GAClB,IAAI,CAqCN;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAGnE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,gBAAgB,EAAE,GAAG,GAAG,IAAI,CA4B1D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,cAAc,EAAE,cAAc,EAC9B,mBAAmB,EAAE,GAAG,GAAG,MAAM,GAChC,UAAU,GAAG,SAAS,CAExB;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,GAAG,EACZ,mBAAmB,EAAE,GAAG,GAAG,MAAM,GAChC,UAAU,GAAG,SAAS,CAgCxB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,GAAG,GAAG,UAAU,GAAG,SAAS,CAkBtE"}
|
|
@@ -6,6 +6,7 @@ local Map = ____lualib.Map
|
|
|
6
6
|
local ____exports = {}
|
|
7
7
|
local getAllGridEntities
|
|
8
8
|
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
9
|
+
local EffectVariant = ____isaac_2Dtypescript_2Ddefinitions.EffectVariant
|
|
9
10
|
local GridCollisionClass = ____isaac_2Dtypescript_2Ddefinitions.GridCollisionClass
|
|
10
11
|
local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
|
|
11
12
|
local PoopGridEntityVariant = ____isaac_2Dtypescript_2Ddefinitions.PoopGridEntityVariant
|
|
@@ -22,6 +23,10 @@ local GRID_ENTITY_XML_MAP = ____gridEntityXMLMap.GRID_ENTITY_XML_MAP
|
|
|
22
23
|
local ____roomShapeToTopLeftWallGridIndexMap = require("maps.roomShapeToTopLeftWallGridIndexMap")
|
|
23
24
|
local DEFAULT_TOP_LEFT_WALL_GRID_INDEX = ____roomShapeToTopLeftWallGridIndexMap.DEFAULT_TOP_LEFT_WALL_GRID_INDEX
|
|
24
25
|
local ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP = ____roomShapeToTopLeftWallGridIndexMap.ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP
|
|
26
|
+
local ____entities = require("functions.entities")
|
|
27
|
+
local removeEntities = ____entities.removeEntities
|
|
28
|
+
local ____entitiesSpecific = require("functions.entitiesSpecific")
|
|
29
|
+
local getEffects = ____entitiesSpecific.getEffects
|
|
25
30
|
local ____math = require("functions.math")
|
|
26
31
|
local isCircleIntersectingRectangle = ____math.isCircleIntersectingRectangle
|
|
27
32
|
local ____rooms = require("functions.rooms")
|
|
@@ -35,6 +40,7 @@ local ____utils = require("functions.utils")
|
|
|
35
40
|
local erange = ____utils.erange
|
|
36
41
|
local ____vector = require("functions.vector")
|
|
37
42
|
local isVector = ____vector.isVector
|
|
43
|
+
local vectorEquals = ____vector.vectorEquals
|
|
38
44
|
--- Helper function to get every legal grid index for the current room.
|
|
39
45
|
--
|
|
40
46
|
-- Under the hood, this uses the `Room.GetGridSize` method.
|
|
@@ -113,6 +119,9 @@ end
|
|
|
113
119
|
--- Helper function to remove a grid entity by providing the grid entity object or the grid index
|
|
114
120
|
-- inside of the room.
|
|
115
121
|
--
|
|
122
|
+
-- If removing a Devil Statue or an Angel Statue, this will also remove the associated effect
|
|
123
|
+
-- (`EffectVariant.DEVIL` (6) or `EffectVariant.ANGEL` (9), respectively.)
|
|
124
|
+
--
|
|
116
125
|
-- @param gridEntityOrGridIndex The grid entity or grid index to remove.
|
|
117
126
|
-- @param updateRoom Whether or not to update the room after the grid entity is removed. This is
|
|
118
127
|
-- generally a good idea because if the room is not updated, you will be unable to
|
|
@@ -121,11 +130,33 @@ end
|
|
|
121
130
|
-- so set this to false if you need to run this function multiple times.
|
|
122
131
|
function ____exports.removeGridEntity(self, gridEntityOrGridIndex, updateRoom)
|
|
123
132
|
local room = game:GetRoom()
|
|
133
|
+
local ____isNumber_result_0
|
|
134
|
+
if isNumber(nil, gridEntityOrGridIndex) then
|
|
135
|
+
____isNumber_result_0 = room:GetGridEntity(gridEntityOrGridIndex)
|
|
136
|
+
else
|
|
137
|
+
____isNumber_result_0 = gridEntityOrGridIndex
|
|
138
|
+
end
|
|
139
|
+
local gridEntity = ____isNumber_result_0
|
|
140
|
+
if gridEntity == nil then
|
|
141
|
+
return
|
|
142
|
+
end
|
|
143
|
+
local gridEntityType = gridEntity:GetType()
|
|
144
|
+
local variant = gridEntity:GetVariant()
|
|
145
|
+
local position = gridEntity.Position
|
|
124
146
|
local gridIndex = isNumber(nil, gridEntityOrGridIndex) and gridEntityOrGridIndex or gridEntityOrGridIndex:GetGridIndex()
|
|
125
147
|
room:RemoveGridEntity(gridIndex, 0, false)
|
|
126
148
|
if updateRoom then
|
|
127
149
|
roomUpdateSafe(nil)
|
|
128
150
|
end
|
|
151
|
+
if gridEntityType == GridEntityType.STATUE then
|
|
152
|
+
local effectVariant = variant == asNumber(nil, StatueVariant.DEVIL) and EffectVariant.DEVIL or EffectVariant.ANGEL
|
|
153
|
+
local effects = getEffects(nil, effectVariant)
|
|
154
|
+
local effectsOnTile = __TS__ArrayFilter(
|
|
155
|
+
effects,
|
|
156
|
+
function(____, effect) return vectorEquals(nil, effect.Position, position) end
|
|
157
|
+
)
|
|
158
|
+
removeEntities(nil, effectsOnTile)
|
|
159
|
+
end
|
|
129
160
|
end
|
|
130
161
|
--- Helper function to spawn a grid entity with a specific variant.
|
|
131
162
|
--
|
|
@@ -135,13 +166,13 @@ end
|
|
|
135
166
|
-- - allows you to specify the grid index or the position
|
|
136
167
|
function ____exports.spawnGridEntityWithVariant(self, gridEntityType, variant, gridIndexOrPosition)
|
|
137
168
|
local room = game:GetRoom()
|
|
138
|
-
local
|
|
169
|
+
local ____isVector_result_1
|
|
139
170
|
if isVector(nil, gridIndexOrPosition) then
|
|
140
|
-
|
|
171
|
+
____isVector_result_1 = room:GetGridEntityFromPos(gridIndexOrPosition)
|
|
141
172
|
else
|
|
142
|
-
|
|
173
|
+
____isVector_result_1 = room:GetGridEntity(gridIndexOrPosition)
|
|
143
174
|
end
|
|
144
|
-
local existingGridEntity =
|
|
175
|
+
local existingGridEntity = ____isVector_result_1
|
|
145
176
|
if existingGridEntity ~= nil then
|
|
146
177
|
____exports.removeGridEntity(nil, existingGridEntity, true)
|
|
147
178
|
end
|
package/dist/index.d.ts
CHANGED
|
@@ -8979,6 +8979,9 @@ export declare function removeGridEntities<T extends AnyGridEntity>(gridEntities
|
|
|
8979
8979
|
* Helper function to remove a grid entity by providing the grid entity object or the grid index
|
|
8980
8980
|
* inside of the room.
|
|
8981
8981
|
*
|
|
8982
|
+
* If removing a Devil Statue or an Angel Statue, this will also remove the associated effect
|
|
8983
|
+
* (`EffectVariant.DEVIL` (6) or `EffectVariant.ANGEL` (9), respectively.)
|
|
8984
|
+
*
|
|
8982
8985
|
* @param gridEntityOrGridIndex The grid entity or grid index to remove.
|
|
8983
8986
|
* @param updateRoom Whether or not to update the room after the grid entity is removed. This is
|
|
8984
8987
|
* generally a good idea because if the room is not updated, you will be unable to
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CrawlSpaceVariant,
|
|
3
|
+
EffectVariant,
|
|
3
4
|
GridCollisionClass,
|
|
4
5
|
GridEntityType,
|
|
5
6
|
GridEntityXMLType,
|
|
@@ -16,12 +17,14 @@ import {
|
|
|
16
17
|
ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP,
|
|
17
18
|
} from "../maps/roomShapeToTopLeftWallGridIndexMap";
|
|
18
19
|
import { AnyGridEntity } from "../types/AnyGridEntity";
|
|
20
|
+
import { removeEntities } from "./entities";
|
|
21
|
+
import { getEffects } from "./entitiesSpecific";
|
|
19
22
|
import { isCircleIntersectingRectangle } from "./math";
|
|
20
23
|
import { roomUpdateSafe } from "./rooms";
|
|
21
24
|
import { clearSprite } from "./sprites";
|
|
22
25
|
import { asNumber, isNumber } from "./types";
|
|
23
26
|
import { erange } from "./utils";
|
|
24
|
-
import { isVector } from "./vector";
|
|
27
|
+
import { isVector, vectorEquals } from "./vector";
|
|
25
28
|
|
|
26
29
|
const BREAKABLE_GRID_ENTITY_TYPES_BY_EXPLOSIONS: ReadonlySet<GridEntityType> =
|
|
27
30
|
new Set([
|
|
@@ -498,6 +501,9 @@ export function removeGridEntities<T extends AnyGridEntity>(
|
|
|
498
501
|
* Helper function to remove a grid entity by providing the grid entity object or the grid index
|
|
499
502
|
* inside of the room.
|
|
500
503
|
*
|
|
504
|
+
* If removing a Devil Statue or an Angel Statue, this will also remove the associated effect
|
|
505
|
+
* (`EffectVariant.DEVIL` (6) or `EffectVariant.ANGEL` (9), respectively.)
|
|
506
|
+
*
|
|
501
507
|
* @param gridEntityOrGridIndex The grid entity or grid index to remove.
|
|
502
508
|
* @param updateRoom Whether or not to update the room after the grid entity is removed. This is
|
|
503
509
|
* generally a good idea because if the room is not updated, you will be unable to
|
|
@@ -511,6 +517,18 @@ export function removeGridEntity(
|
|
|
511
517
|
): void {
|
|
512
518
|
const room = game.GetRoom();
|
|
513
519
|
|
|
520
|
+
const gridEntity = isNumber(gridEntityOrGridIndex)
|
|
521
|
+
? room.GetGridEntity(gridEntityOrGridIndex)
|
|
522
|
+
: gridEntityOrGridIndex;
|
|
523
|
+
if (gridEntity === undefined) {
|
|
524
|
+
// There is no grid entity to remove.
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
const gridEntityType = gridEntity.GetType();
|
|
529
|
+
const variant = gridEntity.GetVariant();
|
|
530
|
+
const position = gridEntity.Position;
|
|
531
|
+
|
|
514
532
|
const gridIndex = isNumber(gridEntityOrGridIndex)
|
|
515
533
|
? gridEntityOrGridIndex
|
|
516
534
|
: gridEntityOrGridIndex.GetGridIndex();
|
|
@@ -519,6 +537,20 @@ export function removeGridEntity(
|
|
|
519
537
|
if (updateRoom) {
|
|
520
538
|
roomUpdateSafe();
|
|
521
539
|
}
|
|
540
|
+
|
|
541
|
+
// In the special case of removing a Devil Statue or Angel Statue, we also need to delete the
|
|
542
|
+
// corresponding effect.
|
|
543
|
+
if (gridEntityType === GridEntityType.STATUE) {
|
|
544
|
+
const effectVariant =
|
|
545
|
+
variant === asNumber(StatueVariant.DEVIL)
|
|
546
|
+
? EffectVariant.DEVIL
|
|
547
|
+
: EffectVariant.ANGEL;
|
|
548
|
+
const effects = getEffects(effectVariant);
|
|
549
|
+
const effectsOnTile = effects.filter((effect) =>
|
|
550
|
+
vectorEquals(effect.Position, position),
|
|
551
|
+
);
|
|
552
|
+
removeEntities(effectsOnTile);
|
|
553
|
+
}
|
|
522
554
|
}
|
|
523
555
|
|
|
524
556
|
/**
|