isaacscript-common 59.5.0 → 59.6.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/index.rollup.d.ts +24 -0
- package/dist/isaacscript-common.lua +34 -12
- package/dist/src/functions/gridEntities.d.ts +22 -0
- package/dist/src/functions/gridEntities.d.ts.map +1 -1
- package/dist/src/functions/gridEntities.lua +40 -11
- package/package.json +1 -1
- package/src/functions/gridEntities.ts +59 -13
package/dist/index.rollup.d.ts
CHANGED
|
@@ -7642,6 +7642,24 @@ export declare function getSubPlayerParent(subPlayer: EntitySubPlayer): EntityPl
|
|
|
7642
7642
|
*/
|
|
7643
7643
|
export declare function getSurroundingGridEntities(gridEntity: GridEntity): GridEntity[];
|
|
7644
7644
|
|
|
7645
|
+
/**
|
|
7646
|
+
* Helper function to get the grid indexes on the surrounding tiles from the provided grid index.
|
|
7647
|
+
*
|
|
7648
|
+
* There are always 8 grid indexes returned (e.g. top-left + top + top-right + left + right +
|
|
7649
|
+
* bottom-left + bottom + right), even if the computed values would be negative or otherwise
|
|
7650
|
+
* invalid.
|
|
7651
|
+
*/
|
|
7652
|
+
export declare function getSurroundingGridIndexes(gridIndex: int): [
|
|
7653
|
+
topLeft: int,
|
|
7654
|
+
top: int,
|
|
7655
|
+
topRight: int,
|
|
7656
|
+
left: int,
|
|
7657
|
+
right: int,
|
|
7658
|
+
bottomLeft: int,
|
|
7659
|
+
bottom: int,
|
|
7660
|
+
bottomRight: int
|
|
7661
|
+
];
|
|
7662
|
+
|
|
7645
7663
|
/**
|
|
7646
7664
|
* Helper function to determine how many heart containers that Tainted Magdalene has that will not
|
|
7647
7665
|
* be automatically depleted over time. By default, this is 2, but this function will return 4 so
|
|
@@ -9198,6 +9216,12 @@ export declare function isGridEntityBroken(gridEntity: GridEntity): boolean;
|
|
|
9198
9216
|
*/
|
|
9199
9217
|
export declare function isGridEntityXMLType(num: number): num is GridEntityXMLType;
|
|
9200
9218
|
|
|
9219
|
+
/**
|
|
9220
|
+
* Helper function to check if the provided grid index has a door on it or if the surrounding 8 grid
|
|
9221
|
+
* indexes have a door on it.
|
|
9222
|
+
*/
|
|
9223
|
+
export declare function isGridIndexAdjacentToDoor(gridIndex: int): boolean;
|
|
9224
|
+
|
|
9201
9225
|
/** For `PickupVariant.HEART` (10). */
|
|
9202
9226
|
export declare function isHeart(pickup: EntityPickup): pickup is EntityPickupHeart;
|
|
9203
9227
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 59.
|
|
3
|
+
isaacscript-common 59.6.0
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -28923,6 +28923,20 @@ function getRockPNGName(self)
|
|
|
28923
28923
|
end
|
|
28924
28924
|
until true
|
|
28925
28925
|
end
|
|
28926
|
+
function ____exports.getSurroundingGridIndexes(self, gridIndex)
|
|
28927
|
+
local room = game:GetRoom()
|
|
28928
|
+
local gridWidth = room:GetGridWidth()
|
|
28929
|
+
return {
|
|
28930
|
+
gridIndex - gridWidth - 1,
|
|
28931
|
+
gridIndex - gridWidth,
|
|
28932
|
+
gridIndex - gridWidth + 1,
|
|
28933
|
+
gridIndex - 1,
|
|
28934
|
+
gridIndex + 1,
|
|
28935
|
+
gridIndex + gridWidth - 1,
|
|
28936
|
+
gridIndex + gridWidth,
|
|
28937
|
+
gridIndex + gridWidth + 1
|
|
28938
|
+
}
|
|
28939
|
+
end
|
|
28926
28940
|
function ____exports.getTopLeftWallGridIndex(self)
|
|
28927
28941
|
local room = game:GetRoom()
|
|
28928
28942
|
local roomShape = room:GetRoomShape()
|
|
@@ -29173,18 +29187,8 @@ function ____exports.getRockPNGPath(self)
|
|
|
29173
29187
|
end
|
|
29174
29188
|
function ____exports.getSurroundingGridEntities(self, gridEntity)
|
|
29175
29189
|
local room = game:GetRoom()
|
|
29176
|
-
local gridWidth = room:GetGridWidth()
|
|
29177
29190
|
local gridIndex = gridEntity:GetGridIndex()
|
|
29178
|
-
local surroundingGridIndexes =
|
|
29179
|
-
gridIndex - 1,
|
|
29180
|
-
gridIndex + 1,
|
|
29181
|
-
gridIndex - gridWidth - 1,
|
|
29182
|
-
gridIndex - gridWidth,
|
|
29183
|
-
gridIndex - gridWidth + 1,
|
|
29184
|
-
gridIndex + gridWidth - 1,
|
|
29185
|
-
gridIndex + gridWidth,
|
|
29186
|
-
gridIndex + gridWidth + 1
|
|
29187
|
-
}
|
|
29191
|
+
local surroundingGridIndexes = ____exports.getSurroundingGridIndexes(nil, gridIndex)
|
|
29188
29192
|
local surroundingGridEntities = {}
|
|
29189
29193
|
for ____, surroundingGridIndex in ipairs(surroundingGridIndexes) do
|
|
29190
29194
|
local surroundingGridEntity = room:GetGridEntity(surroundingGridIndex)
|
|
@@ -29213,6 +29217,24 @@ end
|
|
|
29213
29217
|
function ____exports.isGridEntityXMLType(self, num)
|
|
29214
29218
|
return GRID_ENTITY_XML_TYPES_SET:has(num)
|
|
29215
29219
|
end
|
|
29220
|
+
function ____exports.isGridIndexAdjacentToDoor(self, gridIndex)
|
|
29221
|
+
local room = game:GetRoom()
|
|
29222
|
+
local surroundingGridIndexes = ____exports.getSurroundingGridIndexes(nil, gridIndex)
|
|
29223
|
+
local gridIndexes = {
|
|
29224
|
+
gridIndex,
|
|
29225
|
+
table.unpack(surroundingGridIndexes)
|
|
29226
|
+
}
|
|
29227
|
+
for ____, gridIndexToInspect in ipairs(gridIndexes) do
|
|
29228
|
+
local gridEntity = room:GetGridEntity(gridIndexToInspect)
|
|
29229
|
+
if gridEntity ~= nil then
|
|
29230
|
+
local door = gridEntity:ToDoor()
|
|
29231
|
+
if door ~= nil then
|
|
29232
|
+
return true
|
|
29233
|
+
end
|
|
29234
|
+
end
|
|
29235
|
+
end
|
|
29236
|
+
return false
|
|
29237
|
+
end
|
|
29216
29238
|
function ____exports.isPoopGridEntityXMLType(self, gridEntityXMLType)
|
|
29217
29239
|
return POOP_GRID_ENTITY_XML_TYPES_SET:has(gridEntityXMLType)
|
|
29218
29240
|
end
|
|
@@ -116,6 +116,23 @@ export declare function getRockPNGPath(): string;
|
|
|
116
116
|
* rocks (e.g. top-left + top + top-right + left + right + bottom-left + bottom + right).
|
|
117
117
|
*/
|
|
118
118
|
export declare function getSurroundingGridEntities(gridEntity: GridEntity): GridEntity[];
|
|
119
|
+
/**
|
|
120
|
+
* Helper function to get the grid indexes on the surrounding tiles from the provided grid index.
|
|
121
|
+
*
|
|
122
|
+
* There are always 8 grid indexes returned (e.g. top-left + top + top-right + left + right +
|
|
123
|
+
* bottom-left + bottom + right), even if the computed values would be negative or otherwise
|
|
124
|
+
* invalid.
|
|
125
|
+
*/
|
|
126
|
+
export declare function getSurroundingGridIndexes(gridIndex: int): [
|
|
127
|
+
topLeft: int,
|
|
128
|
+
top: int,
|
|
129
|
+
topRight: int,
|
|
130
|
+
left: int,
|
|
131
|
+
right: int,
|
|
132
|
+
bottomLeft: int,
|
|
133
|
+
bottom: int,
|
|
134
|
+
bottomRight: int
|
|
135
|
+
];
|
|
119
136
|
/**
|
|
120
137
|
* Helper function to get the top left wall in the current room.
|
|
121
138
|
*
|
|
@@ -149,6 +166,11 @@ export declare function isGridEntityBroken(gridEntity: GridEntity): boolean;
|
|
|
149
166
|
* the `PRE_ROOM_ENTITY_SPAWN` callback for narrowing the type of the first argument.
|
|
150
167
|
*/
|
|
151
168
|
export declare function isGridEntityXMLType(num: number): num is GridEntityXMLType;
|
|
169
|
+
/**
|
|
170
|
+
* Helper function to check if the provided grid index has a door on it or if the surrounding 8 grid
|
|
171
|
+
* indexes have a door on it.
|
|
172
|
+
*/
|
|
173
|
+
export declare function isGridIndexAdjacentToDoor(gridIndex: int): boolean;
|
|
152
174
|
/** Helper function to see if a `GridEntityXMLType` is some kind of poop. */
|
|
153
175
|
export declare function isPoopGridEntityXMLType(gridEntityXMLType: GridEntityXMLType): boolean;
|
|
154
176
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gridEntities.d.ts","sourceRoot":"","sources":["../../../src/functions/gridEntities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAIL,cAAc,EAIf,MAAM,8BAA8B,CAAC;AAYtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AA0C1D;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,iBAAiB,EAAE,iBAAiB,EACpC,oBAAoB,EAAE,GAAG,GACxB,CAAC,cAAc,EAAE,GAAG,CAAC,GAAG,SAAS,CAenC;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,cAAc,EAAE,cAAc,EAC9B,OAAO,SAAK,GACX,OAAO,CAiBT;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,GAAG,EAAE,CAKzC;AAED;;;;;;;;;GASG;AACH,wBAAgB,kCAAkC,CAChD,UAAU,EAAE,UAAU,GACrB,MAAM,EAAE,CAoBV;AAED,qFAAqF;AACrF,wBAAgB,+BAA+B,CAC7C,YAAY,EAAE,YAAY,GACzB,CAAC,cAAc,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,CAAC,CAuBhD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,eAAe,CAC7B,GAAG,eAAe,EAAE,cAAc,EAAE,GACnC,UAAU,EAAE,CAYd;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,eAAe,EAAE,cAAc,EAAE,GACnC,UAAU,EAAE,CAYd;AAgBD,uFAAuF;AACvF,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,GACb,UAAU,EAAE,CAyCd;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,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Name(self)
|
|
|
340
340
|
end
|
|
341
341
|
until true
|
|
342
342
|
end
|
|
343
|
+
--- Helper function to get the grid indexes on the surrounding tiles from the provided grid index.
|
|
344
|
+
--
|
|
345
|
+
-- There are always 8 grid indexes returned (e.g. top-left + top + top-right + left + right +
|
|
346
|
+
-- bottom-left + bottom + right), even if the computed values would be negative or otherwise
|
|
347
|
+
-- invalid.
|
|
348
|
+
function ____exports.getSurroundingGridIndexes(self, gridIndex)
|
|
349
|
+
local room = game:GetRoom()
|
|
350
|
+
local gridWidth = room:GetGridWidth()
|
|
351
|
+
return {
|
|
352
|
+
gridIndex - gridWidth - 1,
|
|
353
|
+
gridIndex - gridWidth,
|
|
354
|
+
gridIndex - gridWidth + 1,
|
|
355
|
+
gridIndex - 1,
|
|
356
|
+
gridIndex + 1,
|
|
357
|
+
gridIndex + gridWidth - 1,
|
|
358
|
+
gridIndex + gridWidth,
|
|
359
|
+
gridIndex + gridWidth + 1
|
|
360
|
+
}
|
|
361
|
+
end
|
|
343
362
|
--- Helper function to get the grid index of the top left wall. (This will depend on what the current
|
|
344
363
|
-- room shape is.)
|
|
345
364
|
--
|
|
@@ -683,18 +702,8 @@ end
|
|
|
683
702
|
-- rocks (e.g. top-left + top + top-right + left + right + bottom-left + bottom + right).
|
|
684
703
|
function ____exports.getSurroundingGridEntities(self, gridEntity)
|
|
685
704
|
local room = game:GetRoom()
|
|
686
|
-
local gridWidth = room:GetGridWidth()
|
|
687
705
|
local gridIndex = gridEntity:GetGridIndex()
|
|
688
|
-
local surroundingGridIndexes =
|
|
689
|
-
gridIndex - 1,
|
|
690
|
-
gridIndex + 1,
|
|
691
|
-
gridIndex - gridWidth - 1,
|
|
692
|
-
gridIndex - gridWidth,
|
|
693
|
-
gridIndex - gridWidth + 1,
|
|
694
|
-
gridIndex + gridWidth - 1,
|
|
695
|
-
gridIndex + gridWidth,
|
|
696
|
-
gridIndex + gridWidth + 1
|
|
697
|
-
}
|
|
706
|
+
local surroundingGridIndexes = ____exports.getSurroundingGridIndexes(nil, gridIndex)
|
|
698
707
|
local surroundingGridEntities = {}
|
|
699
708
|
for ____, surroundingGridIndex in ipairs(surroundingGridIndexes) do
|
|
700
709
|
local surroundingGridEntity = room:GetGridEntity(surroundingGridIndex)
|
|
@@ -737,6 +746,26 @@ end
|
|
|
737
746
|
function ____exports.isGridEntityXMLType(self, num)
|
|
738
747
|
return GRID_ENTITY_XML_TYPES_SET:has(num)
|
|
739
748
|
end
|
|
749
|
+
--- Helper function to check if the provided grid index has a door on it or if the surrounding 8 grid
|
|
750
|
+
-- indexes have a door on it.
|
|
751
|
+
function ____exports.isGridIndexAdjacentToDoor(self, gridIndex)
|
|
752
|
+
local room = game:GetRoom()
|
|
753
|
+
local surroundingGridIndexes = ____exports.getSurroundingGridIndexes(nil, gridIndex)
|
|
754
|
+
local gridIndexes = {
|
|
755
|
+
gridIndex,
|
|
756
|
+
table.unpack(surroundingGridIndexes)
|
|
757
|
+
}
|
|
758
|
+
for ____, gridIndexToInspect in ipairs(gridIndexes) do
|
|
759
|
+
local gridEntity = room:GetGridEntity(gridIndexToInspect)
|
|
760
|
+
if gridEntity ~= nil then
|
|
761
|
+
local door = gridEntity:ToDoor()
|
|
762
|
+
if door ~= nil then
|
|
763
|
+
return true
|
|
764
|
+
end
|
|
765
|
+
end
|
|
766
|
+
end
|
|
767
|
+
return false
|
|
768
|
+
end
|
|
740
769
|
--- Helper function to see if a `GridEntityXMLType` is some kind of poop.
|
|
741
770
|
function ____exports.isPoopGridEntityXMLType(self, gridEntityXMLType)
|
|
742
771
|
return POOP_GRID_ENTITY_XML_TYPES_SET:has(gridEntityXMLType)
|
package/package.json
CHANGED
|
@@ -690,21 +690,9 @@ export function getSurroundingGridEntities(
|
|
|
690
690
|
gridEntity: GridEntity,
|
|
691
691
|
): GridEntity[] {
|
|
692
692
|
const room = game.GetRoom();
|
|
693
|
-
const gridWidth = room.GetGridWidth();
|
|
694
693
|
const gridIndex = gridEntity.GetGridIndex();
|
|
695
694
|
|
|
696
|
-
const surroundingGridIndexes
|
|
697
|
-
gridIndex - 1, // Left
|
|
698
|
-
gridIndex + 1, // Right
|
|
699
|
-
|
|
700
|
-
gridIndex - gridWidth - 1, // Top-left
|
|
701
|
-
gridIndex - gridWidth, // Top
|
|
702
|
-
gridIndex - gridWidth + 1, // Top-right
|
|
703
|
-
|
|
704
|
-
gridIndex + gridWidth - 1, // Bottom-left
|
|
705
|
-
gridIndex + gridWidth, // Bottom
|
|
706
|
-
gridIndex + gridWidth + 1, // Bottom-right
|
|
707
|
-
];
|
|
695
|
+
const surroundingGridIndexes = getSurroundingGridIndexes(gridIndex);
|
|
708
696
|
|
|
709
697
|
const surroundingGridEntities: GridEntity[] = [];
|
|
710
698
|
for (const surroundingGridIndex of surroundingGridIndexes) {
|
|
@@ -717,6 +705,42 @@ export function getSurroundingGridEntities(
|
|
|
717
705
|
return surroundingGridEntities;
|
|
718
706
|
}
|
|
719
707
|
|
|
708
|
+
/**
|
|
709
|
+
* Helper function to get the grid indexes on the surrounding tiles from the provided grid index.
|
|
710
|
+
*
|
|
711
|
+
* There are always 8 grid indexes returned (e.g. top-left + top + top-right + left + right +
|
|
712
|
+
* bottom-left + bottom + right), even if the computed values would be negative or otherwise
|
|
713
|
+
* invalid.
|
|
714
|
+
*/
|
|
715
|
+
export function getSurroundingGridIndexes(
|
|
716
|
+
gridIndex: int,
|
|
717
|
+
): [
|
|
718
|
+
topLeft: int,
|
|
719
|
+
top: int,
|
|
720
|
+
topRight: int,
|
|
721
|
+
left: int,
|
|
722
|
+
right: int,
|
|
723
|
+
bottomLeft: int,
|
|
724
|
+
bottom: int,
|
|
725
|
+
bottomRight: int,
|
|
726
|
+
] {
|
|
727
|
+
const room = game.GetRoom();
|
|
728
|
+
const gridWidth = room.GetGridWidth();
|
|
729
|
+
|
|
730
|
+
return [
|
|
731
|
+
gridIndex - gridWidth - 1, // Top-left
|
|
732
|
+
gridIndex - gridWidth, // Top
|
|
733
|
+
gridIndex - gridWidth + 1, // Top-right
|
|
734
|
+
|
|
735
|
+
gridIndex - 1, // Left
|
|
736
|
+
gridIndex + 1, // Right
|
|
737
|
+
|
|
738
|
+
gridIndex + gridWidth - 1, // Bottom-left
|
|
739
|
+
gridIndex + gridWidth, // Bottom
|
|
740
|
+
gridIndex + gridWidth + 1, // Bottom-right
|
|
741
|
+
];
|
|
742
|
+
}
|
|
743
|
+
|
|
720
744
|
/**
|
|
721
745
|
* Helper function to get the top left wall in the current room.
|
|
722
746
|
*
|
|
@@ -785,6 +809,28 @@ export function isGridEntityXMLType(num: number): num is GridEntityXMLType {
|
|
|
785
809
|
return GRID_ENTITY_XML_TYPES_SET.has(num); // eslint-disable-line isaacscript/strict-enums
|
|
786
810
|
}
|
|
787
811
|
|
|
812
|
+
/**
|
|
813
|
+
* Helper function to check if the provided grid index has a door on it or if the surrounding 8 grid
|
|
814
|
+
* indexes have a door on it.
|
|
815
|
+
*/
|
|
816
|
+
export function isGridIndexAdjacentToDoor(gridIndex: int): boolean {
|
|
817
|
+
const room = game.GetRoom();
|
|
818
|
+
const surroundingGridIndexes = getSurroundingGridIndexes(gridIndex);
|
|
819
|
+
const gridIndexes = [gridIndex, ...surroundingGridIndexes];
|
|
820
|
+
|
|
821
|
+
for (const gridIndexToInspect of gridIndexes) {
|
|
822
|
+
const gridEntity = room.GetGridEntity(gridIndexToInspect);
|
|
823
|
+
if (gridEntity !== undefined) {
|
|
824
|
+
const door = gridEntity.ToDoor();
|
|
825
|
+
if (door !== undefined) {
|
|
826
|
+
return true;
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
return false;
|
|
832
|
+
}
|
|
833
|
+
|
|
788
834
|
/** Helper function to see if a `GridEntityXMLType` is some kind of poop. */
|
|
789
835
|
export function isPoopGridEntityXMLType(
|
|
790
836
|
gridEntityXMLType: GridEntityXMLType,
|