isaacscript-common 1.0.569 → 1.0.570
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 +15 -0
- package/dist/functions/entity.lua +28 -0
- package/dist/functions/npc.d.ts +14 -0
- package/dist/functions/npc.lua +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/types/AnyEntity.d.ts +2 -0
- package/dist/types/AnyEntity.lua +3 -0
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
import { AnyEntity } from "../types/AnyEntity";
|
|
2
3
|
export declare function anyEntityCloserThan(entities: Entity[], position: Vector, distance: int): boolean;
|
|
3
4
|
/**
|
|
4
5
|
* Helper function to get all of the bombs in the room.
|
|
@@ -24,6 +25,11 @@ export declare function getBombs(matchingVariant?: number, matchingSubType?: num
|
|
|
24
25
|
* ```
|
|
25
26
|
*/
|
|
26
27
|
export declare function getClosestEntityTo(referenceEntity: Entity, entities: Entity[]): Entity;
|
|
28
|
+
/**
|
|
29
|
+
* Helper function to compare two different arrays of entities. Returns the entities that are in the
|
|
30
|
+
* second array but not in the first array.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getFilteredNewEntities<T extends AnyEntity>(oldEntities: T[], newEntities: T[]): T[];
|
|
27
33
|
/**
|
|
28
34
|
* Helper function to get all of the effects in the room.
|
|
29
35
|
*
|
|
@@ -251,6 +257,15 @@ export declare function removeAllProjectiles(variant?: ProjectileVariant | int,
|
|
|
251
257
|
* @returns True if one or more tears was removed, false otherwise.
|
|
252
258
|
*/
|
|
253
259
|
export declare function removeAllTears(variant?: TearVariant | int, subType?: int, cap?: int): boolean;
|
|
260
|
+
/**
|
|
261
|
+
* Game().RerollEnemy rerolls a boolean of whether or not the enemy was rerolled. However, you
|
|
262
|
+
* cannot use the same entity object after a reroll. This function calls game.RerollEnemy and
|
|
263
|
+
* returns the new entity object.
|
|
264
|
+
*
|
|
265
|
+
* @param entity The entity to reroll
|
|
266
|
+
* @returns If the entity was not rerolled, returns the original entity. otherwise, returns the resulting entity from the reroll
|
|
267
|
+
*/
|
|
268
|
+
export declare function rerollEnemy(entity: Entity): Entity;
|
|
254
269
|
/**
|
|
255
270
|
* Helper function to set the position of every entity in the room based on a map of positions. If
|
|
256
271
|
* an entity is found that does not have matching element in the provided map, then that entity will
|
|
@@ -44,6 +44,20 @@ function ____exports.getClosestEntityTo(self, referenceEntity, entities)
|
|
|
44
44
|
end
|
|
45
45
|
return closestEntity
|
|
46
46
|
end
|
|
47
|
+
function ____exports.getFilteredNewEntities(self, oldEntities, newEntities)
|
|
48
|
+
local oldEntitiesSet = __TS__New(Set)
|
|
49
|
+
for ____, entity in ipairs(oldEntities) do
|
|
50
|
+
local ptrHash = GetPtrHash(entity)
|
|
51
|
+
oldEntitiesSet:add(ptrHash)
|
|
52
|
+
end
|
|
53
|
+
return __TS__ArrayFilter(
|
|
54
|
+
newEntities,
|
|
55
|
+
function(____, entity)
|
|
56
|
+
local ptrHash = GetPtrHash(entity)
|
|
57
|
+
return not oldEntitiesSet:has(ptrHash)
|
|
58
|
+
end
|
|
59
|
+
)
|
|
60
|
+
end
|
|
47
61
|
function ____exports.getEffects(self, matchingVariant, matchingSubType)
|
|
48
62
|
if matchingVariant == nil then
|
|
49
63
|
matchingVariant = -1
|
|
@@ -280,6 +294,20 @@ function ____exports.removeAllTears(self, variant, subType, cap)
|
|
|
280
294
|
local tears = ____exports.getTears(nil, variant, subType)
|
|
281
295
|
return ____exports.removeEntities(nil, tears, cap)
|
|
282
296
|
end
|
|
297
|
+
function ____exports.rerollEnemy(self, entity)
|
|
298
|
+
local game = Game()
|
|
299
|
+
local oldEntities = ____exports.getEntities(nil)
|
|
300
|
+
local wasRerolled = game:RerollEnemy(entity)
|
|
301
|
+
if not wasRerolled then
|
|
302
|
+
return entity
|
|
303
|
+
end
|
|
304
|
+
local newEntities = ____exports.getEntities(nil)
|
|
305
|
+
local filteredNewEntities = ____exports.getFilteredNewEntities(nil, oldEntities, newEntities)
|
|
306
|
+
if #filteredNewEntities ~= 0 then
|
|
307
|
+
error("Failed to find the new entity generated by the \"RerollEnemy\" method.")
|
|
308
|
+
end
|
|
309
|
+
return filteredNewEntities[1]
|
|
310
|
+
end
|
|
283
311
|
function ____exports.setEntityPositions(self, entityPositions, entities)
|
|
284
312
|
if entities == nil then
|
|
285
313
|
entities = ____exports.getEntities(nil)
|
package/dist/functions/npc.d.ts
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/**
|
|
3
|
+
* Helper function to make an NPC fire a projectile. Returns the fired projectile. Use this function
|
|
4
|
+
* instead of `EntityNPC.FireProjectiles()`, since that returns void.
|
|
5
|
+
*
|
|
6
|
+
* @param npc The NPC to fire the projectile from.
|
|
7
|
+
* @param position The staring position of the projectile.
|
|
8
|
+
* @param velocity The starting velocity of the projectile.
|
|
9
|
+
* @param projectilesMode The mode of the projectile. Optional. Equal to
|
|
10
|
+
* `ProjectilesMode.ONE_PROJECTILE` by default.
|
|
11
|
+
* @param projectileParams The parameters of the projectile. Optional. Equal to `ProjectileParams()`
|
|
12
|
+
* by default.
|
|
13
|
+
* @returns The fired projectile.
|
|
14
|
+
*/
|
|
15
|
+
export declare function fireProjectiles(npc: EntityNPC, position: Vector, velocity: Vector, projectilesMode?: ProjectilesMode, projectileParams?: ProjectileParams): EntityProjectile[];
|
|
2
16
|
/**
|
|
3
17
|
* Helper function to get all of the non-dead bosses in the room.
|
|
4
18
|
*
|
package/dist/functions/npc.lua
CHANGED
|
@@ -6,6 +6,8 @@ local ____constants = require("constants")
|
|
|
6
6
|
local EGGY_STATE_FRAME_OF_FINAL_SPIDER = ____constants.EGGY_STATE_FRAME_OF_FINAL_SPIDER
|
|
7
7
|
local ____entity = require("functions.entity")
|
|
8
8
|
local getEntities = ____entity.getEntities
|
|
9
|
+
local getFilteredNewEntities = ____entity.getFilteredNewEntities
|
|
10
|
+
local getProjectiles = ____entity.getProjectiles
|
|
9
11
|
local removeEntities = ____entity.removeEntities
|
|
10
12
|
function ____exports.getBosses(self)
|
|
11
13
|
local bosses = {}
|
|
@@ -75,6 +77,18 @@ NON_ALIVE_NPCS_TYPE_VARIANT_SUBTYPE = __TS__New(
|
|
|
75
77
|
(((tostring(EntityType.ENTITY_CHARGER) .. ".") .. 0) .. ".") .. 1
|
|
76
78
|
}
|
|
77
79
|
)
|
|
80
|
+
function ____exports.fireProjectiles(self, npc, position, velocity, projectilesMode, projectileParams)
|
|
81
|
+
if projectilesMode == nil then
|
|
82
|
+
projectilesMode = 0
|
|
83
|
+
end
|
|
84
|
+
if projectileParams == nil then
|
|
85
|
+
projectileParams = ProjectileParams()
|
|
86
|
+
end
|
|
87
|
+
local oldProjectiles = getProjectiles(nil, projectileParams.Variant)
|
|
88
|
+
npc:FireProjectiles(position, velocity, projectilesMode, projectileParams)
|
|
89
|
+
local newProjectiles = getProjectiles(nil, projectileParams.Variant)
|
|
90
|
+
return getFilteredNewEntities(nil, oldProjectiles, newProjectiles)
|
|
91
|
+
end
|
|
78
92
|
function ____exports.getAliveBosses(self)
|
|
79
93
|
local aliveBosses = {}
|
|
80
94
|
for ____, boss in ipairs(
|
package/dist/index.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ export * from "./maps/transformationMaps";
|
|
|
61
61
|
export * from "./maps/transformationNameMap";
|
|
62
62
|
export * from "./maps/trinketNameMap";
|
|
63
63
|
export * from "./sets/cards";
|
|
64
|
+
export * from "./types/AnyEntity";
|
|
64
65
|
export * from "./types/CallbackParametersCustom";
|
|
65
66
|
export * from "./types/HealthType";
|
|
66
67
|
export * from "./types/JSONDoor";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.570",
|
|
4
4
|
"description": "Helper functions for IsaacScript mods",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dist/**/*.d.ts"
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"isaac-typescript-definitions": "^1.0.
|
|
28
|
+
"isaac-typescript-definitions": "^1.0.315",
|
|
29
29
|
"isaacscript-lint": "^1.0.74",
|
|
30
30
|
"typedoc": "^0.22.10",
|
|
31
31
|
"typescript": "4.4.4",
|