isaacscript-common 6.13.0 → 6.16.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.
Files changed (144) hide show
  1. package/dist/callbacks/postGridEntityCustomCollision.d.ts +2 -0
  2. package/dist/callbacks/postGridEntityCustomCollision.d.ts.map +1 -0
  3. package/dist/callbacks/postGridEntityCustomCollision.lua +71 -0
  4. package/dist/callbacks/postGridEntityCustomRender.lua +0 -7
  5. package/dist/callbacks/postGridEntityCustomUpdate.lua +0 -7
  6. package/dist/callbacks/subscriptions/postGridEntityCustomBroken.d.ts +6 -0
  7. package/dist/callbacks/subscriptions/postGridEntityCustomBroken.d.ts.map +1 -0
  8. package/dist/callbacks/subscriptions/postGridEntityCustomBroken.lua +29 -0
  9. package/dist/callbacks/subscriptions/postGridEntityCustomCollision.d.ts +6 -0
  10. package/dist/callbacks/subscriptions/postGridEntityCustomCollision.d.ts.map +1 -0
  11. package/dist/callbacks/subscriptions/postGridEntityCustomCollision.lua +29 -0
  12. package/dist/enums/ModCallbackCustom.d.ts +96 -62
  13. package/dist/enums/ModCallbackCustom.d.ts.map +1 -1
  14. package/dist/enums/ModCallbackCustom.lua +64 -60
  15. package/dist/enums/private/SerializationBrand.d.ts +1 -1
  16. package/dist/enums/private/SerializationBrand.lua +1 -1
  17. package/dist/features/customGridEntity.d.ts +7 -3
  18. package/dist/features/customGridEntity.d.ts.map +1 -1
  19. package/dist/features/customGridEntity.lua +67 -7
  20. package/dist/features/extraConsoleCommands/exports.d.ts +4 -3
  21. package/dist/features/extraConsoleCommands/exports.d.ts.map +1 -1
  22. package/dist/features/extraConsoleCommands/exports.lua +4 -3
  23. package/dist/features/extraConsoleCommands/init.lua +1 -0
  24. package/dist/functions/collectibles.d.ts +6 -2
  25. package/dist/functions/collectibles.d.ts.map +1 -1
  26. package/dist/functions/collectibles.lua +4 -2
  27. package/dist/functions/color.d.ts +20 -14
  28. package/dist/functions/color.d.ts.map +1 -1
  29. package/dist/functions/color.lua +78 -73
  30. package/dist/functions/deepCopy.d.ts.map +1 -1
  31. package/dist/functions/deepCopy.lua +22 -1
  32. package/dist/functions/gridEntities.d.ts +2 -36
  33. package/dist/functions/gridEntities.d.ts.map +1 -1
  34. package/dist/functions/gridEntities.lua +2 -78
  35. package/dist/functions/isaacAPIClass.d.ts +1 -1
  36. package/dist/functions/isaacAPIClass.d.ts.map +1 -1
  37. package/dist/functions/itemPool.d.ts +10 -0
  38. package/dist/functions/itemPool.d.ts.map +1 -0
  39. package/dist/functions/itemPool.lua +116 -0
  40. package/dist/functions/kColor.d.ts +20 -14
  41. package/dist/functions/kColor.d.ts.map +1 -1
  42. package/dist/functions/kColor.lua +65 -60
  43. package/dist/functions/mergeTests.lua +2 -2
  44. package/dist/functions/npcs.d.ts +1 -29
  45. package/dist/functions/npcs.d.ts.map +1 -1
  46. package/dist/functions/npcs.lua +0 -45
  47. package/dist/functions/projectiles.d.ts +32 -0
  48. package/dist/functions/projectiles.d.ts.map +1 -0
  49. package/dist/functions/projectiles.lua +73 -0
  50. package/dist/functions/random.d.ts +1 -1
  51. package/dist/functions/random.lua +1 -1
  52. package/dist/functions/rng.d.ts +11 -15
  53. package/dist/functions/rng.d.ts.map +1 -1
  54. package/dist/functions/rng.lua +32 -52
  55. package/dist/functions/rockAlt.d.ts +48 -0
  56. package/dist/functions/rockAlt.d.ts.map +1 -0
  57. package/dist/functions/rockAlt.lua +365 -0
  58. package/dist/functions/saveFile.d.ts +8 -7
  59. package/dist/functions/saveFile.d.ts.map +1 -1
  60. package/dist/functions/saveFile.lua +10 -96
  61. package/dist/functions/serialization.d.ts +26 -7
  62. package/dist/functions/serialization.d.ts.map +1 -1
  63. package/dist/functions/serialization.lua +51 -19
  64. package/dist/functions/table.d.ts +2 -2
  65. package/dist/functions/table.lua +2 -2
  66. package/dist/functions/trinketGive.d.ts +13 -0
  67. package/dist/functions/trinketGive.d.ts.map +1 -1
  68. package/dist/functions/trinketGive.lua +16 -0
  69. package/dist/functions/tstlClass.d.ts +1 -1
  70. package/dist/functions/tstlClass.d.ts.map +1 -1
  71. package/dist/functions/vector.d.ts +21 -14
  72. package/dist/functions/vector.d.ts.map +1 -1
  73. package/dist/functions/vector.lua +58 -54
  74. package/dist/index.d.ts +2 -0
  75. package/dist/index.d.ts.map +1 -1
  76. package/dist/index.lua +16 -0
  77. package/dist/initCustomCallbacks.d.ts.map +1 -1
  78. package/dist/initCustomCallbacks.lua +3 -0
  79. package/dist/interfaces/AddCallbackParameterCustom.d.ts +4 -0
  80. package/dist/interfaces/AddCallbackParameterCustom.d.ts.map +1 -1
  81. package/dist/objects/callbackRegisterFunctions.d.ts.map +1 -1
  82. package/dist/objects/callbackRegisterFunctions.lua +6 -0
  83. package/dist/objects/isaacAPIClassTypeToFunctions.d.ts +12 -0
  84. package/dist/objects/isaacAPIClassTypeToFunctions.d.ts.map +1 -0
  85. package/dist/objects/isaacAPIClassTypeToFunctions.lua +25 -0
  86. package/dist/types/{private/IsaacAPIClass.d.ts → IsaacAPIClass.d.ts} +0 -0
  87. package/dist/types/IsaacAPIClass.d.ts.map +1 -0
  88. package/dist/types/{private/IsaacAPIClass.lua → IsaacAPIClass.lua} +0 -0
  89. package/dist/types/{private/SerializedIsaacAPIClass.d.ts → SerializedIsaacAPIClass.d.ts} +0 -0
  90. package/dist/types/SerializedIsaacAPIClass.d.ts.map +1 -0
  91. package/dist/types/{private/SerializedIsaacAPIClass.lua → SerializedIsaacAPIClass.lua} +0 -0
  92. package/dist/types/{private/TSTLClass.d.ts → TSTLClass.d.ts} +0 -0
  93. package/dist/types/TSTLClass.d.ts.map +1 -0
  94. package/dist/types/{private/TSTLClass.lua → TSTLClass.lua} +0 -0
  95. package/package.json +2 -2
  96. package/src/callbacks/postGridEntityCustomCollision.ts +74 -0
  97. package/src/callbacks/postGridEntityCustomRender.ts +1 -17
  98. package/src/callbacks/postGridEntityCustomUpdate.ts +1 -17
  99. package/src/callbacks/subscriptions/postGridEntityCustomBroken.ts +41 -0
  100. package/src/callbacks/subscriptions/postGridEntityCustomCollision.ts +43 -0
  101. package/src/enums/ModCallbackCustom.ts +38 -2
  102. package/src/enums/private/SerializationBrand.ts +1 -1
  103. package/src/features/customGridEntity.ts +78 -2
  104. package/src/features/extraConsoleCommands/exports.ts +4 -3
  105. package/src/features/extraConsoleCommands/init.ts +1 -0
  106. package/src/features/extraConsoleCommands/listCommands.ts +2 -2
  107. package/src/functions/collectibles.ts +6 -2
  108. package/src/functions/color.ts +89 -87
  109. package/src/functions/deepCopy.ts +15 -2
  110. package/src/functions/gridEntities.ts +2 -77
  111. package/src/functions/isaacAPIClass.ts +1 -1
  112. package/src/functions/itemPool.ts +153 -0
  113. package/src/functions/kColor.ts +87 -84
  114. package/src/functions/mergeTests.ts +2 -2
  115. package/src/functions/npcs.ts +1 -58
  116. package/src/functions/projectiles.ts +78 -0
  117. package/src/functions/random.ts +1 -1
  118. package/src/functions/rng.ts +45 -65
  119. package/src/functions/rockAlt.ts +396 -0
  120. package/src/functions/saveFile.ts +13 -119
  121. package/src/functions/serialization.ts +81 -25
  122. package/src/functions/table.ts +2 -2
  123. package/src/functions/trinketGive.ts +21 -0
  124. package/src/functions/tstlClass.ts +1 -1
  125. package/src/functions/vector.ts +78 -74
  126. package/src/index.ts +2 -0
  127. package/src/initCustomCallbacks.ts +2 -0
  128. package/src/interfaces/AddCallbackParameterCustom.ts +4 -0
  129. package/src/objects/callbackRegisterFunctions.ts +6 -0
  130. package/src/objects/isaacAPIClassTypeToFunctions.ts +63 -0
  131. package/src/types/{private/IsaacAPIClass.ts → IsaacAPIClass.ts} +0 -0
  132. package/src/types/{private/SerializedIsaacAPIClass.ts → SerializedIsaacAPIClass.ts} +0 -0
  133. package/src/types/{private/TSTLClass.ts → TSTLClass.ts} +0 -0
  134. package/dist/objects/isaacAPIClassTypeToCopyFunction.d.ts +0 -6
  135. package/dist/objects/isaacAPIClassTypeToCopyFunction.d.ts.map +0 -1
  136. package/dist/objects/isaacAPIClassTypeToCopyFunction.lua +0 -13
  137. package/dist/objects/serializedIsaacAPIClassTypeToIdentityFunction.d.ts +0 -5
  138. package/dist/objects/serializedIsaacAPIClassTypeToIdentityFunction.d.ts.map +0 -1
  139. package/dist/objects/serializedIsaacAPIClassTypeToIdentityFunction.lua +0 -13
  140. package/dist/types/private/IsaacAPIClass.d.ts.map +0 -1
  141. package/dist/types/private/SerializedIsaacAPIClass.d.ts.map +0 -1
  142. package/dist/types/private/TSTLClass.d.ts.map +0 -1
  143. package/src/objects/isaacAPIClassTypeToCopyFunction.ts +0 -18
  144. package/src/objects/serializedIsaacAPIClassTypeToIdentityFunction.ts +0 -14
