isaacscript-common 1.2.270 → 1.2.271
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/functions/entity.d.ts +18 -0
- package/dist/functions/entity.lua +37 -0
- package/package.json +1 -1
|
@@ -67,6 +67,24 @@ export declare function isEntityMoving(entity: Entity, threshold?: number): bool
|
|
|
67
67
|
* apply to non-story bosses, like Vanishing Twin. Also see the `STORY_BOSSES` constant.
|
|
68
68
|
*/
|
|
69
69
|
export declare function isStoryBoss(entityType: EntityType | int): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Helper function to parse a string that contains an entity type, a variant, and a sub-type,
|
|
72
|
+
* separated by periods.
|
|
73
|
+
*
|
|
74
|
+
* For example, passing "45.0.1" would return an array of [45, 0, 1].
|
|
75
|
+
*
|
|
76
|
+
* Returns undefined if the string cannot be parsed.
|
|
77
|
+
*/
|
|
78
|
+
export declare function parseEntityID(entityID: string): [entityType: EntityType | int, variant: int, subType: int] | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* Helper function to parse a string that contains an entity type and a variant separated by a
|
|
81
|
+
* period.
|
|
82
|
+
*
|
|
83
|
+
* For example, passing "45.0" would return an array of [45, 0].
|
|
84
|
+
*
|
|
85
|
+
* Returns undefined if the string cannot be parsed.
|
|
86
|
+
*/
|
|
87
|
+
export declare function parseEntityTypeVariantString(entityTypeVariantString: string): [entityType: EntityType | int, variant: int] | undefined;
|
|
70
88
|
/**
|
|
71
89
|
* Helper function to remove all of the matching entities in the room.
|
|
72
90
|
*
|
|
@@ -2,6 +2,7 @@ local ____lualib = require("lualib_bundle")
|
|
|
2
2
|
local Set = ____lualib.Set
|
|
3
3
|
local __TS__New = ____lualib.__TS__New
|
|
4
4
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
5
|
+
local __TS__StringSplit = ____lualib.__TS__StringSplit
|
|
5
6
|
local ____exports = {}
|
|
6
7
|
local ____cachedClasses = require("cachedClasses")
|
|
7
8
|
local game = ____cachedClasses.game
|
|
@@ -107,6 +108,42 @@ end
|
|
|
107
108
|
function ____exports.isStoryBoss(self, entityType)
|
|
108
109
|
return STORY_BOSSES_SET:has(entityType)
|
|
109
110
|
end
|
|
111
|
+
function ____exports.parseEntityID(self, entityID)
|
|
112
|
+
local entityIDArray = __TS__StringSplit(entityID, ".")
|
|
113
|
+
if #entityIDArray ~= 3 then
|
|
114
|
+
return nil
|
|
115
|
+
end
|
|
116
|
+
local entityTypeString, variantString, subTypeString = table.unpack(entityIDArray)
|
|
117
|
+
local entityType = tonumber(entityTypeString)
|
|
118
|
+
if entityType == nil then
|
|
119
|
+
return nil
|
|
120
|
+
end
|
|
121
|
+
local variant = tonumber(variantString)
|
|
122
|
+
if variant == nil then
|
|
123
|
+
return nil
|
|
124
|
+
end
|
|
125
|
+
local subType = tonumber(subTypeString)
|
|
126
|
+
if subType == nil then
|
|
127
|
+
return nil
|
|
128
|
+
end
|
|
129
|
+
return {entityType, variant, subType}
|
|
130
|
+
end
|
|
131
|
+
function ____exports.parseEntityTypeVariantString(self, entityTypeVariantString)
|
|
132
|
+
local entityTypeVariantArray = __TS__StringSplit(entityTypeVariantString, ".")
|
|
133
|
+
if #entityTypeVariantArray ~= 2 then
|
|
134
|
+
return nil
|
|
135
|
+
end
|
|
136
|
+
local entityTypeString, variantString = table.unpack(entityTypeVariantArray)
|
|
137
|
+
local entityType = tonumber(entityTypeString)
|
|
138
|
+
if entityType == nil then
|
|
139
|
+
return nil
|
|
140
|
+
end
|
|
141
|
+
local variant = tonumber(variantString)
|
|
142
|
+
if variant == nil then
|
|
143
|
+
return nil
|
|
144
|
+
end
|
|
145
|
+
return {entityType, variant}
|
|
146
|
+
end
|
|
110
147
|
function ____exports.removeAllMatchingEntities(self, entityType, entityVariant, entitySubType, cap)
|
|
111
148
|
if entityVariant == nil then
|
|
112
149
|
entityVariant = -1
|