isaacscript-common 6.15.0 → 6.16.2
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/callbacks/postGridEntityCustomCollision.d.ts +2 -0
- package/dist/callbacks/postGridEntityCustomCollision.d.ts.map +1 -0
- package/dist/callbacks/postGridEntityCustomCollision.lua +71 -0
- package/dist/callbacks/postGridEntityCustomRender.lua +0 -7
- package/dist/callbacks/postGridEntityCustomUpdate.lua +0 -7
- package/dist/callbacks/subscriptions/postGridEntityCustomBroken.d.ts +6 -0
- package/dist/callbacks/subscriptions/postGridEntityCustomBroken.d.ts.map +1 -0
- package/dist/callbacks/subscriptions/postGridEntityCustomBroken.lua +24 -0
- package/dist/callbacks/subscriptions/postGridEntityCustomCollision.d.ts +6 -0
- package/dist/callbacks/subscriptions/postGridEntityCustomCollision.d.ts.map +1 -0
- package/dist/callbacks/subscriptions/postGridEntityCustomCollision.lua +29 -0
- package/dist/enums/ModCallbackCustom.d.ts +96 -62
- package/dist/enums/ModCallbackCustom.d.ts.map +1 -1
- package/dist/enums/ModCallbackCustom.lua +64 -60
- package/dist/features/customGridEntity.d.ts +5 -1
- package/dist/features/customGridEntity.d.ts.map +1 -1
- package/dist/features/customGridEntity.lua +65 -5
- package/dist/functions/color.d.ts +11 -15
- package/dist/functions/color.d.ts.map +1 -1
- package/dist/functions/color.lua +55 -74
- package/dist/functions/deepCopy.d.ts.map +1 -1
- package/dist/functions/deepCopy.lua +22 -1
- package/dist/functions/gridEntities.d.ts +0 -16
- package/dist/functions/gridEntities.d.ts.map +1 -1
- package/dist/functions/gridEntities.lua +0 -19
- package/dist/functions/isaacAPIClass.d.ts +1 -1
- package/dist/functions/isaacAPIClass.d.ts.map +1 -1
- package/dist/functions/kColor.d.ts +11 -15
- package/dist/functions/kColor.d.ts.map +1 -1
- package/dist/functions/kColor.lua +42 -61
- package/dist/functions/mergeTests.lua +2 -2
- package/dist/functions/npcs.d.ts +1 -29
- package/dist/functions/npcs.d.ts.map +1 -1
- package/dist/functions/npcs.lua +0 -45
- package/dist/functions/projectiles.d.ts +32 -0
- package/dist/functions/projectiles.d.ts.map +1 -0
- package/dist/functions/projectiles.lua +73 -0
- package/dist/functions/rng.d.ts +11 -15
- package/dist/functions/rng.d.ts.map +1 -1
- package/dist/functions/rng.lua +32 -52
- package/dist/functions/rockAlt.d.ts +27 -3
- package/dist/functions/rockAlt.d.ts.map +1 -1
- package/dist/functions/rockAlt.lua +113 -33
- package/dist/functions/saveFile.d.ts.map +1 -1
- package/dist/functions/saveFile.lua +3 -1
- package/dist/functions/serialization.d.ts +26 -7
- package/dist/functions/serialization.d.ts.map +1 -1
- package/dist/functions/serialization.lua +51 -19
- package/dist/functions/table.d.ts +2 -2
- package/dist/functions/table.lua +2 -2
- package/dist/functions/tstlClass.d.ts +1 -1
- package/dist/functions/tstlClass.d.ts.map +1 -1
- package/dist/functions/vector.d.ts +11 -15
- package/dist/functions/vector.d.ts.map +1 -1
- package/dist/functions/vector.lua +36 -55
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.lua +8 -0
- package/dist/initCustomCallbacks.d.ts.map +1 -1
- package/dist/initCustomCallbacks.lua +3 -0
- package/dist/interfaces/AddCallbackParameterCustom.d.ts +4 -0
- package/dist/interfaces/AddCallbackParameterCustom.d.ts.map +1 -1
- package/dist/objects/callbackRegisterFunctions.d.ts.map +1 -1
- package/dist/objects/callbackRegisterFunctions.lua +6 -0
- package/dist/objects/isaacAPIClassTypeToFunctions.d.ts +12 -0
- package/dist/objects/isaacAPIClassTypeToFunctions.d.ts.map +1 -0
- package/dist/objects/isaacAPIClassTypeToFunctions.lua +25 -0
- package/dist/types/{private/IsaacAPIClass.d.ts → IsaacAPIClass.d.ts} +0 -0
- package/dist/types/IsaacAPIClass.d.ts.map +1 -0
- package/dist/types/{private/IsaacAPIClass.lua → IsaacAPIClass.lua} +0 -0
- package/dist/types/{private/SerializedIsaacAPIClass.d.ts → SerializedIsaacAPIClass.d.ts} +0 -0
- package/dist/types/SerializedIsaacAPIClass.d.ts.map +1 -0
- package/dist/types/{private/SerializedIsaacAPIClass.lua → SerializedIsaacAPIClass.lua} +0 -0
- package/dist/types/{private/TSTLClass.d.ts → TSTLClass.d.ts} +0 -0
- package/dist/types/TSTLClass.d.ts.map +1 -0
- package/dist/types/{private/TSTLClass.lua → TSTLClass.lua} +0 -0
- package/package.json +2 -2
- package/src/callbacks/postGridEntityCustomCollision.ts +74 -0
- package/src/callbacks/postGridEntityCustomRender.ts +1 -17
- package/src/callbacks/postGridEntityCustomUpdate.ts +1 -17
- package/src/callbacks/subscriptions/postGridEntityCustomBroken.ts +36 -0
- package/src/callbacks/subscriptions/postGridEntityCustomCollision.ts +43 -0
- package/src/enums/ModCallbackCustom.ts +38 -2
- package/src/features/customGridEntity.ts +76 -0
- package/src/functions/color.ts +67 -87
- package/src/functions/deepCopy.ts +15 -2
- package/src/functions/gridEntities.ts +0 -23
- package/src/functions/isaacAPIClass.ts +1 -1
- package/src/functions/kColor.ts +65 -84
- package/src/functions/mergeTests.ts +2 -2
- package/src/functions/npcs.ts +1 -58
- package/src/functions/projectiles.ts +78 -0
- package/src/functions/rng.ts +45 -65
- package/src/functions/rockAlt.ts +127 -40
- package/src/functions/saveFile.ts +2 -1
- package/src/functions/serialization.ts +81 -25
- package/src/functions/table.ts +2 -2
- package/src/functions/tstlClass.ts +1 -1
- package/src/functions/vector.ts +55 -74
- package/src/index.ts +1 -0
- package/src/initCustomCallbacks.ts +2 -0
- package/src/interfaces/AddCallbackParameterCustom.ts +4 -0
- package/src/objects/callbackRegisterFunctions.ts +6 -0
- package/src/objects/isaacAPIClassTypeToFunctions.ts +63 -0
- package/src/types/{private/IsaacAPIClass.ts → IsaacAPIClass.ts} +0 -0
- package/src/types/{private/SerializedIsaacAPIClass.ts → SerializedIsaacAPIClass.ts} +0 -0
- package/src/types/{private/TSTLClass.ts → TSTLClass.ts} +0 -0
- package/dist/objects/isaacAPIClassTypeToCopyFunction.d.ts +0 -6
- package/dist/objects/isaacAPIClassTypeToCopyFunction.d.ts.map +0 -1
- package/dist/objects/isaacAPIClassTypeToCopyFunction.lua +0 -13
- package/dist/objects/serializedIsaacAPIClassTypeToIdentityFunction.d.ts +0 -5
- package/dist/objects/serializedIsaacAPIClassTypeToIdentityFunction.d.ts.map +0 -1
- package/dist/objects/serializedIsaacAPIClassTypeToIdentityFunction.lua +0 -13
- package/dist/types/private/IsaacAPIClass.d.ts.map +0 -1
- package/dist/types/private/SerializedIsaacAPIClass.d.ts.map +0 -1
- package/dist/types/private/TSTLClass.d.ts.map +0 -1
- package/src/objects/isaacAPIClassTypeToCopyFunction.ts +0 -18
- package/src/objects/serializedIsaacAPIClassTypeToIdentityFunction.ts +0 -14
package/dist/functions/rng.lua
CHANGED
|
@@ -6,8 +6,6 @@ local ____cachedClasses = require("cachedClasses")
|
|
|
6
6
|
local game = ____cachedClasses.game
|
|
7
7
|
local ____SerializationBrand = require("enums.private.SerializationBrand")
|
|
8
8
|
local SerializationBrand = ____SerializationBrand.SerializationBrand
|
|
9
|
-
local ____SerializationType = require("enums.SerializationType")
|
|
10
|
-
local SerializationType = ____SerializationType.SerializationType
|
|
11
9
|
local ____isaacAPIClass = require("functions.isaacAPIClass")
|
|
12
10
|
local isaacAPIClassEquals = ____isaacAPIClass.isaacAPIClassEquals
|
|
13
11
|
local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
|
|
@@ -49,57 +47,27 @@ end
|
|
|
49
47
|
RECOMMENDED_SHIFT_IDX = 35
|
|
50
48
|
local KEYS = {"seed"}
|
|
51
49
|
OBJECT_NAME = "RNG"
|
|
52
|
-
--- Helper function to copy an `RNG`
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
-- @param serializationType Default is `SerializationType.NONE`.
|
|
57
|
-
function ____exports.copyRNG(self, rng, serializationType)
|
|
58
|
-
if serializationType == nil then
|
|
59
|
-
serializationType = SerializationType.NONE
|
|
50
|
+
--- Helper function to copy an `RNG` Isaac API class.
|
|
51
|
+
function ____exports.copyRNG(self, rng)
|
|
52
|
+
if not ____exports.isRNG(nil, rng) then
|
|
53
|
+
error(((("Failed to copy a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
|
|
60
54
|
end
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
|
|
78
|
-
end
|
|
79
|
-
local seed = rng:GetSeed()
|
|
80
|
-
local rngTable = {}
|
|
81
|
-
rngTable.seed = seed
|
|
82
|
-
rngTable[SerializationBrand.RNG] = ""
|
|
83
|
-
return rngTable
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
____cond3 = ____cond3 or ____switch3 == SerializationType.DESERIALIZE
|
|
87
|
-
if ____cond3 then
|
|
88
|
-
do
|
|
89
|
-
if not isTable(nil, rng) then
|
|
90
|
-
error(("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object was not a Lua table.")
|
|
91
|
-
end
|
|
92
|
-
local seedNumber = table.unpack(getNumbersFromTable(
|
|
93
|
-
nil,
|
|
94
|
-
rng,
|
|
95
|
-
OBJECT_NAME,
|
|
96
|
-
table.unpack(KEYS)
|
|
97
|
-
))
|
|
98
|
-
local seed = seedNumber
|
|
99
|
-
return ____exports.newRNG(nil, seed)
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
until true
|
|
55
|
+
local seed = rng:GetSeed()
|
|
56
|
+
return ____exports.newRNG(nil, seed)
|
|
57
|
+
end
|
|
58
|
+
--- Helper function to convert a `SerializedRNG` object to a normal `RNG` object. (This is used by
|
|
59
|
+
-- the save data manager when reading data from the "save#.dat" file.)
|
|
60
|
+
function ____exports.deserializeRNG(self, rng)
|
|
61
|
+
if not isTable(nil, rng) then
|
|
62
|
+
error(("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object was not a Lua table.")
|
|
63
|
+
end
|
|
64
|
+
local seed = table.unpack(getNumbersFromTable(
|
|
65
|
+
nil,
|
|
66
|
+
rng,
|
|
67
|
+
OBJECT_NAME,
|
|
68
|
+
table.unpack(KEYS)
|
|
69
|
+
))
|
|
70
|
+
return ____exports.newRNG(nil, seed)
|
|
103
71
|
end
|
|
104
72
|
--- Used to determine is the given table is a serialized `RNG` object created by the save data
|
|
105
73
|
-- manager and/or the `deepCopy` function.
|
|
@@ -116,6 +84,18 @@ end
|
|
|
116
84
|
function ____exports.rngEquals(self, rng1, rng2)
|
|
117
85
|
return isaacAPIClassEquals(nil, rng1, rng2, KEYS)
|
|
118
86
|
end
|
|
87
|
+
--- Helper function to convert a `RNG` object to a `SerializedRNG` object. (This is used by the save
|
|
88
|
+
-- data manager when writing data from the "save#.dat" file.)
|
|
89
|
+
function ____exports.serializeRNG(self, rng)
|
|
90
|
+
if not ____exports.isRNG(nil, rng) then
|
|
91
|
+
error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
|
|
92
|
+
end
|
|
93
|
+
local seed = rng:GetSeed()
|
|
94
|
+
local rngTable = {}
|
|
95
|
+
rngTable.seed = seed
|
|
96
|
+
rngTable[SerializationBrand.RNG] = ""
|
|
97
|
+
return rngTable
|
|
98
|
+
end
|
|
119
99
|
--- Helper function to iterate over the provided object and set the seed for all of the values that
|
|
120
100
|
-- are RNG objects equal to a particular seed.
|
|
121
101
|
function ____exports.setAllRNGToSeed(self, object, seed)
|
|
@@ -2,12 +2,32 @@
|
|
|
2
2
|
/// <reference types="isaac-typescript-definitions" />
|
|
3
3
|
/// <reference types="isaac-typescript-definitions" />
|
|
4
4
|
import { RockAltType } from "../enums/RockAltType";
|
|
5
|
+
/**
|
|
6
|
+
* Helper function to get the alternate rock type (i.e. urn, mushroom, etc.) that the current room
|
|
7
|
+
* will have.
|
|
8
|
+
*
|
|
9
|
+
* The rock type is based on the backdrop of the room.
|
|
10
|
+
*
|
|
11
|
+
* For example, if you change the backdrop of the starting room of the run to `BackdropType.CAVES`,
|
|
12
|
+
* and then spawn `GridEntityType.ROCK_ALT`, it will be a mushroom instead of an urn. Additionally,
|
|
13
|
+
* if it is destroyed, it will generate mushroom-appropriate rewards.
|
|
14
|
+
*
|
|
15
|
+
* On the other hand, if an urn is spawned first before the backdrop is changed to
|
|
16
|
+
* `BackdropType.CAVES`, the graphic of the urn will not switch to a mushroom. However, when
|
|
17
|
+
* destroyed, the urn will still generate mushroom-appropriate rewards.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getRockAltType(): RockAltType;
|
|
5
20
|
/**
|
|
6
21
|
* Helper function for emulating what happens when a vanilla `GridEntityType.ROCK_ALT` grid entity
|
|
7
22
|
* breaks.
|
|
8
23
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
24
|
+
* Most of the time, this function will do nothing, similar to how most of the time, when an
|
|
25
|
+
* individual urn is destroyed, nothing will spawn.
|
|
26
|
+
*
|
|
27
|
+
* Note that in vanilla, trinkets will not spawn if they have already been removed from the trinket
|
|
28
|
+
* pool. This function cannot replicate that behavior because there is no way to check to see if a
|
|
29
|
+
* trinket is still in the pool. Thus, it will always have a chance to spawn the respective trinket
|
|
30
|
+
* (e.g. Swallowed Penny from urns).
|
|
11
31
|
*
|
|
12
32
|
* The logic in this function is based on the rewards listed on the wiki:
|
|
13
33
|
* https://bindingofisaacrebirth.fandom.com/wiki/Rocks
|
|
@@ -15,10 +35,14 @@ import { RockAltType } from "../enums/RockAltType";
|
|
|
15
35
|
* @param position The place to spawn the reward.
|
|
16
36
|
* @param rockAltType The type of reward to spawn. For example, `RockAltType.URN` will have a chance
|
|
17
37
|
* at spawning coins and spiders.
|
|
38
|
+
* @param variant Optional. The variant of the grid entity to emulate. Default is 0, which
|
|
39
|
+
* corresponds to a "normal" grid entity or an empty bucket. This only matters when
|
|
40
|
+
* spawning the reward for buckets. (Empty buckets have different rewards than full
|
|
41
|
+
* buckets.)
|
|
18
42
|
* @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
19
43
|
* `RNG.Next` method will be called. Default is `getRandomSeed()`. Normally, you
|
|
20
44
|
* should pass the `InitSeed` of the grid entity that was broken.
|
|
21
45
|
* @returns Whether or not this function spawned something.
|
|
22
46
|
*/
|
|
23
|
-
export declare function spawnRockAltReward(position: Vector, rockAltType: RockAltType, seedOrRNG?: Seed | RNG): boolean;
|
|
47
|
+
export declare function spawnRockAltReward(position: Vector, rockAltType: RockAltType, variant?: number, seedOrRNG?: Seed | RNG): boolean;
|
|
24
48
|
//# sourceMappingURL=rockAlt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rockAlt.d.ts","sourceRoot":"","sources":["../../src/functions/rockAlt.ts"],"names":[],"mappings":";;;AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"rockAlt.d.ts","sourceRoot":"","sources":["../../src/functions/rockAlt.ts"],"names":[],"mappings":";;;AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AA+BnD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAK5C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,WAAW,EACxB,OAAO,SAAI,EACX,SAAS,GAAE,IAAI,GAAG,GAAqB,GACtC,OAAO,CAwBT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
|
-
local spawnRockAltRewardUrn, spawnRockAltRewardMushroom, spawnRockAltRewardSkull, spawnRockAltRewardPolyp, spawnRockAltRewardBucket
|
|
2
|
+
local spawnRockAltRewardUrn, spawnRockAltRewardMushroom, spawnRockAltRewardSkull, spawnRockAltRewardPolyp, spawnRockAltRewardBucket, ROCK_ALT_CHANCES, POLYP_PROJECTILE_SPEED, POLYP_NUM_PROJECTILES
|
|
3
3
|
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
4
4
|
local Card = ____isaac_2Dtypescript_2Ddefinitions.Card
|
|
5
5
|
local CoinSubType = ____isaac_2Dtypescript_2Ddefinitions.CoinSubType
|
|
@@ -17,6 +17,8 @@ local ____constants = require("constants")
|
|
|
17
17
|
local DISTANCE_OF_GRID_TILE = ____constants.DISTANCE_OF_GRID_TILE
|
|
18
18
|
local ____RockAltType = require("enums.RockAltType")
|
|
19
19
|
local RockAltType = ____RockAltType.RockAltType
|
|
20
|
+
local ____backdropTypeToRockAltType = require("objects.backdropTypeToRockAltType")
|
|
21
|
+
local BACKDROP_TYPE_TO_ROCK_ALT_TYPE = ____backdropTypeToRockAltType.BACKDROP_TYPE_TO_ROCK_ALT_TYPE
|
|
20
22
|
local ____entitiesSpecific = require("functions.entitiesSpecific")
|
|
21
23
|
local spawnEffectWithSeed = ____entitiesSpecific.spawnEffectWithSeed
|
|
22
24
|
local spawnNPCWithSeed = ____entitiesSpecific.spawnNPCWithSeed
|
|
@@ -28,6 +30,8 @@ local spawnCoinWithSeed = ____pickupsSpecific.spawnCoinWithSeed
|
|
|
28
30
|
local spawnHeartWithSeed = ____pickupsSpecific.spawnHeartWithSeed
|
|
29
31
|
local spawnPillWithSeed = ____pickupsSpecific.spawnPillWithSeed
|
|
30
32
|
local spawnTrinketWithSeed = ____pickupsSpecific.spawnTrinketWithSeed
|
|
33
|
+
local ____projectiles = require("functions.projectiles")
|
|
34
|
+
local fireProjectilesInCircle = ____projectiles.fireProjectilesInCircle
|
|
31
35
|
local ____random = require("functions.random")
|
|
32
36
|
local getRandom = ____random.getRandom
|
|
33
37
|
local ____rng = require("functions.rng")
|
|
@@ -43,11 +47,11 @@ local getRandomVector = ____vector.getRandomVector
|
|
|
43
47
|
function spawnRockAltRewardUrn(self, position, rng)
|
|
44
48
|
local chance = getRandom(nil, rng)
|
|
45
49
|
local totalChance = 0
|
|
46
|
-
totalChance = totalChance +
|
|
50
|
+
totalChance = totalChance + ROCK_ALT_CHANCES.Nothing
|
|
47
51
|
if chance < totalChance then
|
|
48
52
|
return false
|
|
49
53
|
end
|
|
50
|
-
totalChance = totalChance +
|
|
54
|
+
totalChance = totalChance + ROCK_ALT_CHANCES.BasicDrop
|
|
51
55
|
if chance < totalChance then
|
|
52
56
|
local numCoinsChance = getRandom(nil, rng)
|
|
53
57
|
local numCoins = numCoinsChance < 0.5 and 1 or 2
|
|
@@ -69,12 +73,12 @@ function spawnRockAltRewardUrn(self, position, rng)
|
|
|
69
73
|
)
|
|
70
74
|
return true
|
|
71
75
|
end
|
|
72
|
-
totalChance = totalChance +
|
|
76
|
+
totalChance = totalChance + ROCK_ALT_CHANCES.Trinket
|
|
73
77
|
if chance < totalChance then
|
|
74
78
|
spawnTrinketWithSeed(nil, TrinketType.SWALLOWED_PENNY, position, rng)
|
|
75
79
|
return true
|
|
76
80
|
end
|
|
77
|
-
totalChance = totalChance +
|
|
81
|
+
totalChance = totalChance + ROCK_ALT_CHANCES.Collectible
|
|
78
82
|
if chance < totalChance then
|
|
79
83
|
local stillInPools = isCollectibleInItemPool(nil, CollectibleType.QUARTER, ItemPoolType.DEVIL)
|
|
80
84
|
if stillInPools then
|
|
@@ -109,21 +113,21 @@ function spawnRockAltRewardMushroom(self, position, rng)
|
|
|
109
113
|
local roomType = room:GetType()
|
|
110
114
|
local chance = getRandom(nil, rng)
|
|
111
115
|
local totalChance = 0
|
|
112
|
-
totalChance = totalChance +
|
|
116
|
+
totalChance = totalChance + ROCK_ALT_CHANCES.Nothing
|
|
113
117
|
if chance < totalChance then
|
|
114
118
|
return false
|
|
115
119
|
end
|
|
116
|
-
totalChance = totalChance +
|
|
120
|
+
totalChance = totalChance + ROCK_ALT_CHANCES.BasicDrop
|
|
117
121
|
if chance < totalChance then
|
|
118
122
|
spawnPillWithSeed(nil, PillColor.NULL, position, rng)
|
|
119
123
|
return true
|
|
120
124
|
end
|
|
121
|
-
totalChance = totalChance +
|
|
125
|
+
totalChance = totalChance + ROCK_ALT_CHANCES.Trinket
|
|
122
126
|
if chance < totalChance then
|
|
123
127
|
spawnTrinketWithSeed(nil, TrinketType.LIBERTY_CAP, position, rng)
|
|
124
128
|
return true
|
|
125
129
|
end
|
|
126
|
-
totalChance = totalChance +
|
|
130
|
+
totalChance = totalChance + ROCK_ALT_CHANCES.Collectible
|
|
127
131
|
if chance < totalChance then
|
|
128
132
|
if roomType == RoomType.SECRET then
|
|
129
133
|
local wavyCapChance = getRandom(nil, rng)
|
|
@@ -165,21 +169,21 @@ end
|
|
|
165
169
|
function spawnRockAltRewardSkull(self, position, rng)
|
|
166
170
|
local chance = getRandom(nil, rng)
|
|
167
171
|
local totalChance = 0
|
|
168
|
-
totalChance = totalChance +
|
|
172
|
+
totalChance = totalChance + ROCK_ALT_CHANCES.Nothing
|
|
169
173
|
if chance < totalChance then
|
|
170
174
|
return false
|
|
171
175
|
end
|
|
172
|
-
totalChance = totalChance +
|
|
176
|
+
totalChance = totalChance + ROCK_ALT_CHANCES.BasicDrop
|
|
173
177
|
if chance < totalChance then
|
|
174
178
|
spawnCardWithSeed(nil, Card.NULL, position, rng)
|
|
175
179
|
return true
|
|
176
180
|
end
|
|
177
|
-
totalChance = totalChance +
|
|
181
|
+
totalChance = totalChance + ROCK_ALT_CHANCES.Trinket
|
|
178
182
|
if chance < totalChance then
|
|
179
183
|
spawnHeartWithSeed(nil, HeartSubType.BLACK, position, rng)
|
|
180
184
|
return true
|
|
181
185
|
end
|
|
182
|
-
totalChance = totalChance +
|
|
186
|
+
totalChance = totalChance + ROCK_ALT_CHANCES.Collectible
|
|
183
187
|
if chance < totalChance then
|
|
184
188
|
local ghostBabyStillInPools = isCollectibleInItemPool(nil, CollectibleType.GHOST_BABY, ItemPoolType.TREASURE)
|
|
185
189
|
local dryBabyStillInPools = isCollectibleInItemPool(nil, CollectibleType.DRY_BABY, ItemPoolType.TREASURE)
|
|
@@ -209,29 +213,98 @@ function spawnRockAltRewardSkull(self, position, rng)
|
|
|
209
213
|
)
|
|
210
214
|
return true
|
|
211
215
|
end
|
|
212
|
-
function spawnRockAltRewardPolyp(self,
|
|
216
|
+
function spawnRockAltRewardPolyp(self, position, rng)
|
|
213
217
|
local chance = getRandom(nil, rng)
|
|
214
218
|
local totalChance = 0
|
|
215
|
-
totalChance = totalChance +
|
|
219
|
+
totalChance = totalChance + ROCK_ALT_CHANCES.Nothing
|
|
216
220
|
if chance < totalChance then
|
|
217
221
|
return false
|
|
218
222
|
end
|
|
219
|
-
|
|
223
|
+
totalChance = totalChance + ROCK_ALT_CHANCES.BasicDrop
|
|
224
|
+
if chance < totalChance then
|
|
225
|
+
spawnHeartWithSeed(nil, HeartSubType.NULL, position, rng)
|
|
226
|
+
return true
|
|
227
|
+
end
|
|
228
|
+
totalChance = totalChance + ROCK_ALT_CHANCES.Trinket
|
|
229
|
+
if chance < totalChance then
|
|
230
|
+
spawnTrinketWithSeed(nil, TrinketType.UMBILICAL_CORD, position, rng)
|
|
231
|
+
return true
|
|
232
|
+
end
|
|
233
|
+
totalChance = totalChance + ROCK_ALT_CHANCES.Collectible
|
|
234
|
+
if chance < totalChance then
|
|
235
|
+
local placentaStillInPools = isCollectibleInItemPool(nil, CollectibleType.PLACENTA, ItemPoolType.BOSS)
|
|
236
|
+
local bloodClotStillInPools = isCollectibleInItemPool(nil, CollectibleType.BLOOD_CLOT, ItemPoolType.BOSS)
|
|
237
|
+
if bloodClotStillInPools and placentaStillInPools then
|
|
238
|
+
local collectibleChance = getRandom(nil, rng)
|
|
239
|
+
local collectibleType = collectibleChance < 0.5 and CollectibleType.PLACENTA or CollectibleType.BLOOD_CLOT
|
|
240
|
+
spawnCollectible(nil, collectibleType, position, rng)
|
|
241
|
+
return true
|
|
242
|
+
end
|
|
243
|
+
if bloodClotStillInPools then
|
|
244
|
+
spawnCollectible(nil, CollectibleType.MINI_MUSH, position, rng)
|
|
245
|
+
return true
|
|
246
|
+
end
|
|
247
|
+
if placentaStillInPools then
|
|
248
|
+
spawnCollectible(nil, CollectibleType.MAGIC_MUSHROOM, position, rng)
|
|
249
|
+
return true
|
|
250
|
+
end
|
|
251
|
+
return false
|
|
252
|
+
end
|
|
253
|
+
spawnEffectWithSeed(
|
|
254
|
+
nil,
|
|
255
|
+
EffectVariant.CREEP_RED,
|
|
256
|
+
0,
|
|
257
|
+
position,
|
|
258
|
+
rng
|
|
259
|
+
)
|
|
260
|
+
fireProjectilesInCircle(
|
|
261
|
+
nil,
|
|
262
|
+
nil,
|
|
263
|
+
position,
|
|
264
|
+
POLYP_PROJECTILE_SPEED,
|
|
265
|
+
POLYP_NUM_PROJECTILES
|
|
266
|
+
)
|
|
267
|
+
return true
|
|
220
268
|
end
|
|
221
|
-
function spawnRockAltRewardBucket(self, _position, rng)
|
|
269
|
+
function spawnRockAltRewardBucket(self, _position, rng, _variant)
|
|
222
270
|
local chance = getRandom(nil, rng)
|
|
223
271
|
local totalChance = 0
|
|
224
|
-
totalChance = totalChance +
|
|
272
|
+
totalChance = totalChance + ROCK_ALT_CHANCES.Nothing
|
|
225
273
|
if chance < totalChance then
|
|
226
274
|
return false
|
|
227
275
|
end
|
|
228
276
|
return false
|
|
229
277
|
end
|
|
278
|
+
ROCK_ALT_CHANCES = {Nothing = 0.68, BasicDrop = 0.0967, Trinket = 0.025, Collectible = 0.005}
|
|
279
|
+
POLYP_PROJECTILE_SPEED = 10
|
|
280
|
+
POLYP_NUM_PROJECTILES = 6
|
|
281
|
+
--- Helper function to get the alternate rock type (i.e. urn, mushroom, etc.) that the current room
|
|
282
|
+
-- will have.
|
|
283
|
+
--
|
|
284
|
+
-- The rock type is based on the backdrop of the room.
|
|
285
|
+
--
|
|
286
|
+
-- For example, if you change the backdrop of the starting room of the run to `BackdropType.CAVES`,
|
|
287
|
+
-- and then spawn `GridEntityType.ROCK_ALT`, it will be a mushroom instead of an urn. Additionally,
|
|
288
|
+
-- if it is destroyed, it will generate mushroom-appropriate rewards.
|
|
289
|
+
--
|
|
290
|
+
-- On the other hand, if an urn is spawned first before the backdrop is changed to
|
|
291
|
+
-- `BackdropType.CAVES`, the graphic of the urn will not switch to a mushroom. However, when
|
|
292
|
+
-- destroyed, the urn will still generate mushroom-appropriate rewards.
|
|
293
|
+
function ____exports.getRockAltType(self)
|
|
294
|
+
local room = game:GetRoom()
|
|
295
|
+
local backdropType = room:GetBackdropType()
|
|
296
|
+
return BACKDROP_TYPE_TO_ROCK_ALT_TYPE[backdropType]
|
|
297
|
+
end
|
|
230
298
|
--- Helper function for emulating what happens when a vanilla `GridEntityType.ROCK_ALT` grid entity
|
|
231
299
|
-- breaks.
|
|
232
300
|
--
|
|
233
|
-
--
|
|
234
|
-
--
|
|
301
|
+
-- Most of the time, this function will do nothing, similar to how most of the time, when an
|
|
302
|
+
-- individual urn is destroyed, nothing will spawn.
|
|
303
|
+
--
|
|
304
|
+
-- Note that in vanilla, trinkets will not spawn if they have already been removed from the trinket
|
|
305
|
+
-- pool. This function cannot replicate that behavior because there is no way to check to see if a
|
|
306
|
+
-- trinket is still in the pool. Thus, it will always have a chance to spawn the respective trinket
|
|
307
|
+
-- (e.g. Swallowed Penny from urns).
|
|
235
308
|
--
|
|
236
309
|
-- The logic in this function is based on the rewards listed on the wiki:
|
|
237
310
|
-- https://bindingofisaacrebirth.fandom.com/wiki/Rocks
|
|
@@ -239,45 +312,52 @@ end
|
|
|
239
312
|
-- @param position The place to spawn the reward.
|
|
240
313
|
-- @param rockAltType The type of reward to spawn. For example, `RockAltType.URN` will have a chance
|
|
241
314
|
-- at spawning coins and spiders.
|
|
315
|
+
-- @param variant Optional. The variant of the grid entity to emulate. Default is 0, which
|
|
316
|
+
-- corresponds to a "normal" grid entity or an empty bucket. This only matters when
|
|
317
|
+
-- spawning the reward for buckets. (Empty buckets have different rewards than full
|
|
318
|
+
-- buckets.)
|
|
242
319
|
-- @param seedOrRNG Optional. The `Seed` or `RNG` object to use. If an `RNG` object is provided, the
|
|
243
320
|
-- `RNG.Next` method will be called. Default is `getRandomSeed()`. Normally, you
|
|
244
321
|
-- should pass the `InitSeed` of the grid entity that was broken.
|
|
245
322
|
-- @returns Whether or not this function spawned something.
|
|
246
|
-
function ____exports.spawnRockAltReward(self, position, rockAltType, seedOrRNG)
|
|
323
|
+
function ____exports.spawnRockAltReward(self, position, rockAltType, variant, seedOrRNG)
|
|
324
|
+
if variant == nil then
|
|
325
|
+
variant = 0
|
|
326
|
+
end
|
|
247
327
|
if seedOrRNG == nil then
|
|
248
328
|
seedOrRNG = getRandomSeed(nil)
|
|
249
329
|
end
|
|
250
330
|
local rng = isRNG(nil, seedOrRNG) and seedOrRNG or newRNG(nil, seedOrRNG)
|
|
251
331
|
repeat
|
|
252
|
-
local
|
|
253
|
-
local
|
|
254
|
-
if
|
|
332
|
+
local ____switch4 = rockAltType
|
|
333
|
+
local ____cond4 = ____switch4 == RockAltType.URN
|
|
334
|
+
if ____cond4 then
|
|
255
335
|
do
|
|
256
336
|
return spawnRockAltRewardUrn(nil, position, rng)
|
|
257
337
|
end
|
|
258
338
|
end
|
|
259
|
-
|
|
260
|
-
if
|
|
339
|
+
____cond4 = ____cond4 or ____switch4 == RockAltType.MUSHROOM
|
|
340
|
+
if ____cond4 then
|
|
261
341
|
do
|
|
262
342
|
return spawnRockAltRewardMushroom(nil, position, rng)
|
|
263
343
|
end
|
|
264
344
|
end
|
|
265
|
-
|
|
266
|
-
if
|
|
345
|
+
____cond4 = ____cond4 or ____switch4 == RockAltType.SKULL
|
|
346
|
+
if ____cond4 then
|
|
267
347
|
do
|
|
268
348
|
return spawnRockAltRewardSkull(nil, position, rng)
|
|
269
349
|
end
|
|
270
350
|
end
|
|
271
|
-
|
|
272
|
-
if
|
|
351
|
+
____cond4 = ____cond4 or ____switch4 == RockAltType.POLYP
|
|
352
|
+
if ____cond4 then
|
|
273
353
|
do
|
|
274
354
|
return spawnRockAltRewardPolyp(nil, position, rng)
|
|
275
355
|
end
|
|
276
356
|
end
|
|
277
|
-
|
|
278
|
-
if
|
|
357
|
+
____cond4 = ____cond4 or ____switch4 == RockAltType.BUCKET
|
|
358
|
+
if ____cond4 then
|
|
279
359
|
do
|
|
280
|
-
return spawnRockAltRewardBucket(nil, position, rng)
|
|
360
|
+
return spawnRockAltRewardBucket(nil, position, rng, variant)
|
|
281
361
|
end
|
|
282
362
|
end
|
|
283
363
|
until true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saveFile.d.ts","sourceRoot":"","sources":["../../src/functions/saveFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"saveFile.d.ts","sourceRoot":"","sources":["../../src/functions/saveFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAI7E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,GACzB,OAAO,CAMT"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
local ____exports = {}
|
|
2
|
+
local ____itemPool = require("functions.itemPool")
|
|
3
|
+
local isCollectibleInItemPool = ____itemPool.isCollectibleInItemPool
|
|
2
4
|
local ____players = require("functions.players")
|
|
3
5
|
local anyPlayerHasCollectible = ____players.anyPlayerHasCollectible
|
|
4
6
|
--- Helper function to see if the given collectible is unlocked on the current save file. This
|
|
@@ -17,6 +19,6 @@ function ____exports.isCollectibleUnlocked(self, collectibleType, itemPoolType)
|
|
|
17
19
|
if anyPlayerHasCollectible(nil, collectibleType) then
|
|
18
20
|
return true
|
|
19
21
|
end
|
|
20
|
-
return
|
|
22
|
+
return isCollectibleInItemPool(nil, collectibleType, itemPoolType)
|
|
21
23
|
end
|
|
22
24
|
return ____exports
|
|
@@ -1,12 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SerializedIsaacAPIClass } from "../types/private/SerializedIsaacAPIClass";
|
|
3
|
-
export declare function copyIsaacAPIClass(isaacAPIClass: unknown, serializationType: SerializationType): unknown;
|
|
1
|
+
import { SerializedIsaacAPIClass } from "../types/SerializedIsaacAPIClass";
|
|
4
2
|
/**
|
|
5
|
-
*
|
|
3
|
+
* Helper function to generically copy an Isaac API class without knowing what specific type of
|
|
4
|
+
* class it is. (This is used by the save data manager.)
|
|
6
5
|
*
|
|
7
|
-
*
|
|
8
|
-
|
|
6
|
+
* For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
|
|
7
|
+
*/
|
|
8
|
+
export declare function copyIsaacAPIClass(isaacAPIClass: unknown): unknown;
|
|
9
|
+
/**
|
|
10
|
+
* Helper function to generically deserialize an Isaac API class without knowing what specific type
|
|
11
|
+
* of class it is. (This is used by the save data manager when reading data from the "save#.dat"
|
|
12
|
+
* file.)
|
|
13
|
+
*
|
|
14
|
+
* For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
|
|
15
|
+
*/
|
|
16
|
+
export declare function deserializeIsaacAPIClass(serializedIsaacAPIClass: unknown): unknown;
|
|
17
|
+
/**
|
|
18
|
+
* Helper function to generically check if a given Lua table is a serialized Isaac API class. (This
|
|
19
|
+
* is used by the save data manager when reading data from the "save#.dat" file.)
|
|
20
|
+
*
|
|
21
|
+
* For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
|
|
9
22
|
*/
|
|
10
|
-
export declare function deserializeIsaacAPIClass(serializedIsaacAPIClass: SerializedIsaacAPIClass): unknown;
|
|
11
23
|
export declare function isSerializedIsaacAPIClass(object: unknown): object is SerializedIsaacAPIClass;
|
|
24
|
+
/**
|
|
25
|
+
* Helper function to generically serialize an Isaac API class without knowing what specific type of
|
|
26
|
+
* class it is. (This is used by the save data manager when writing data to the "save#.dat" file.)
|
|
27
|
+
*
|
|
28
|
+
* For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
|
|
29
|
+
*/
|
|
30
|
+
export declare function serializeIsaacAPIClass(isaacAPIClass: unknown): unknown;
|
|
12
31
|
//# sourceMappingURL=serialization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../src/functions/serialization.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../src/functions/serialization.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAI3E;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,OAAO,GAAG,OAAO,CA0BjE;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,uBAAuB,EAAE,OAAO,GAC/B,OAAO,CA0BT;AAoBD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,uBAAuB,CAQnC;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,OAAO,GAAG,OAAO,CA0BtE"}
|
|
@@ -2,17 +2,14 @@ local ____lualib = require("lualib_bundle")
|
|
|
2
2
|
local __TS__TypeOf = ____lualib.__TS__TypeOf
|
|
3
3
|
local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
|
|
4
4
|
local __TS__ObjectValues = ____lualib.__TS__ObjectValues
|
|
5
|
+
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
5
6
|
local __TS__ArraySome = ____lualib.__TS__ArraySome
|
|
6
7
|
local ____exports = {}
|
|
7
8
|
local getSerializedTableType
|
|
8
|
-
local ____SerializationType = require("enums.SerializationType")
|
|
9
|
-
local SerializationType = ____SerializationType.SerializationType
|
|
10
9
|
local ____isaacAPIClassTypeToBrand = require("objects.isaacAPIClassTypeToBrand")
|
|
11
10
|
local ISAAC_API_CLASS_TYPE_TO_BRAND = ____isaacAPIClassTypeToBrand.ISAAC_API_CLASS_TYPE_TO_BRAND
|
|
12
|
-
local
|
|
13
|
-
local
|
|
14
|
-
local ____serializedIsaacAPIClassTypeToIdentityFunction = require("objects.serializedIsaacAPIClassTypeToIdentityFunction")
|
|
15
|
-
local SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION = ____serializedIsaacAPIClassTypeToIdentityFunction.SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION
|
|
11
|
+
local ____isaacAPIClassTypeToFunctions = require("objects.isaacAPIClassTypeToFunctions")
|
|
12
|
+
local ISAAC_API_CLASS_TYPE_TO_FUNCTIONS = ____isaacAPIClassTypeToFunctions.ISAAC_API_CLASS_TYPE_TO_FUNCTIONS
|
|
16
13
|
local ____isaacAPIClass = require("functions.isaacAPIClass")
|
|
17
14
|
local getIsaacAPIClassName = ____isaacAPIClass.getIsaacAPIClassName
|
|
18
15
|
local ____types = require("functions.types")
|
|
@@ -28,7 +25,11 @@ function getSerializedTableType(self, serializedIsaacAPIClass)
|
|
|
28
25
|
end
|
|
29
26
|
return nil
|
|
30
27
|
end
|
|
31
|
-
function
|
|
28
|
+
--- Helper function to generically copy an Isaac API class without knowing what specific type of
|
|
29
|
+
-- class it is. (This is used by the save data manager.)
|
|
30
|
+
--
|
|
31
|
+
-- For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
|
|
32
|
+
function ____exports.copyIsaacAPIClass(self, isaacAPIClass)
|
|
32
33
|
if not isUserdata(nil, isaacAPIClass) then
|
|
33
34
|
error("Failed to copy an Isaac API class since the provided object was of type: " .. __TS__TypeOf(isaacAPIClass))
|
|
34
35
|
end
|
|
@@ -37,32 +38,63 @@ function ____exports.copyIsaacAPIClass(self, isaacAPIClass, serializationType)
|
|
|
37
38
|
error("Failed to copy an Isaac API class since it does not have a class type.")
|
|
38
39
|
end
|
|
39
40
|
local copyableIsaacAPIClassType = isaacAPIClassType
|
|
40
|
-
local
|
|
41
|
-
if
|
|
42
|
-
error(
|
|
41
|
+
local functions = ISAAC_API_CLASS_TYPE_TO_FUNCTIONS[copyableIsaacAPIClassType]
|
|
42
|
+
if functions == nil then
|
|
43
|
+
error("Failed to copy an Isaac API class since the associated functions were not found for Isaac API class type: " .. copyableIsaacAPIClassType)
|
|
43
44
|
end
|
|
44
|
-
return
|
|
45
|
+
return functions:copy(isaacAPIClass)
|
|
45
46
|
end
|
|
46
|
-
---
|
|
47
|
+
--- Helper function to generically deserialize an Isaac API class without knowing what specific type
|
|
48
|
+
-- of class it is. (This is used by the save data manager when reading data from the "save#.dat"
|
|
49
|
+
-- file.)
|
|
47
50
|
--
|
|
48
|
-
--
|
|
49
|
-
-- "copyIsaacAPIClass" function can handle all serialization types.
|
|
51
|
+
-- For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
|
|
50
52
|
function ____exports.deserializeIsaacAPIClass(self, serializedIsaacAPIClass)
|
|
51
53
|
if not isTable(nil, serializedIsaacAPIClass) then
|
|
52
54
|
error("Failed to deserialize an Isaac API class since the provided object was of type: " .. __TS__TypeOf(serializedIsaacAPIClass))
|
|
53
55
|
end
|
|
54
56
|
local copyableIsaacAPIClassType = getSerializedTableType(nil, serializedIsaacAPIClass)
|
|
55
57
|
if copyableIsaacAPIClassType == nil then
|
|
56
|
-
error("Failed to deserialize an API class since a valid class type brand was not found.")
|
|
58
|
+
error("Failed to deserialize an Isaac API class since a valid class type brand was not found.")
|
|
59
|
+
end
|
|
60
|
+
local functions = ISAAC_API_CLASS_TYPE_TO_FUNCTIONS[copyableIsaacAPIClassType]
|
|
61
|
+
if functions == nil then
|
|
62
|
+
error("Failed to deserialize an Isaac API class since the associated functions were not found for class type: " .. copyableIsaacAPIClassType)
|
|
57
63
|
end
|
|
58
|
-
|
|
59
|
-
return copyFunction(nil, serializedIsaacAPIClass, SerializationType.DESERIALIZE)
|
|
64
|
+
return functions:deserialize(serializedIsaacAPIClass)
|
|
60
65
|
end
|
|
66
|
+
--- Helper function to generically check if a given Lua table is a serialized Isaac API class. (This
|
|
67
|
+
-- is used by the save data manager when reading data from the "save#.dat" file.)
|
|
68
|
+
--
|
|
69
|
+
-- For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
|
|
61
70
|
function ____exports.isSerializedIsaacAPIClass(self, object)
|
|
62
|
-
local
|
|
71
|
+
local allFunctions = __TS__ObjectValues(ISAAC_API_CLASS_TYPE_TO_FUNCTIONS)
|
|
72
|
+
local isSerializedFunctions = __TS__ArrayMap(
|
|
73
|
+
allFunctions,
|
|
74
|
+
function(____, functions) return functions.isSerialized end
|
|
75
|
+
)
|
|
63
76
|
return __TS__ArraySome(
|
|
64
|
-
|
|
77
|
+
isSerializedFunctions,
|
|
65
78
|
function(____, identityFunction) return identityFunction(nil, object) end
|
|
66
79
|
)
|
|
67
80
|
end
|
|
81
|
+
--- Helper function to generically serialize an Isaac API class without knowing what specific type of
|
|
82
|
+
-- class it is. (This is used by the save data manager when writing data to the "save#.dat" file.)
|
|
83
|
+
--
|
|
84
|
+
-- For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
|
|
85
|
+
function ____exports.serializeIsaacAPIClass(self, isaacAPIClass)
|
|
86
|
+
if not isUserdata(nil, isaacAPIClass) then
|
|
87
|
+
error("Failed to serialize an Isaac API class since the provided object was of type: " .. __TS__TypeOf(isaacAPIClass))
|
|
88
|
+
end
|
|
89
|
+
local isaacAPIClassType = getIsaacAPIClassName(nil, isaacAPIClass)
|
|
90
|
+
if isaacAPIClassType == nil then
|
|
91
|
+
error("Failed to serialize an Isaac API class since it does not have a class type.")
|
|
92
|
+
end
|
|
93
|
+
local copyableIsaacAPIClassType = isaacAPIClassType
|
|
94
|
+
local functions = ISAAC_API_CLASS_TYPE_TO_FUNCTIONS[copyableIsaacAPIClassType]
|
|
95
|
+
if functions == nil then
|
|
96
|
+
error("Failed to serialize an Isaac API class since the associated functions were not found for class type: " .. copyableIsaacAPIClassType)
|
|
97
|
+
end
|
|
98
|
+
return functions:serialize(isaacAPIClass)
|
|
99
|
+
end
|
|
68
100
|
return ____exports
|
|
@@ -14,8 +14,8 @@ export declare function copyValuesToTable(object: unknown, keys: string[], luaMa
|
|
|
14
14
|
*/
|
|
15
15
|
export declare function getBooleansFromTable(luaMap: LuaMap<string, unknown>, objectName: string, ...keys: string[]): boolean[];
|
|
16
16
|
/**
|
|
17
|
-
* Helper function to safely get number values from a Lua table. Will throw an
|
|
18
|
-
* value does not exist on the table or if it cannot be converted to a number.
|
|
17
|
+
* Helper function to safely get number values from specific keys on a Lua table. Will throw an
|
|
18
|
+
* error if the specific value does not exist on the table or if it cannot be converted to a number.
|
|
19
19
|
*
|
|
20
20
|
* This function is variadic, meaning that you can specify N arguments to get N values.
|
|
21
21
|
*/
|
package/dist/functions/table.lua
CHANGED
|
@@ -43,8 +43,8 @@ function ____exports.getBooleansFromTable(self, luaMap, objectName, ...)
|
|
|
43
43
|
end
|
|
44
44
|
return booleans
|
|
45
45
|
end
|
|
46
|
-
--- Helper function to safely get number values from a Lua table. Will throw an
|
|
47
|
-
-- value does not exist on the table or if it cannot be converted to a number.
|
|
46
|
+
--- Helper function to safely get number values from specific keys on a Lua table. Will throw an
|
|
47
|
+
-- error if the specific value does not exist on the table or if it cannot be converted to a number.
|
|
48
48
|
--
|
|
49
49
|
-- This function is variadic, meaning that you can specify N arguments to get N values.
|
|
50
50
|
function ____exports.getNumbersFromTable(self, luaMap, objectName, ...)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="typescript-to-lua/language-extensions" />
|
|
2
2
|
import { DefaultMap } from "../classes/DefaultMap";
|
|
3
|
-
import { TSTLClass } from "../types/
|
|
3
|
+
import { TSTLClass } from "../types/TSTLClass";
|
|
4
4
|
/**
|
|
5
5
|
* Helper function to get the name of a TypeScriptToLua class. TSTL classes are Lua tables created
|
|
6
6
|
* with the `__TS__Class` Lua function from the TSTL lualib. Their name is contained within
|