@@ -2,11 +2,15 @@ local ____exports = {}
2
2
  local OBJECT_NAME
3
3
  local ____SerializationBrand = require("enums.private.SerializationBrand")
4
4
  local SerializationBrand = ____SerializationBrand.SerializationBrand
5
- local ____SerializationType = require("enums.SerializationType")
6
- local SerializationType = ____SerializationType.SerializationType
7
5
  local ____isaacAPIClass = require("functions.isaacAPIClass")
8
6
  local isaacAPIClassEquals = ____isaacAPIClass.isaacAPIClassEquals
9
7
  local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
8
+ local ____random = require("functions.random")
9
+ local getRandom = ____random.getRandom
10
+ local ____rng = require("functions.rng")
11
+ local getRandomSeed = ____rng.getRandomSeed
12
+ local isRNG = ____rng.isRNG
13
+ local newRNG = ____rng.newRNG
10
14
  local ____table = require("functions.table")
11
15
  local copyValuesToTable = ____table.copyValuesToTable
12
16
  local getNumbersFromTable = ____table.getNumbersFromTable
@@ -30,79 +34,69 @@ OBJECT_NAME = "Color"
30
34
  function ____exports.colorEquals(self, color1, color2)
31
35
  return isaacAPIClassEquals(nil, color1, color2, KEYS)
