isaacscript-common 6.12.0 → 6.15.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/enums/private/SerializationBrand.d.ts +1 -1
- package/dist/enums/private/SerializationBrand.lua +1 -1
- package/dist/features/collectibleItemPoolType.d.ts +2 -2
- package/dist/features/collectibleItemPoolType.lua +2 -2
- package/dist/features/customGridEntity.d.ts +2 -2
- package/dist/features/customGridEntity.lua +2 -2
- package/dist/features/customTrapdoor/blackSprite.d.ts.map +1 -1
- package/dist/features/customTrapdoor/blackSprite.lua +6 -6
- package/dist/features/extraConsoleCommands/exports.d.ts +4 -3
- package/dist/features/extraConsoleCommands/exports.d.ts.map +1 -1
- package/dist/features/extraConsoleCommands/exports.lua +4 -3
- package/dist/features/extraConsoleCommands/init.lua +12 -14
- package/dist/features/extraConsoleCommands/listCommands.d.ts +15 -19
- package/dist/features/extraConsoleCommands/listCommands.d.ts.map +1 -1
- package/dist/features/extraConsoleCommands/listCommands.lua +30 -38
- package/dist/functions/collectibles.d.ts +6 -2
- package/dist/functions/collectibles.d.ts.map +1 -1
- package/dist/functions/collectibles.lua +4 -2
- package/dist/functions/color.d.ts +10 -0
- package/dist/functions/color.d.ts.map +1 -1
- package/dist/functions/color.lua +24 -0
- package/dist/functions/gridEntities.d.ts +2 -20
- package/dist/functions/gridEntities.d.ts.map +1 -1
- package/dist/functions/gridEntities.lua +2 -59
- package/dist/functions/itemPool.d.ts +10 -0
- package/dist/functions/itemPool.d.ts.map +1 -0
- package/dist/functions/itemPool.lua +116 -0
- package/dist/functions/kColor.d.ts +10 -0
- package/dist/functions/kColor.d.ts.map +1 -1
- package/dist/functions/kColor.lua +24 -0
- package/dist/functions/map.d.ts +2 -0
- package/dist/functions/map.d.ts.map +1 -1
- package/dist/functions/map.lua +7 -0
- package/dist/functions/npcs.d.ts +2 -2
- package/dist/functions/npcs.lua +2 -2
- package/dist/functions/random.d.ts +1 -1
- package/dist/functions/random.lua +1 -1
- package/dist/functions/rockAlt.d.ts +24 -0
- package/dist/functions/rockAlt.d.ts.map +1 -0
- package/dist/functions/rockAlt.lua +285 -0
- package/dist/functions/saveFile.d.ts +8 -7
- package/dist/functions/saveFile.d.ts.map +1 -1
- package/dist/functions/saveFile.lua +10 -96
- package/dist/functions/set.d.ts +2 -0
- package/dist/functions/set.d.ts.map +1 -1
- package/dist/functions/set.lua +6 -0
- package/dist/functions/trinketGive.d.ts +13 -0
- package/dist/functions/trinketGive.d.ts.map +1 -1
- package/dist/functions/trinketGive.lua +16 -0
- package/dist/functions/vector.d.ts +11 -0
- package/dist/functions/vector.d.ts.map +1 -1
- package/dist/functions/vector.lua +23 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.lua +16 -0
- package/package.json +2 -2
- package/src/callbacks/postPickupInitFirst.ts +2 -0
- package/src/enums/private/SerializationBrand.ts +1 -1
- package/src/features/collectibleItemPoolType.ts +3 -3
- package/src/features/customGridEntity.ts +2 -2
- package/src/features/customTrapdoor/blackSprite.ts +11 -5
- package/src/features/extraConsoleCommands/exports.ts +4 -3
- package/src/features/extraConsoleCommands/init.ts +18 -14
- package/src/features/extraConsoleCommands/listCommands.ts +33 -36
- package/src/functions/collectibles.ts +6 -2
- package/src/functions/color.ts +22 -0
- package/src/functions/gridEntities.ts +2 -54
- package/src/functions/itemPool.ts +153 -0
- package/src/functions/kColor.ts +22 -0
- package/src/functions/map.ts +10 -0
- package/src/functions/npcs.ts +2 -2
- package/src/functions/random.ts +1 -1
- package/src/functions/rockAlt.ts +309 -0
- package/src/functions/saveFile.ts +13 -119
- package/src/functions/set.ts +7 -1
- package/src/functions/trinketGive.ts +21 -0
- package/src/functions/vector.ts +23 -0
- package/src/index.ts +2 -0
|
@@ -294,6 +294,8 @@ function ____exports.getCollectibleName(self, collectibleType)
|
|
|
294
294
|
end
|
|
295
295
|
return DEFAULT_COLLECTIBLE_NAME
|
|
296
296
|
end
|
|
297
|
+
--- Helper function to get the "pedestal type" of a collectible. For example, it might be sitting on
|
|
298
|
+
-- top of a broken Blood Donation Machine, or it might be sitting on top of an opened Spiked Chest.
|
|
297
299
|
function ____exports.getCollectiblePedestalType(self, collectible)
|
|
298
300
|
if not isCollectible(nil, collectible) then
|
|
299
301
|
local entityID = getEntityID(nil, collectible)
|
|
@@ -302,8 +304,8 @@ function ____exports.getCollectiblePedestalType(self, collectible)
|
|
|
302
304
|
local sprite = collectible:GetSprite()
|
|
303
305
|
return sprite:GetOverlayFrame()
|
|
304
306
|
end
|
|
305
|
-
--- Helper function to get
|
|
306
|
-
-- type was not valid.
|
|
307
|
+
--- Helper function to get a collectible's quality. For example, Mom's Knife has a quality of 4.
|
|
308
|
+
-- Returns 0 if the provided collectible type was not valid.
|
|
307
309
|
function ____exports.getCollectibleQuality(self, collectibleType)
|
|
308
310
|
local itemConfigItem = itemConfig:GetCollectible(collectibleType)
|
|
309
311
|
if itemConfigItem == nil then
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/// <reference types="typescript-to-lua/language-extensions" />
|
|
2
2
|
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
4
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
3
5
|
import { SerializationType } from "../enums/SerializationType";
|
|
4
6
|
declare type SerializedColor = LuaMap<string, unknown> & {
|
|
5
7
|
readonly __serializedColorBrand: symbol;
|
|
@@ -19,6 +21,14 @@ export declare function colorEquals(color1: Color, color2: Color): boolean;
|
|
|
19
21
|
*/
|
|
20
22
|
export declare function copyColor<C extends Color | SerializedColor, S extends SerializationType>(color: C, serializationType: S): CopyColorReturn[S];
|
|
21
23
|
export declare function copyColor<C extends Color | SerializedColor>(color: C): CopyColorReturn[SerializationType.NONE];
|
|
24
|
+
/**
|
|
25
|
+
* Helper function to get a random color.
|
|
26
|
+
*
|
|
27
|
+
* @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
28
|
+
* `RNG.Next` method will be called. Default is `getRandomSeed()`.
|
|
29
|
+
* @param alpha Optional. The alpha value to use. Default is 1.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getRandomColor(seedOrRNG?: Seed | RNG, alpha?: number): Color;
|
|
22
32
|
/** Helper function to check if something is an instantiated Color object. */
|
|
23
33
|
export declare function isColor(object: unknown): object is Color;
|
|
24
34
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/functions/color.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/functions/color.ts"],"names":[],"mappings":";;;;AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAO/D,aAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC/C,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;CACzC,CAAC;AAEF,UAAU,eAAe;IACvB,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC;IAChC,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC;IAC/C,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC;CACxC;AAKD,wBAAgB,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,OAAO,CAEjE;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,CAAC,SAAS,KAAK,GAAG,eAAe,EACjC,CAAC,SAAS,iBAAiB,EAC3B,KAAK,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;AACtD,wBAAgB,SAAS,CAAC,CAAC,SAAS,KAAK,GAAG,eAAe,EACzD,KAAK,EAAE,CAAC,GACP,eAAe,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;AAuE3C;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,KAAK,SAAI,GACR,KAAK,CAQP;AAED,6EAA6E;AAC7E,wBAAgB,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,KAAK,CAExD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,eAAe,CAM5E"}
|
package/dist/functions/color.lua
CHANGED
|
@@ -7,6 +7,12 @@ local SerializationType = ____SerializationType.SerializationType
|
|
|
7
7
|
local ____isaacAPIClass = require("functions.isaacAPIClass")
|
|
8
8
|
local isaacAPIClassEquals = ____isaacAPIClass.isaacAPIClassEquals
|
|
9
9
|
local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
|
|
10
|
+
local ____random = require("functions.random")
|
|
11
|
+
local getRandom = ____random.getRandom
|
|
12
|
+
local ____rng = require("functions.rng")
|
|
13
|
+
local getRandomSeed = ____rng.getRandomSeed
|
|
14
|
+
local isRNG = ____rng.isRNG
|
|
15
|
+
local newRNG = ____rng.newRNG
|
|
10
16
|
local ____table = require("functions.table")
|
|
11
17
|
local copyValuesToTable = ____table.copyValuesToTable
|
|
12
18
|
local getNumbersFromTable = ____table.getNumbersFromTable
|
|
@@ -104,6 +110,24 @@ function ____exports.copyColor(self, color, serializationType)
|
|
|
104
110
|
end
|
|
105
111
|
until true
|
|
106
112
|
end
|
|
113
|
+
--- Helper function to get a random color.
|
|
114
|
+
--
|
|
115
|
+
-- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
116
|
+
-- `RNG.Next` method will be called. Default is `getRandomSeed()`.
|
|
117
|
+
-- @param alpha Optional. The alpha value to use. Default is 1.
|
|
118
|
+
function ____exports.getRandomColor(self, seedOrRNG, alpha)
|
|
119
|
+
if seedOrRNG == nil then
|
|
120
|
+
seedOrRNG = getRandomSeed(nil)
|
|
121
|
+
end
|
|
122
|
+
if alpha == nil then
|
|
123
|
+
alpha = 1
|
|
124
|
+
end
|
|
125
|
+
local rng = isRNG(nil, seedOrRNG) and seedOrRNG or newRNG(nil, seedOrRNG)
|
|
126
|
+
local r = getRandom(nil, rng)
|
|
127
|
+
local g = getRandom(nil, rng)
|
|
128
|
+
local b = getRandom(nil, rng)
|
|
129
|
+
return Color(r, g, b, alpha)
|
|
130
|
+
end
|
|
107
131
|
--- Used to determine is the given table is a serialized `Color` object created by the save data
|
|
108
132
|
-- manager and/or the `deepCopy` function.
|
|
109
133
|
function ____exports.isSerializedColor(self, object)
|
|
@@ -175,7 +175,7 @@ export declare function removeAllMatchingGridEntities(...gridEntityType: GridEnt
|
|
|
175
175
|
* generally a good idea because if the room is not updated, you will be unable to
|
|
176
176
|
* spawn another grid entity on the same tile until a frame has passed. However,
|
|
177
177
|
* doing this is expensive, since it involves a call to `Isaac.GetRoomEntities`,
|
|
178
|
-
* so set this to false if you need to
|
|
178
|
+
* so set this to false if you need to run this function multiple times.
|
|
179
179
|
* @param cap Optional. If specified, will only remove the given amount of entities.
|
|
180
180
|
* @returns An array of the entities that were removed.
|
|
181
181
|
*/
|
|
@@ -189,7 +189,7 @@ export declare function removeGridEntities<T extends AnyGridEntity>(gridEntities
|
|
|
189
189
|
* generally a good idea because if the room is not updated, you will be unable to
|
|
190
190
|
* spawn another grid entity on the same tile until a frame has passed. However,
|
|
191
191
|
* doing this is expensive, since it involves a call to `Isaac.GetRoomEntities`,
|
|
192
|
-
* so set this to false if you need to
|
|
192
|
+
* so set this to false if you need to run this function multiple times.
|
|
193
193
|
*/
|
|
194
194
|
export declare function removeGridEntity(gridEntityOrGridIndex: GridEntity | int, updateRoom: boolean): void;
|
|
195
195
|
/**
|
|
@@ -225,24 +225,6 @@ export declare function spawnGridEntity(gridEntityType: GridEntityType, gridInde
|
|
|
225
225
|
* - allows you to specify the grid index or the position
|
|
226
226
|
*/
|
|
227
227
|
export declare function spawnGridEntityWithVariant(gridEntityType: GridEntityType, variant: int, gridIndexOrPosition: int | Vector): GridEntity | undefined;
|
|
228
|
-
/**
|
|
229
|
-
* Helper function for emulating what happens when a vanilla `GridEntityType.ROCK_ALT` grid entity
|
|
230
|
-
* breaks.
|
|
231
|
-
*
|
|
232
|
-
* Note that most of the time, this function will do nothing, similar to how most of the time, when
|
|
233
|
-
* an individual urn is destroyed, nothing will spawn.
|
|
234
|
-
*
|
|
235
|
-
* The logic in this function is based on the rewards listed on the wiki:
|
|
236
|
-
* https://bindingofisaacrebirth.fandom.com/wiki/Rocks
|
|
237
|
-
*
|
|
238
|
-
* @param rockAltType The type of reward to spawn. For example, `RockAltType.URN` will have a chance
|
|
239
|
-
* at spawning coins and spiders.
|
|
240
|
-
* @param _seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided,
|
|
241
|
-
* the `RNG.Next` method will be called. Default is `getRandomSeed()`. Normally,
|
|
242
|
-
* you should pass the `InitSeed` of the grid entity that was broken.
|
|
243
|
-
* @returns Whether or not this function spawned something.
|
|
244
|
-
*/
|
|
245
|
-
export declare function spawnRockAltReward(rockAltType: RockAltType, _seedOrRNG?: Seed | RNG): boolean;
|
|
246
228
|
/**
|
|
247
229
|
* Helper function to spawn a Void Portal. This is more complicated than simply spawning a trapdoor
|
|
248
230
|
* with the appropriate variant, as the game does not give it the correct sprite automatically.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gridEntities.d.ts","sourceRoot":"","sources":["../../src/functions/gridEntities.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAEjB,cAAc,EACd,iBAAiB,EAGjB,eAAe,EAChB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAQnD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"gridEntities.d.ts","sourceRoot":"","sources":["../../src/functions/gridEntities.ts"],"names":[],"mappings":"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"}
|
|
@@ -15,8 +15,6 @@ local ____cachedClasses = require("cachedClasses")
|
|
|
15
15
|
local game = ____cachedClasses.game
|
|
16
16
|
local ____constants = require("constants")
|
|
17
17
|
local DISTANCE_OF_GRID_TILE = ____constants.DISTANCE_OF_GRID_TILE
|
|
18
|
-
local ____RockAltType = require("enums.RockAltType")
|
|
19
|
-
local RockAltType = ____RockAltType.RockAltType
|
|
20
18
|
local ____gridEntityTypeToBrokenStateMap = require("maps.gridEntityTypeToBrokenStateMap")
|
|
21
19
|
local GRID_ENTITY_TYPE_TO_BROKEN_STATE_MAP = ____gridEntityTypeToBrokenStateMap.GRID_ENTITY_TYPE_TO_BROKEN_STATE_MAP
|
|
22
20
|
local ____gridEntityXMLMap = require("maps.gridEntityXMLMap")
|
|
@@ -28,8 +26,6 @@ local ____backdropTypeToRockAltType = require("objects.backdropTypeToRockAltType
|
|
|
28
26
|
local BACKDROP_TYPE_TO_ROCK_ALT_TYPE = ____backdropTypeToRockAltType.BACKDROP_TYPE_TO_ROCK_ALT_TYPE
|
|
29
27
|
local ____math = require("functions.math")
|
|
30
28
|
local isCircleIntersectingRectangle = ____math.isCircleIntersectingRectangle
|
|
31
|
-
local ____rng = require("functions.rng")
|
|
32
|
-
local getRandomSeed = ____rng.getRandomSeed
|
|
33
29
|
local ____rooms = require("functions.rooms")
|
|
34
30
|
local roomUpdateSafe = ____rooms.roomUpdateSafe
|
|
35
31
|
local ____sprites = require("functions.sprites")
|
|
@@ -123,7 +119,7 @@ end
|
|
|
123
119
|
-- generally a good idea because if the room is not updated, you will be unable to
|
|
124
120
|
-- spawn another grid entity on the same tile until a frame has passed. However,
|
|
125
121
|
-- doing this is expensive, since it involves a call to `Isaac.GetRoomEntities`,
|
|
126
|
-
-- so set this to false if you need to
|
|
122
|
+
-- so set this to false if you need to run this function multiple times.
|
|
127
123
|
function ____exports.removeGridEntity(self, gridEntityOrGridIndex, updateRoom)
|
|
128
124
|
local room = game:GetRoom()
|
|
129
125
|
local gridIndex = isNumber(nil, gridEntityOrGridIndex) and gridEntityOrGridIndex or gridEntityOrGridIndex:GetGridIndex()
|
|
@@ -420,7 +416,7 @@ end
|
|
|
420
416
|
-- generally a good idea because if the room is not updated, you will be unable to
|
|
421
417
|
-- spawn another grid entity on the same tile until a frame has passed. However,
|
|
422
418
|
-- doing this is expensive, since it involves a call to `Isaac.GetRoomEntities`,
|
|
423
|
-
-- so set this to false if you need to
|
|
419
|
+
-- so set this to false if you need to run this function multiple times.
|
|
424
420
|
-- @param cap Optional. If specified, will only remove the given amount of entities.
|
|
425
421
|
-- @returns An array of the entities that were removed.
|
|
426
422
|
function ____exports.removeGridEntities(self, gridEntities, updateRoom, cap)
|
|
@@ -473,59 +469,6 @@ end
|
|
|
473
469
|
function ____exports.spawnGridEntity(self, gridEntityType, gridIndexOrPosition)
|
|
474
470
|
return ____exports.spawnGridEntityWithVariant(nil, gridEntityType, 0, gridIndexOrPosition)
|
|
475
471
|
end
|
|
476
|
-
--- Helper function for emulating what happens when a vanilla `GridEntityType.ROCK_ALT` grid entity
|
|
477
|
-
-- breaks.
|
|
478
|
-
--
|
|
479
|
-
-- Note that most of the time, this function will do nothing, similar to how most of the time, when
|
|
480
|
-
-- an individual urn is destroyed, nothing will spawn.
|
|
481
|
-
--
|
|
482
|
-
-- The logic in this function is based on the rewards listed on the wiki:
|
|
483
|
-
-- https://bindingofisaacrebirth.fandom.com/wiki/Rocks
|
|
484
|
-
--
|
|
485
|
-
-- @param rockAltType The type of reward to spawn. For example, `RockAltType.URN` will have a chance
|
|
486
|
-
-- at spawning coins and spiders.
|
|
487
|
-
-- @param _seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided,
|
|
488
|
-
-- the `RNG.Next` method will be called. Default is `getRandomSeed()`. Normally,
|
|
489
|
-
-- you should pass the `InitSeed` of the grid entity that was broken.
|
|
490
|
-
-- @returns Whether or not this function spawned something.
|
|
491
|
-
function ____exports.spawnRockAltReward(self, rockAltType, _seedOrRNG)
|
|
492
|
-
if _seedOrRNG == nil then
|
|
493
|
-
_seedOrRNG = getRandomSeed(nil)
|
|
494
|
-
end
|
|
495
|
-
repeat
|
|
496
|
-
local ____switch66 = rockAltType
|
|
497
|
-
local ____cond66 = ____switch66 == RockAltType.URN
|
|
498
|
-
if ____cond66 then
|
|
499
|
-
do
|
|
500
|
-
return false
|
|
501
|
-
end
|
|
502
|
-
end
|
|
503
|
-
____cond66 = ____cond66 or ____switch66 == RockAltType.MUSHROOM
|
|
504
|
-
if ____cond66 then
|
|
505
|
-
do
|
|
506
|
-
return false
|
|
507
|
-
end
|
|
508
|
-
end
|
|
509
|
-
____cond66 = ____cond66 or ____switch66 == RockAltType.SKULL
|
|
510
|
-
if ____cond66 then
|
|
511
|
-
do
|
|
512
|
-
return false
|
|
513
|
-
end
|
|
514
|
-
end
|
|
515
|
-
____cond66 = ____cond66 or ____switch66 == RockAltType.POLYP
|
|
516
|
-
if ____cond66 then
|
|
517
|
-
do
|
|
518
|
-
return false
|
|
519
|
-
end
|
|
520
|
-
end
|
|
521
|
-
____cond66 = ____cond66 or ____switch66 == RockAltType.BUCKET
|
|
522
|
-
if ____cond66 then
|
|
523
|
-
do
|
|
524
|
-
return false
|
|
525
|
-
end
|
|
526
|
-
end
|
|
527
|
-
until true
|
|
528
|
-
end
|
|
529
472
|
--- Helper function to spawn a Void Portal. This is more complicated than simply spawning a trapdoor
|
|
530
473
|
-- with the appropriate variant, as the game does not give it the correct sprite automatically.
|
|
531
474
|
function ____exports.spawnVoidPortal(self, gridIndex)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CollectibleType, ItemPoolType } from "isaac-typescript-definitions";
|
|
2
|
+
/**
|
|
3
|
+
* Helper function to see if the given collectible is still present in the given item pool.
|
|
4
|
+
*
|
|
5
|
+
* If the collectible is non-offensive, any Tainted Losts will be temporarily changed to Isaac and
|
|
6
|
+
* then changed back. (This is because Tainted Lost is not able to retrieve non-offensive
|
|
7
|
+
* collectibles from item pools).
|
|
8
|
+
*/
|
|
9
|
+
export declare function isCollectibleInItemPool(collectibleType: CollectibleType, itemPoolType: ItemPoolType): boolean;
|
|
10
|
+
//# sourceMappingURL=itemPool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itemPool.d.ts","sourceRoot":"","sources":["../../src/functions/itemPool.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,YAAY,EAGb,MAAM,8BAA8B,CAAC;AAoBtC;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,GACzB,OAAO,CAsDT"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local Map = ____lualib.Map
|
|
3
|
+
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
4
|
+
local __TS__New = ____lualib.__TS__New
|
|
5
|
+
local ____exports = {}
|
|
6
|
+
local removeItemsAndTrinketsThatAffectItemPools, restoreItemsAndTrinketsThatAffectItemPools, COLLECTIBLES_THAT_AFFECT_ITEM_POOLS, TRINKETS_THAT_AFFECT_ITEM_POOLS
|
|
7
|
+
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
8
|
+
local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
|
|
9
|
+
local ItemConfigTag = ____isaac_2Dtypescript_2Ddefinitions.ItemConfigTag
|
|
10
|
+
local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
|
|
11
|
+
local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
|
|
12
|
+
local ____cachedClasses = require("cachedClasses")
|
|
13
|
+
local game = ____cachedClasses.game
|
|
14
|
+
local ____collectibleSet = require("functions.collectibleSet")
|
|
15
|
+
local getCollectibleSet = ____collectibleSet.getCollectibleSet
|
|
16
|
+
local ____collectibleTag = require("functions.collectibleTag")
|
|
17
|
+
local collectibleHasTag = ____collectibleTag.collectibleHasTag
|
|
18
|
+
local ____playerDataStructures = require("functions.playerDataStructures")
|
|
19
|
+
local mapGetPlayer = ____playerDataStructures.mapGetPlayer
|
|
20
|
+
local mapSetPlayer = ____playerDataStructures.mapSetPlayer
|
|
21
|
+
local ____playerIndex = require("functions.playerIndex")
|
|
22
|
+
local getPlayers = ____playerIndex.getPlayers
|
|
23
|
+
local ____players = require("functions.players")
|
|
24
|
+
local getPlayersOfType = ____players.getPlayersOfType
|
|
25
|
+
local ____utils = require("functions.utils")
|
|
26
|
+
local ____repeat = ____utils["repeat"]
|
|
27
|
+
function removeItemsAndTrinketsThatAffectItemPools(self)
|
|
28
|
+
local removedItemsMap = __TS__New(Map)
|
|
29
|
+
local removedTrinketsMap = __TS__New(Map)
|
|
30
|
+
for ____, player in ipairs(getPlayers(nil)) do
|
|
31
|
+
local removedItems = {}
|
|
32
|
+
for ____, itemToRemove in ipairs(COLLECTIBLES_THAT_AFFECT_ITEM_POOLS) do
|
|
33
|
+
if player:HasCollectible(itemToRemove) then
|
|
34
|
+
local numCollectibles = player:GetCollectibleNum(itemToRemove)
|
|
35
|
+
____repeat(
|
|
36
|
+
nil,
|
|
37
|
+
numCollectibles,
|
|
38
|
+
function()
|
|
39
|
+
player:RemoveCollectible(itemToRemove)
|
|
40
|
+
removedItems[#removedItems + 1] = itemToRemove
|
|
41
|
+
end
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
mapSetPlayer(nil, removedItemsMap, player, removedItems)
|
|
46
|
+
local removedTrinkets = {}
|
|
47
|
+
for ____, trinketToRemove in ipairs(TRINKETS_THAT_AFFECT_ITEM_POOLS) do
|
|
48
|
+
if player:HasTrinket(trinketToRemove) then
|
|
49
|
+
local numTrinkets = player:GetTrinketMultiplier(trinketToRemove)
|
|
50
|
+
____repeat(
|
|
51
|
+
nil,
|
|
52
|
+
numTrinkets,
|
|
53
|
+
function()
|
|
54
|
+
player:TryRemoveTrinket(trinketToRemove)
|
|
55
|
+
removedTrinkets[#removedTrinkets + 1] = trinketToRemove
|
|
56
|
+
end
|
|
57
|
+
)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
mapSetPlayer(nil, removedTrinketsMap, player, removedTrinkets)
|
|
61
|
+
end
|
|
62
|
+
return {removedItemsMap, removedTrinketsMap}
|
|
63
|
+
end
|
|
64
|
+
function restoreItemsAndTrinketsThatAffectItemPools(self, removedItemsMap, removedTrinketsMap)
|
|
65
|
+
for ____, player in ipairs(getPlayers(nil)) do
|
|
66
|
+
local removedItems = mapGetPlayer(nil, removedItemsMap, player)
|
|
67
|
+
if removedItems ~= nil then
|
|
68
|
+
for ____, collectibleType in ipairs(removedItems) do
|
|
69
|
+
player:AddCollectible(collectibleType, 0, false)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
local removedTrinkets = mapGetPlayer(nil, removedTrinketsMap, player)
|
|
73
|
+
if removedTrinkets ~= nil then
|
|
74
|
+
for ____, trinketType in ipairs(removedTrinkets) do
|
|
75
|
+
player:AddTrinket(trinketType, false)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
COLLECTIBLES_THAT_AFFECT_ITEM_POOLS = {CollectibleType.CHAOS, CollectibleType.SACRED_ORB, CollectibleType.TMTRAINER}
|
|
81
|
+
TRINKETS_THAT_AFFECT_ITEM_POOLS = {TrinketType.NO}
|
|
82
|
+
--- Helper function to see if the given collectible is still present in the given item pool.
|
|
83
|
+
--
|
|
84
|
+
-- If the collectible is non-offensive, any Tainted Losts will be temporarily changed to Isaac and
|
|
85
|
+
-- then changed back. (This is because Tainted Lost is not able to retrieve non-offensive
|
|
86
|
+
-- collectibles from item pools).
|
|
87
|
+
function ____exports.isCollectibleInItemPool(self, collectibleType, itemPoolType)
|
|
88
|
+
local taintedLosts = getPlayersOfType(nil, PlayerType.THE_LOST_B)
|
|
89
|
+
local isOffensive = collectibleHasTag(nil, collectibleType, ItemConfigTag.OFFENSIVE)
|
|
90
|
+
local changedPlayerTypes = false
|
|
91
|
+
if not isOffensive then
|
|
92
|
+
changedPlayerTypes = true
|
|
93
|
+
for ____, player in ipairs(taintedLosts) do
|
|
94
|
+
player:ChangePlayerType(PlayerType.ISAAC)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
local removedItemsMap, removedTrinketsMap = table.unpack(removeItemsAndTrinketsThatAffectItemPools(nil))
|
|
98
|
+
local itemPool = game:GetItemPool()
|
|
99
|
+
local collectibleSet = getCollectibleSet(nil)
|
|
100
|
+
for ____, collectibleTypeInSet in __TS__Iterator(collectibleSet:values()) do
|
|
101
|
+
if collectibleTypeInSet ~= collectibleType then
|
|
102
|
+
itemPool:AddRoomBlacklist(collectibleTypeInSet)
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
local retrievedCollectibleType = itemPool:GetCollectible(itemPoolType, false, 1)
|
|
106
|
+
local collectibleUnlocked = retrievedCollectibleType == collectibleType
|
|
107
|
+
itemPool:ResetRoomBlacklist()
|
|
108
|
+
restoreItemsAndTrinketsThatAffectItemPools(nil, removedItemsMap, removedTrinketsMap)
|
|
109
|
+
if changedPlayerTypes then
|
|
110
|
+
for ____, player in ipairs(taintedLosts) do
|
|
111
|
+
player:ChangePlayerType(PlayerType.THE_LOST_B)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
return collectibleUnlocked
|
|
115
|
+
end
|
|
116
|
+
return ____exports
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/// <reference types="typescript-to-lua/language-extensions" />
|
|
2
2
|
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
4
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
3
5
|
import { SerializationType } from "../enums/SerializationType";
|
|
4
6
|
declare type SerializedKColor = LuaMap<string, unknown> & {
|
|
5
7
|
readonly __serializedKColorBrand: symbol;
|
|
@@ -18,6 +20,14 @@ interface CopyKColorReturn {
|
|
|
18
20
|
*/
|
|
19
21
|
export declare function copyKColor<K extends KColor | SerializedKColor, S extends SerializationType>(kColor: K, serializationType: S): CopyKColorReturn[S];
|
|
20
22
|
export declare function copyKColor<K extends KColor | SerializedKColor>(kColor: K): CopyKColorReturn[SerializationType.NONE];
|
|
23
|
+
/**
|
|
24
|
+
* Helper function to get a random color.
|
|
25
|
+
*
|
|
26
|
+
* @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
27
|
+
* `RNG.Next` method will be called. Default is `getRandomSeed()`.
|
|
28
|
+
* @param alpha Optional. The alpha value to use. Default is 1.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getRandomKColor(seedOrRNG?: Seed | RNG, alpha?: number): KColor;
|
|
21
31
|
/** Helper function to check if something is an instantiated KColor object. */
|
|
22
32
|
export declare function isKColor(object: unknown): object is KColor;
|
|
23
33
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kColor.d.ts","sourceRoot":"","sources":["../../src/functions/kColor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"kColor.d.ts","sourceRoot":"","sources":["../../src/functions/kColor.ts"],"names":[],"mappings":";;;;AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAO/D,aAAK,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAChD,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;CAC1C,CAAC;AAEF,UAAU,gBAAgB;IACxB,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACjC,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAChD,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CACzC;AAKD;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,CAAC,SAAS,MAAM,GAAG,gBAAgB,EACnC,CAAC,SAAS,iBAAiB,EAC3B,MAAM,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;AACxD,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,GAAG,gBAAgB,EAC5D,MAAM,EAAE,CAAC,GACR,gBAAgB,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;AAoE5C;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,KAAK,SAAI,GACR,MAAM,CAQR;AAED,8EAA8E;AAC9E,wBAAgB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,MAAM,CAE1D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,gBAAgB,CAQ5B;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAEtE"}
|
|
@@ -7,6 +7,12 @@ local SerializationType = ____SerializationType.SerializationType
|
|
|
7
7
|
local ____isaacAPIClass = require("functions.isaacAPIClass")
|
|
8
8
|
local isaacAPIClassEquals = ____isaacAPIClass.isaacAPIClassEquals
|
|
9
9
|
local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
|
|
10
|
+
local ____random = require("functions.random")
|
|
11
|
+
local getRandom = ____random.getRandom
|
|
12
|
+
local ____rng = require("functions.rng")
|
|
13
|
+
local getRandomSeed = ____rng.getRandomSeed
|
|
14
|
+
local isRNG = ____rng.isRNG
|
|
15
|
+
local newRNG = ____rng.newRNG
|
|
10
16
|
local ____table = require("functions.table")
|
|
11
17
|
local copyValuesToTable = ____table.copyValuesToTable
|
|
12
18
|
local getNumbersFromTable = ____table.getNumbersFromTable
|
|
@@ -80,6 +86,24 @@ function ____exports.copyKColor(self, kColor, serializationType)
|
|
|
80
86
|
end
|
|
81
87
|
until true
|
|
82
88
|
end
|
|
89
|
+
--- Helper function to get a random color.
|
|
90
|
+
--
|
|
91
|
+
-- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
92
|
+
-- `RNG.Next` method will be called. Default is `getRandomSeed()`.
|
|
93
|
+
-- @param alpha Optional. The alpha value to use. Default is 1.
|
|
94
|
+
function ____exports.getRandomKColor(self, seedOrRNG, alpha)
|
|
95
|
+
if seedOrRNG == nil then
|
|
96
|
+
seedOrRNG = getRandomSeed(nil)
|
|
97
|
+
end
|
|
98
|
+
if alpha == nil then
|
|
99
|
+
alpha = 1
|
|
100
|
+
end
|
|
101
|
+
local rng = isRNG(nil, seedOrRNG) and seedOrRNG or newRNG(nil, seedOrRNG)
|
|
102
|
+
local r = getRandom(nil, rng)
|
|
103
|
+
local g = getRandom(nil, rng)
|
|
104
|
+
local b = getRandom(nil, rng)
|
|
105
|
+
return KColor(r, g, b, alpha)
|
|
106
|
+
end
|
|
83
107
|
--- Used to determine is the given table is a serialized `KColor` object created by the save data
|
|
84
108
|
-- manager and/or the `deepCopy` function.
|
|
85
109
|
function ____exports.isSerializedKColor(self, object)
|
package/dist/functions/map.d.ts
CHANGED
|
@@ -20,4 +20,6 @@ export declare function copyMap<K, V>(oldMap: Map<K, V>): Map<K, V>;
|
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
export declare function getMapPartialMatch<T>(searchText: string, map: ReadonlyMap<string, T>): [string, T] | undefined;
|
|
23
|
+
/** Helper function to sum every value in a map together. */
|
|
24
|
+
export declare function sumMap(map: Map<unknown, number> | ReadonlyMap<unknown, number>): number;
|
|
23
25
|
//# sourceMappingURL=map.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/functions/map.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/functions/map.ts"],"names":[],"mappings":"AAEA,mGAAmG;AACnG,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAO1D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,GAC1B,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,CAuBzB;AAED,4DAA4D;AAC5D,wBAAgB,MAAM,CACpB,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,GACvD,MAAM,CAGR"}
|
package/dist/functions/map.lua
CHANGED
|
@@ -8,6 +8,8 @@ local __TS__StringReplaceAll = ____lualib.__TS__StringReplaceAll
|
|
|
8
8
|
local __TS__StringStartsWith = ____lualib.__TS__StringStartsWith
|
|
9
9
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
10
10
|
local ____exports = {}
|
|
11
|
+
local ____array = require("functions.array")
|
|
12
|
+
local sumArray = ____array.sumArray
|
|
11
13
|
--- Helper function to copy a map. (You can also use a Map constructor to accomplish this task.)
|
|
12
14
|
function ____exports.copyMap(self, oldMap)
|
|
13
15
|
local newMap = __TS__New(Map)
|
|
@@ -58,4 +60,9 @@ function ____exports.getMapPartialMatch(self, searchText, map)
|
|
|
58
60
|
end
|
|
59
61
|
return {matchingKey, value}
|
|
60
62
|
end
|
|
63
|
+
--- Helper function to sum every value in a map together.
|
|
64
|
+
function ____exports.sumMap(self, map)
|
|
65
|
+
local values = {__TS__Spread(map:values())}
|
|
66
|
+
return sumArray(nil, values)
|
|
67
|
+
end
|
|
61
68
|
return ____exports
|
package/dist/functions/npcs.d.ts
CHANGED
|
@@ -48,8 +48,8 @@ export declare function isDyingEggyWithNoSpidersLeft(npc: EntityNPC): boolean;
|
|
|
48
48
|
export declare function isRaglingDeathPatch(npc: EntityNPC): boolean;
|
|
49
49
|
/**
|
|
50
50
|
* The base game `EntityNPC.FireProjectiles` method does not return anything, which is a problem in
|
|
51
|
-
* situations where you need to work with the fired projectiles. This function
|
|
52
|
-
*
|
|
51
|
+
* situations where you need to work with the fired projectiles. This function runs that method, and
|
|
52
|
+
* then returns the projectiles that were spawned.
|
|
53
53
|
*
|
|
54
54
|
* @param npc The EntityNPC firing projectiles.
|
|
55
55
|
* @param position The starting position of the projectiles.
|
package/dist/functions/npcs.lua
CHANGED
|
@@ -143,8 +143,8 @@ function ____exports.getAliveNPCs(self, entityType, variant, subType, ignoreFrie
|
|
|
143
143
|
)
|
|
144
144
|
end
|
|
145
145
|
--- The base game `EntityNPC.FireProjectiles` method does not return anything, which is a problem in
|
|
146
|
-
-- situations where you need to work with the fired projectiles. This function
|
|
147
|
-
--
|
|
146
|
+
-- situations where you need to work with the fired projectiles. This function runs that method, and
|
|
147
|
+
-- then returns the projectiles that were spawned.
|
|
148
148
|
--
|
|
149
149
|
-- @param npc The EntityNPC firing projectiles.
|
|
150
150
|
-- @param position The starting position of the projectiles.
|
|
@@ -27,7 +27,7 @@ export declare function getRandomFloat(min: int, max: int, seedOrRNG?: Seed | RN
|
|
|
27
27
|
/**
|
|
28
28
|
* This returns a random integer between min and max. It is inclusive on both ends.
|
|
29
29
|
*
|
|
30
|
-
* Note that this function will
|
|
30
|
+
* Note that this function will run the `Next` method on the `RNG` object before returning the
|
|
31
31
|
* random number.
|
|
32
32
|
*
|
|
33
33
|
* For example:
|
|
@@ -44,7 +44,7 @@ function ____exports.getRandomFloat(self, min, max, seedOrRNG)
|
|
|
44
44
|
end
|
|
45
45
|
--- This returns a random integer between min and max. It is inclusive on both ends.
|
|
46
46
|
--
|
|
47
|
-
-- Note that this function will
|
|
47
|
+
-- Note that this function will run the `Next` method on the `RNG` object before returning the
|
|
48
48
|
-- random number.
|
|
49
49
|
--
|
|
50
50
|
-- For example:
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
4
|
+
import { RockAltType } from "../enums/RockAltType";
|
|
5
|
+
/**
|
|
6
|
+
* Helper function for emulating what happens when a vanilla `GridEntityType.ROCK_ALT` grid entity
|
|
7
|
+
* breaks.
|
|
8
|
+
*
|
|
9
|
+
* Note that most of the time, this function will do nothing, similar to how most of the time, when
|
|
10
|
+
* an individual urn is destroyed, nothing will spawn.
|
|
11
|
+
*
|
|
12
|
+
* The logic in this function is based on the rewards listed on the wiki:
|
|
13
|
+
* https://bindingofisaacrebirth.fandom.com/wiki/Rocks
|
|
14
|
+
*
|
|
15
|
+
* @param position The place to spawn the reward.
|
|
16
|
+
* @param rockAltType The type of reward to spawn. For example, `RockAltType.URN` will have a chance
|
|
17
|
+
* at spawning coins and spiders.
|
|
18
|
+
* @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
19
|
+
* `RNG.Next` method will be called. Default is `getRandomSeed()`. Normally, you
|
|
20
|
+
* should pass the `InitSeed` of the grid entity that was broken.
|
|
21
|
+
* @returns Whether or not this function spawned something.
|
|
22
|
+
*/
|
|
23
|
+
export declare function spawnRockAltReward(position: Vector, rockAltType: RockAltType, seedOrRNG?: Seed | RNG): boolean;
|
|
24
|
+
//# sourceMappingURL=rockAlt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rockAlt.d.ts","sourceRoot":"","sources":["../../src/functions/rockAlt.ts"],"names":[],"mappings":";;;AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAgBnD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,WAAW,EACxB,SAAS,GAAE,IAAI,GAAG,GAAqB,GACtC,OAAO,CAwBT"}
|