isaacscript-common 1.2.270 → 1.2.273
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/constants.d.ts +2 -2
- package/dist/functions/boss.d.ts +17 -0
- package/dist/functions/boss.lua +70 -0
- package/dist/functions/entity.d.ts +18 -0
- package/dist/functions/entity.lua +37 -0
- package/package.json +2 -2
package/dist/constants.d.ts
CHANGED
|
@@ -120,9 +120,9 @@ export declare const UI_HEART_WIDTH = 12;
|
|
|
120
120
|
* This is a safer version of the `Vector.One` constant. (Other mods can mutate this vector, so it
|
|
121
121
|
* is not safe to use.)
|
|
122
122
|
*/
|
|
123
|
-
export declare const VectorOne:
|
|
123
|
+
export declare const VectorOne: Readonly<Vector>;
|
|
124
124
|
/**
|
|
125
125
|
* This is a safer version of the `Vector.Zero` constant. (Other mods can mutate this vector, so it
|
|
126
126
|
* is not safe to use.)
|
|
127
127
|
*/
|
|
128
|
-
export declare const VectorZero:
|
|
128
|
+
export declare const VectorZero: Readonly<Vector>;
|
package/dist/functions/boss.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
import { EntityTypeNonNPC } from "../types/EntityTypeNonNPC";
|
|
2
3
|
/**
|
|
3
4
|
* Helper function to get all of the non-dead bosses in the room.
|
|
4
5
|
*
|
|
@@ -37,3 +38,19 @@ export declare function getBosses(matchingEntityType?: EntityType | int, matchin
|
|
|
37
38
|
export declare function getCombinedBossSet(stage: int): Set<string> | undefined;
|
|
38
39
|
/** Helper function to check if the provided NPC is a Sin miniboss, such as Sloth or Lust. */
|
|
39
40
|
export declare function isSin(npc: EntityNPC): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Helper function to spawn a boss.
|
|
43
|
+
*
|
|
44
|
+
* Use this function instead of `spawnNPC` since it handles automatically spawning multiple segments
|
|
45
|
+
* for multi-segment bosses.
|
|
46
|
+
*
|
|
47
|
+
* By default, this will spawn Chub (and his variants) with 3 segments and other multi-segment
|
|
48
|
+
* bosses with 4 segments. You can customize this via the "numSegments" argument.
|
|
49
|
+
*/
|
|
50
|
+
export declare function spawnBoss<T extends number>(entityType: T extends EntityTypeNonNPC ? never : T, variant: int, subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined, numSegments?: int): EntityNPC;
|
|
51
|
+
/**
|
|
52
|
+
* Helper function to spawn a boss with a specific seed.
|
|
53
|
+
*
|
|
54
|
+
* For more information, see the documentation for the `spawnBoss` function.
|
|
55
|
+
*/
|
|
56
|
+
export declare function spawnBossWithSeed(entityType: EntityType | int, variant: int, subType: int, position: Vector, seed: Seed, velocity?: Readonly<Vector>, spawner?: Entity | undefined, numSegments?: int): EntityNPC;
|
package/dist/functions/boss.lua
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local Set = ____lualib.Set
|
|
3
|
+
local __TS__New = ____lualib.__TS__New
|
|
2
4
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
3
5
|
local ____exports = {}
|
|
6
|
+
local ____constants = require("constants")
|
|
7
|
+
local VectorZero = ____constants.VectorZero
|
|
4
8
|
local ____bossSets = require("sets.bossSets")
|
|
5
9
|
local ALL_BOSSES_SET = ____bossSets.ALL_BOSSES_SET
|
|
6
10
|
local STAGE_TO_COMBINED_BOSS_SET_MAP = ____bossSets.STAGE_TO_COMBINED_BOSS_SET_MAP
|
|
@@ -9,10 +13,14 @@ local ____sinEntityTypesSet = require("sets.sinEntityTypesSet")
|
|
|
9
13
|
local SIN_ENTITY_TYPES_SET = ____sinEntityTypesSet.SIN_ENTITY_TYPES_SET
|
|
10
14
|
local ____entitySpecific = require("functions.entitySpecific")
|
|
11
15
|
local getNPCs = ____entitySpecific.getNPCs
|
|
16
|
+
local spawnNPC = ____entitySpecific.spawnNPC
|
|
12
17
|
local ____npc = require("functions.npc")
|
|
13
18
|
local getAliveNPCs = ____npc.getAliveNPCs
|
|
14
19
|
local ____set = require("functions.set")
|
|
15
20
|
local copySet = ____set.copySet
|
|
21
|
+
local ____utils = require("functions.utils")
|
|
22
|
+
local ____repeat = ____utils["repeat"]
|
|
23
|
+
local BOSSES_THAT_REQUIRE_MULTIPLE_SPAWNS = __TS__New(Set, {EntityType.ENTITY_LARRYJR, EntityType.ENTITY_CHUB, EntityType.ENTITY_TURDLET})
|
|
16
24
|
function ____exports.getAliveBosses(self, matchingEntityType, matchingVariant, matchingSubType, ignoreFriendly)
|
|
17
25
|
if ignoreFriendly == nil then
|
|
18
26
|
ignoreFriendly = false
|
|
@@ -69,4 +77,66 @@ end
|
|
|
69
77
|
function ____exports.isSin(self, npc)
|
|
70
78
|
return SIN_ENTITY_TYPES_SET:has(npc.Type)
|
|
71
79
|
end
|
|
80
|
+
function ____exports.spawnBoss(self, entityType, variant, subType, position, velocity, spawner, seed, numSegments)
|
|
81
|
+
if velocity == nil then
|
|
82
|
+
velocity = VectorZero
|
|
83
|
+
end
|
|
84
|
+
if spawner == nil then
|
|
85
|
+
spawner = nil
|
|
86
|
+
end
|
|
87
|
+
if seed == nil then
|
|
88
|
+
seed = nil
|
|
89
|
+
end
|
|
90
|
+
local npc = spawnNPC(
|
|
91
|
+
nil,
|
|
92
|
+
entityType,
|
|
93
|
+
variant,
|
|
94
|
+
subType,
|
|
95
|
+
position,
|
|
96
|
+
velocity,
|
|
97
|
+
spawner,
|
|
98
|
+
seed
|
|
99
|
+
)
|
|
100
|
+
if BOSSES_THAT_REQUIRE_MULTIPLE_SPAWNS:has(entityType) then
|
|
101
|
+
local numSegmentsDefined = numSegments == nil and 4 or numSegments
|
|
102
|
+
local numSegmentsToUse = entityType == EntityType.ENTITY_CHUB and 3 or numSegmentsDefined
|
|
103
|
+
local remainingSegmentsToSpawn = numSegmentsToUse - 1
|
|
104
|
+
____repeat(
|
|
105
|
+
nil,
|
|
106
|
+
remainingSegmentsToSpawn,
|
|
107
|
+
function()
|
|
108
|
+
spawnNPC(
|
|
109
|
+
nil,
|
|
110
|
+
entityType,
|
|
111
|
+
variant,
|
|
112
|
+
subType,
|
|
113
|
+
position,
|
|
114
|
+
velocity,
|
|
115
|
+
spawner,
|
|
116
|
+
seed
|
|
117
|
+
)
|
|
118
|
+
end
|
|
119
|
+
)
|
|
120
|
+
end
|
|
121
|
+
return npc
|
|
122
|
+
end
|
|
123
|
+
function ____exports.spawnBossWithSeed(self, entityType, variant, subType, position, seed, velocity, spawner, numSegments)
|
|
124
|
+
if velocity == nil then
|
|
125
|
+
velocity = VectorZero
|
|
126
|
+
end
|
|
127
|
+
if spawner == nil then
|
|
128
|
+
spawner = nil
|
|
129
|
+
end
|
|
130
|
+
return ____exports.spawnBoss(
|
|
131
|
+
nil,
|
|
132
|
+
entityType,
|
|
133
|
+
variant,
|
|
134
|
+
subType,
|
|
135
|
+
position,
|
|
136
|
+
velocity,
|
|
137
|
+
spawner,
|
|
138
|
+
seed,
|
|
139
|
+
numSegments
|
|
140
|
+
)
|
|
141
|
+
end
|
|
72
142
|
return ____exports
|
|
@@ -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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.273",
|
|
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.392",
|
|
29
29
|
"isaacscript-lint": "^1.0.99",
|
|
30
30
|
"isaacscript-tsconfig": "^1.1.8",
|
|
31
31
|
"typedoc": "^0.22.15",
|