32
36
  end
33
- --- Helper function to copy a `Color` object.
37
+ --- Helper function to copy a `Color` Isaac API class.
38
+ function ____exports.copyColor(self, color)
39
+ if not ____exports.isColor(nil, color) then
40
+ error(((("Failed to copy a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
41
+ end
42
+ return Color(
43
+ color.R,
44
+ color.G,
45
+ color.B,
46
+ color.A,
47
+ color.RO,
48
+ color.GO,
49
+ color.BO
50
+ )
51
+ end
52
+ --- Helper function to convert a `SerializedColor` object to a normal `Color` object. (This is used
53
+ -- by the save data manager when reading data from the "save#.dat" file.)
54
+ function ____exports.deserializeColor(self, color)
55
+ if not isTable(nil, color) then
56
+ error(("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object was not a Lua table.")
57
+ end
58
+ local r, g, b, a, ro, go, bo = table.unpack(getNumbersFromTable(
59
+ nil,
60
+ color,
61
+ OBJECT_NAME,
62
+ table.unpack(KEYS)
63
+ ))
64
+ if r == nil then
65
+ error(("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object did not have a value for: R")
66
+ end
67
+ if g == nil then
68
+ error(("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object did not have a value for: G")
69
+ end
70
+ if b == nil then
71
+ error(("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object did not have a value for: B")
72
+ end
73
+ return Color(
74
+ r,
75
+ g,
76
+ b,
77
+ a,
78
+ ro,
79
+ go,
80
+ bo
81
+ )
82
+ end
83
+ --- Helper function to get a random color.
34
84
  --
35
- -- @param color The Color object to copy. In the case of deserialization, this will actually be a
36
- -- Lua table instead of an instantiated Color class.
37
- -- @param serializationType Default is `SerializationType.NONE`.
38
- function ____exports.copyColor(self, color, serializationType)
39
- if serializationType == nil then
40
- serializationType = SerializationType.NONE
85
+ -- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
86
+ -- `RNG.Next` method will be called. Default is `getRandomSeed()`.
87
+ -- @param alpha Optional. The alpha value to use. Default is 1.
88
+ function ____exports.getRandomColor(self, seedOrRNG, alpha)
89
+ if seedOrRNG == nil then
90
+ seedOrRNG = getRandomSeed(nil)
41
91
  end
42
- repeat
43
- local ____switch4 = serializationType
44
- local ____cond4 = ____switch4 == SerializationType.NONE
45
- if ____cond4 then
46
- do
47
- if not ____exports.isColor(nil, color) then
48
- error(((("Failed to copy a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
49
- end
50
- return Color(
51
- color.R,
52
- color.G,
53
- color.B,
54
- color.A,
55
- color.RO,
56
- color.GO,
57
- color.BO
58
- )
59
- end
60
- end
61
- ____cond4 = ____cond4 or ____switch4 == SerializationType.SERIALIZE
62
- if ____cond4 then
63
- do
64
- if not ____exports.isColor(nil, color) then
65
- error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
66
- end
67
- local colorTable = {}
68
- copyValuesToTable(nil, color, KEYS, colorTable)
69
- colorTable[SerializationBrand.COLOR] = ""
70
- return colorTable
71
- end
72
- end
73
- ____cond4 = ____cond4 or ____switch4 == SerializationType.DESERIALIZE
74
- if ____cond4 then
75
- do
76
- if not isTable(nil, color) then
77
- error(("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object was not a Lua table.")
78
- end
79
- local r, g, b, a, ro, go, bo = table.unpack(getNumbersFromTable(
80
- nil,
81
- color,
82
- OBJECT_NAME,
83
- table.unpack(KEYS)
84
- ))
85
- if r == nil then
86
- error(("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object did not have a value for: r")
87
- end
88
- if g == nil then
89
- error(("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object did not have a value for: g")
90
- end
91
- if b == nil then
92
- error(("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object did not have a value for: b")
93
- end
94
- return Color(
95
- r,
96
- g,
97
- b,
98
- a,
99
- ro,
100
- go,
101
- bo
102
- )
103
- end
104
- end
105
- until true
92
+ if alpha == nil then
93
+ alpha = 1
94
+ end
95
+ local rng = isRNG(nil, seedOrRNG) and seedOrRNG or newRNG(nil, seedOrRNG)
96
+ local r = getRandom(nil, rng)
97
+ local g = getRandom(nil, rng)
98
+ local b = getRandom(nil, rng)
99
+ return Color(r, g, b, alpha)
106
100
  end
107
101
  --- Used to determine is the given table is a serialized `Color` object created by the save data
108
102
  -- manager and/or the `deepCopy` function.
@@ -116,4 +110,15 @@ function ____exports.isSerializedColor(self, object)
116
110
  table.unpack(KEYS)
117
111
  ) and object[SerializationBrand.COLOR] ~= nil
118
112
  end
113
+ --- Helper function to convert a `Color` object to a `SerializedColor` object. (This is used by the
114
+ -- save data manager when writing data from the "save#.dat" file.)
115
+ function ____exports.serializeColor(self, color)
116
+ if not ____exports.isColor(nil, color) then
117
+ error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
118
+ end
119
+ local colorTable = {}
120
+ copyValuesToTable(nil, color, KEYS, colorTable)
121
+ colorTable[SerializationBrand.COLOR] = ""
122
+ return colorTable
123
+ end
119
124
  return ____exports
@@ -1 +1 @@
1
- {"version":3,"file":"deepCopy.d.ts","sourceRoot":"","sources":["../../src/functions/deepCopy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AA4B/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,OAAO,EACd,iBAAiB,oBAAyB,EAC1C,oBAAoB,SAAK,EACzB,SAAS,UAAQ,GAChB,OAAO,CAkDT"}
1
+ {"version":3,"file":"deepCopy.d.ts","sourceRoot":"","sources":["../../src/functions/deepCopy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AA6B/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,OAAO,EACd,iBAAiB,oBAAyB,EAC1C,oBAAoB,SAAK,EACzB,SAAS,UAAQ,GAChB,OAAO,CAkDT"}
@@ -31,6 +31,7 @@ local ____serialization = require("functions.serialization")
31
31
  local copyIsaacAPIClass = ____serialization.copyIsaacAPIClass
32
32
  local deserializeIsaacAPIClass = ____serialization.deserializeIsaacAPIClass
33
33
  local isSerializedIsaacAPIClass = ____serialization.isSerializedIsaacAPIClass
34
+ local serializeIsaacAPIClass = ____serialization.serializeIsaacAPIClass
34
35
  local ____tstlClass = require("functions.tstlClass")
35
36
  local getTSTLClassName = ____tstlClass.getTSTLClassName
36
37
  local isDefaultMap = ____tstlClass.isDefaultMap
@@ -520,7 +521,27 @@ function deepCopyUserdata(self, value, serializationType, traversalDescription)
520
521
  if not COPYABLE_ISAAC_API_CLASS_TYPES_SET:has(classType) then
521
522
  error((("The deep copy function does not support copying \"" .. traversalDescription) .. "\", since it is an Isaac API class of type: ") .. classType)
522
523
  end
523
- return copyIsaacAPIClass(nil, value, serializationType)
524
+ repeat
525
+ local ____switch99 = serializationType
526
+ local ____cond99 = ____switch99 == SerializationType.NONE
527
+ if ____cond99 then
528
+ do
529
+ return copyIsaacAPIClass(nil, value)
530
+ end
531
+ end
532
+ ____cond99 = ____cond99 or ____switch99 == SerializationType.SERIALIZE
533
+ if ____cond99 then
534
+ do
535
+ return serializeIsaacAPIClass(nil, value)
536
+ end
537
+ end
538
+ ____cond99 = ____cond99 or ____switch99 == SerializationType.DESERIALIZE
539
+ if ____cond99 then
540
+ do
541
+ return deserializeIsaacAPIClass(nil, value)
542
+ end
543
+ end
544
+ until true
524
545
  end
525
546
  COPYABLE_ISAAC_API_CLASS_TYPES_SET = __TS__New(
526
547
  Set,
@@ -1,5 +1,4 @@
1
1
  import { CrawlSpaceVariant, GridEntityType, GridEntityXMLType, TrapdoorVariant } from "isaac-typescript-definitions";
2
- import { RockAltType } from "../enums/RockAltType";
3
2
  import { AnyGridEntity } from "../types/AnyGridEntity";
4
3
  /**
5
4
  * Helper function to convert the grid entity type found in a room XML file to the corresponding
@@ -82,21 +81,6 @@ export declare function getGridEntityIDFromConstituents(gridEntityType: GridEnti
82
81
  * If you want to match every variant, use the `getGridEntities` function instead.
83
82
  */
84
83
  export declare function getMatchingGridEntities(gridEntityType: GridEntityType, variant: int): GridEntity[];
85
- /**
86
- * Helper function to get the alternate rock type (i.e. urn, mushroom, etc.) that the current room
87
- * will have.
88
- *
89
- * The rock type is based on the backdrop of the room.
90
- *
91
- * For example, if you change the backdrop of the starting room of the run to `BackdropType.CAVES`,
92
- * and then spawn `GridEntityType.ROCK_ALT`, it will be a mushroom instead of an urn. Additionally,
93
- * if it is destroyed, it will generate mushroom-appropriate rewards.
94
- *
95
- * On the other hand, if an urn is spawned first before the backdrop is changed to
96
- * `BackdropType.CAVES`, the graphic of the urn will not switch to a mushroom. However, when
97
- * destroyed, the urn will still generate mushroom-appropriate rewards.
98
- */
99
- export declare function getRockAltType(): RockAltType;
100
84
  export declare function getSurroundingGridEntities(gridEntity: GridEntity): GridEntity[];
101
85
  export declare function getTopLeftWall(): GridEntity | undefined;
102
86
  /**
@@ -175,7 +159,7 @@ export declare function removeAllMatchingGridEntities(...gridEntityType: GridEnt
175
159
  * generally a good idea because if the room is not updated, you will be unable to
176
160
  * spawn another grid entity on the same tile until a frame has passed. However,
177
161
  * doing this is expensive, since it involves a call to `Isaac.GetRoomEntities`,
178
- * so set this to false if you need to invoke this function multiple times.
162
+ * so set this to false if you need to run this function multiple times.
179
163
  * @param cap Optional. If specified, will only remove the given amount of entities.
180
164
  * @returns An array of the entities that were removed.
181
165
  */
@@ -189,7 +173,7 @@ export declare function removeGridEntities<T extends AnyGridEntity>(gridEntities
189
173
  * generally a good idea because if the room is not updated, you will be unable to
190
174
  * spawn another grid entity on the same tile until a frame has passed. However,
191
175
  * doing this is expensive, since it involves a call to `Isaac.GetRoomEntities`,
192
- * so set this to false if you need to invoke this function multiple times.
176
+ * so set this to false if you need to run this function multiple times.
193
177
  */
194
178
  export declare function removeGridEntity(gridEntityOrGridIndex: GridEntity | int, updateRoom: boolean): void;
195
179
  /**
@@ -225,24 +209,6 @@ export declare function spawnGridEntity(gridEntityType: GridEntityType, gridInde
225
209
  * - allows you to specify the grid index or the position
226
210
  */
227
211
  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
212
  /**
247
213
  * Helper function to spawn a Void Portal. This is more complicated than simply spawning a trapdoor
248
214
  * 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;AA+BvD;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,iBAAiB,EAAE,iBAAiB,EACpC,oBAAoB,EAAE,GAAG,GACxB,CAAC,cAAc,EAAE,GAAG,CAAC,GAAG,SAAS,CAqBnC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,GAAG,EAAE,CAKzC;AAED;;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AI,CAGnE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,gBAAgB,EAAE,GAAG,GAAG,IAAI,CA4B1D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,cAAc,EAAE,cAAc,EAC9B,mBAAmB,EAAE,GAAG,GAAG,MAAM,GAChC,UAAU,GAAG,SAAS,CAExB;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,GAAG,EACZ,mBAAmB,EAAE,GAAG,GAAG,MAAM,GAChC,UAAU,GAAG,SAAS,CAgCxB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,GAAG,GAAG,UAAU,GAAG,SAAS,CAkBtE"}
@@ -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")
@@ -24,12 +22,8 @@ local GRID_ENTITY_XML_MAP = ____gridEntityXMLMap.GRID_ENTITY_XML_MAP
24
22
  local ____roomShapeToTopLeftWallGridIndexMap = require("maps.roomShapeToTopLeftWallGridIndexMap")
25
23
  local DEFAULT_TOP_LEFT_WALL_GRID_INDEX = ____roomShapeToTopLeftWallGridIndexMap.DEFAULT_TOP_LEFT_WALL_GRID_INDEX
26
24
  local ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP = ____roomShapeToTopLeftWallGridIndexMap.ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP
27
- local ____backdropTypeToRockAltType = require("objects.backdropTypeToRockAltType")
28
- local BACKDROP_TYPE_TO_ROCK_ALT_TYPE = ____backdropTypeToRockAltType.BACKDROP_TYPE_TO_ROCK_ALT_TYPE
29
25
  local ____math = require("functions.math")
30
26
  local isCircleIntersectingRectangle = ____math.isCircleIntersectingRectangle
31
- local ____rng = require("functions.rng")
32
- local getRandomSeed = ____rng.getRandomSeed
33
27
  local ____rooms = require("functions.rooms")
34
28
  local roomUpdateSafe = ____rooms.roomUpdateSafe
35
29
  local ____sprites = require("functions.sprites")
@@ -123,7 +117,7 @@ end
123
117
  -- generally a good idea because if the room is not updated, you will be unable to
124
118
  -- spawn another grid entity on the same tile until a frame has passed. However,
125
119
  -- doing this is expensive, since it involves a call to `Isaac.GetRoomEntities`,
126
- -- so set this to false if you need to invoke this function multiple times.
120
+ -- so set this to false if you need to run this function multiple times.
127
121
  function ____exports.removeGridEntity(self, gridEntityOrGridIndex, updateRoom)
128
122
  local room = game:GetRoom()
129
123
  local gridIndex = isNumber(nil, gridEntityOrGridIndex) and gridEntityOrGridIndex or gridEntityOrGridIndex:GetGridIndex()
@@ -274,23 +268,6 @@ end
274
268
  function ____exports.getGridEntityIDFromConstituents(self, gridEntityType, variant)
275
269
  return (tostring(gridEntityType) .. ".") .. tostring(variant)
276
270
  end
277
- --- Helper function to get the alternate rock type (i.e. urn, mushroom, etc.) that the current room
278
- -- will have.
279
- --
280
- -- The rock type is based on the backdrop of the room.
281
- --
282
- -- For example, if you change the backdrop of the starting room of the run to `BackdropType.CAVES`,
283
- -- and then spawn `GridEntityType.ROCK_ALT`, it will be a mushroom instead of an urn. Additionally,
284
- -- if it is destroyed, it will generate mushroom-appropriate rewards.
285
- --
286
- -- On the other hand, if an urn is spawned first before the backdrop is changed to
287
- -- `BackdropType.CAVES`, the graphic of the urn will not switch to a mushroom. However, when
288
- -- destroyed, the urn will still generate mushroom-appropriate rewards.
289
- function ____exports.getRockAltType(self)
290
- local room = game:GetRoom()
291
- local backdropType = room:GetBackdropType()
292
- return BACKDROP_TYPE_TO_ROCK_ALT_TYPE[backdropType]
293
- end
294
271
  function ____exports.getSurroundingGridEntities(self, gridEntity)
295
272
  local room = game:GetRoom()
296
273
  local gridWidth = room:GetGridWidth()
@@ -420,7 +397,7 @@ end
420
397
  -- generally a good idea because if the room is not updated, you will be unable to
421
398
  -- spawn another grid entity on the same tile until a frame has passed. However,
422
399
  -- doing this is expensive, since it involves a call to `Isaac.GetRoomEntities`,
423
- -- so set this to false if you need to invoke this function multiple times.
400
+ -- so set this to false if you need to run this function multiple times.
424
401
  -- @param cap Optional. If specified, will only remove the given amount of entities.
425
402
  -- @returns An array of the entities that were removed.
426
403
  function ____exports.removeGridEntities(self, gridEntities, updateRoom, cap)
@@ -473,59 +450,6 @@ end
473
450
  function ____exports.spawnGridEntity(self, gridEntityType, gridIndexOrPosition)
474
451
  return ____exports.spawnGridEntityWithVariant(nil, gridEntityType, 0, gridIndexOrPosition)
475
452
  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
453
  --- Helper function to spawn a Void Portal. This is more complicated than simply spawning a trapdoor
530
454
  -- with the appropriate variant, as the game does not give it the correct sprite automatically.
531
455
  function ____exports.spawnVoidPortal(self, gridIndex)
@@ -17,7 +17,7 @@
17
17
  /// <reference types="isaac-typescript-definitions" />
18
18
  /// <reference types="isaac-typescript-definitions" />
19
19
  /// <reference types="isaac-typescript-definitions" />
20
- import { IsaacAPIClass } from "../types/private/IsaacAPIClass";
20
+ import { IsaacAPIClass } from "../types/IsaacAPIClass";
21
21
  /**
22
22
  * Helper function to get the name of a class from the Isaac API. This is contained within the
23
23
  * "__type" metatable key.
@@ -1 +1 @@
1
- {"version":3,"file":"isaacAPIClass.d.ts","sourceRoot":"","sources":["../../src/functions/isaacAPIClass.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAI/D;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAkBxE;AAED,uEAAuE;AACvE,wBAAgB,MAAM,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,UAAU,CAEhE;AAED,2EAA2E;AAC3E,wBAAgB,MAAM,CAAC,QAAQ,EAAE,OAA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AG,QAAQ,IAAI,gBAAgB,CAE5E;AAED,2EAA2E;AAC3E,wBAAgB,MAAM,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,cAAc,CAEpE;AAED,6EAA6E;AAC7E,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,gBAAgB,CAExE;AAED,0EAA0E;AAC1E,wBAAgB,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,aAAa,CAElE;AAED,uEAAuE;AACvE,wBAAgB,MAAM,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,UAAU,CAEhE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,EAAE,GACb,OAAO,CAKT"}
@@ -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,23 +1,25 @@
1
1
  /// <reference types="typescript-to-lua/language-extensions" />
2
2
  /// <reference types="isaac-typescript-definitions" />
3
- import { SerializationType } from "../enums/SerializationType";
4
- declare type SerializedKColor = LuaMap<string, unknown> & {
3
+ /// <reference types="isaac-typescript-definitions" />
4
+ /// <reference types="isaac-typescript-definitions" />
5
+ export declare type SerializedKColor = LuaMap<string, unknown> & {
5
6
  readonly __serializedKColorBrand: symbol;
6
7
  };
7
- interface CopyKColorReturn {
8
- [SerializationType.NONE]: KColor;
9
- [SerializationType.SERIALIZE]: SerializedKColor;
10
- [SerializationType.DESERIALIZE]: KColor;
11
- }
8
+ /** Helper function to copy a `KColor` Isaac API class. */
9
+ export declare function copyKColor(kColor: KColor): KColor;
10
+ /**
11
+ * Helper function to convert a `SerializedKColor` object to a normal `KColor` object. (This is used
12
+ * by the save data manager when reading data from the "save#.dat" file.)
13
+ */
14
+ export declare function deserializeKColor(kColor: SerializedKColor): KColor;
12
15
  /**
13
- * Helper function to copy a `KColor` object.
16
+ * Helper function to get a random color.
14
17
  *
15
- * @param kColor The KColor object to copy. In the case of deserialization, this will actually be a
16
- * Lua table instead of an instantiated KColor class.
17
- * @param serializationType Default is `SerializationType.NONE`.
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()`.
20
+ * @param alpha Optional. The alpha value to use. Default is 1.
18
21
  */
19
- export declare function copyKColor<K extends KColor | SerializedKColor, S extends SerializationType>(kColor: K, serializationType: S): CopyKColorReturn[S];
20
- export declare function copyKColor<K extends KColor | SerializedKColor>(kColor: K): CopyKColorReturn[SerializationType.NONE];
22
+ export declare function getRandomKColor(seedOrRNG?: Seed | RNG, alpha?: number): KColor;
21
23
  /** Helper function to check if something is an instantiated KColor object. */
22
24
  export declare function isKColor(object: unknown): object is KColor;
23
25
  /**
@@ -26,5 +28,9 @@ export declare function isKColor(object: unknown): object is KColor;
26
28
  */
27
29
  export declare function isSerializedKColor(object: unknown): object is SerializedKColor;
28
30
  export declare function kColorEquals(kColor1: KColor, kColor2: KColor): boolean;
29
- export {};
31
+ /**
32
+ * Helper function to convert a `KColor` object to a `SerializedKColor` object. (This is used by the
33
+ * save data manager when writing data from the "save#.dat" file.)
34
+ */
35
+ export declare function serializeKColor(kColor: KColor): SerializedKColor;
30
36
  //# sourceMappingURL=kColor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"kColor.d.ts","sourceRoot":"","sources":["../../src/functions/kColor.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAK/D,aAAK,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAA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