isaacscript-common 1.2.251 → 1.2.254
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.
|
@@ -36,7 +36,9 @@ function ____exports.merge(self, oldObject, newTable, traversalDescription)
|
|
|
36
36
|
if newTableType ~= "table" then
|
|
37
37
|
error("The second argument given to the merge function is not a table.")
|
|
38
38
|
end
|
|
39
|
-
if
|
|
39
|
+
if isArray(nil, oldObject) and isArray(nil, newTable) then
|
|
40
|
+
local oldTable = oldObject
|
|
41
|
+
mergeArray(nil, oldTable, newTable)
|
|
40
42
|
return
|
|
41
43
|
end
|
|
42
44
|
if __TS__InstanceOf(oldObject, Map) or __TS__InstanceOf(oldObject, Set) then
|
|
@@ -45,16 +47,11 @@ function ____exports.merge(self, oldObject, newTable, traversalDescription)
|
|
|
45
47
|
mergeTable(nil, oldObject, newTable, traversalDescription)
|
|
46
48
|
end
|
|
47
49
|
end
|
|
48
|
-
function mergeArray(self,
|
|
49
|
-
local oldArray = oldObject
|
|
50
|
-
if not isArray(nil, oldArray) or not isArray(nil, newTable) then
|
|
51
|
-
return false
|
|
52
|
-
end
|
|
50
|
+
function mergeArray(self, oldArray, newArray)
|
|
53
51
|
clearTable(nil, oldArray)
|
|
54
|
-
for key, value in pairs(
|
|
52
|
+
for key, value in pairs(newArray) do
|
|
55
53
|
oldArray[key] = value
|
|
56
54
|
end
|
|
57
|
-
return true
|
|
58
55
|
end
|
|
59
56
|
function mergeTSTLObject(self, oldObject, newTable, traversalDescription)
|
|
60
57
|
oldObject:clear()
|
|
@@ -62,13 +59,13 @@ function mergeTSTLObject(self, oldObject, newTable, traversalDescription)
|
|
|
62
59
|
for key, value in pairs(newTable) do
|
|
63
60
|
do
|
|
64
61
|
if isSerializationBrand(nil, key) then
|
|
65
|
-
goto
|
|
62
|
+
goto __continue12
|
|
66
63
|
end
|
|
67
64
|
local keyToUse = key
|
|
68
65
|
if convertStringKeysToNumbers then
|
|
69
66
|
local numberKey = tonumber(key)
|
|
70
67
|
if numberKey == nil then
|
|
71
|
-
goto
|
|
68
|
+
goto __continue12
|
|
72
69
|
end
|
|
73
70
|
keyToUse = numberKey
|
|
74
71
|
end
|
|
@@ -85,13 +82,10 @@ function mergeTSTLObject(self, oldObject, newTable, traversalDescription)
|
|
|
85
82
|
oldObject:add(keyToUse)
|
|
86
83
|
end
|
|
87
84
|
end
|
|
88
|
-
::
|
|
85
|
+
::__continue12::
|
|
89
86
|
end
|
|
90
87
|
end
|
|
91
88
|
function mergeTable(self, oldTable, newTable, traversalDescription)
|
|
92
|
-
if SAVE_DATA_MANAGER_DEBUG then
|
|
93
|
-
log("merge is operating on a table. Iterating through the keys...")
|
|
94
|
-
end
|
|
95
89
|
for key, value in pairs(newTable) do
|
|
96
90
|
do
|
|
97
91
|
if SAVE_DATA_MANAGER_DEBUG then
|
|
@@ -99,7 +93,7 @@ function mergeTable(self, oldTable, newTable, traversalDescription)
|
|
|
99
93
|
log((("merge is merging: " .. traversalDescription) .. " --> ") .. valueToPrint)
|
|
100
94
|
end
|
|
101
95
|
if isSerializationBrand(nil, key) then
|
|
102
|
-
goto
|
|
96
|
+
goto __continue21
|
|
103
97
|
end
|
|
104
98
|
if isSerializedIsaacAPIClass(nil, value) then
|
|
105
99
|
if SAVE_DATA_MANAGER_DEBUG then
|
|
@@ -107,7 +101,7 @@ function mergeTable(self, oldTable, newTable, traversalDescription)
|
|
|
107
101
|
end
|
|
108
102
|
local deserializedObject = deserializeIsaacAPIClass(nil, value)
|
|
109
103
|
oldTable[key] = deserializedObject
|
|
110
|
-
goto
|
|
104
|
+
goto __continue21
|
|
111
105
|
end
|
|
112
106
|
local valueType = type(value)
|
|
113
107
|
if valueType == "table" then
|
|
@@ -123,7 +117,7 @@ function mergeTable(self, oldTable, newTable, traversalDescription)
|
|
|
123
117
|
oldTable[key] = value
|
|
124
118
|
end
|
|
125
119
|
end
|
|
126
|
-
::
|
|
120
|
+
::__continue21::
|
|
127
121
|
end
|
|
128
122
|
end
|
|
129
123
|
return ____exports
|
|
@@ -1,33 +1,40 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
2
|
/**
|
|
3
|
-
* Helper function to add and remove familiars based on a target amount that you specify.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* Helper function to add and remove familiars based on a target amount that you specify.
|
|
4
|
+
*
|
|
5
|
+
* This is a convenience wrapper around the `EntityPlayer.CheckFamiliar` method. Use this helper
|
|
6
|
+
* function instead so that you do not have to retrieve the `ItemConfigItem` and so that you do not
|
|
7
|
+
* specify an incorrect RNG object. (The vanilla method is bugged in that it does not increment the
|
|
8
|
+
* RNG object; see the documentation of the method for more details.)
|
|
7
9
|
*
|
|
8
10
|
* This function is meant to be called in the EvaluateCache callback (when the cache flag is equal
|
|
9
11
|
* to `CacheFlag.CACHE_FAMILIARS`).
|
|
10
12
|
*
|
|
11
|
-
* Note that this function is only meant to be used in special circumstances
|
|
12
|
-
*
|
|
13
|
+
* Note that this function is only meant to be used in special circumstances where the familiar
|
|
14
|
+
* count is completely custom and does not correspond to the amount of collectibles. For the general
|
|
15
|
+
* case, use the `checkFamiliarFromCollectibles` helper function instead.
|
|
16
|
+
*
|
|
17
|
+
* Note that this will spawn familiars with a completely random `InitSeed`. When calculating random
|
|
18
|
+
* events for this familiar, you should use a data structure that maps familiar `InitSeed` to RNG
|
|
19
|
+
* objects that are initialized based on the seed from
|
|
20
|
+
* `EntityPlayer.GetCollectibleRNG(collectibleType)`.
|
|
13
21
|
*
|
|
14
22
|
* @param player The player that owns the familiars.
|
|
15
23
|
* @param collectibleType The collectible type of the collectible associated with this familiar.
|
|
16
|
-
* @param
|
|
17
|
-
*
|
|
24
|
+
* @param targetCount The number of familiars that should exist. This function will add or remove
|
|
25
|
+
* familiars until it matches the target count.
|
|
18
26
|
* @param familiarVariant The variant of the familiar to spawn or remove.
|
|
19
27
|
* @param familiarSubType Optional. The sub-type of the familiar to spawn or remove. If not
|
|
20
28
|
* specified, it will search for existing familiars of all sub-types, and spawn new familiars with a
|
|
21
29
|
* sub-type of 0.
|
|
22
|
-
* @returns The amount of familiars that were added or removed. For example, the player has 0
|
|
23
|
-
* collectibles and there were 2 familiars, this function would remove the 2 familiars and return
|
|
24
|
-
* -2.
|
|
25
30
|
*/
|
|
26
|
-
export declare function checkFamiliar(player: EntityPlayer, collectibleType: int,
|
|
31
|
+
export declare function checkFamiliar(player: EntityPlayer, collectibleType: int, targetCount: int, familiarVariant: int, familiarSubType?: int): void;
|
|
27
32
|
/**
|
|
28
33
|
* Helper function to add and remove familiars based on the amount of associated collectibles that a
|
|
29
|
-
* player has.
|
|
30
|
-
*
|
|
34
|
+
* player has.
|
|
35
|
+
*
|
|
36
|
+
* Use this helper function instead of invoking the `EntityPlayer.CheckFamiliar` method directly so
|
|
37
|
+
* that the target count is handled automatically.
|
|
31
38
|
*
|
|
32
39
|
* This function is meant to be called in the EvaluateCache callback (when the cache flag is equal
|
|
33
40
|
* to `CacheFlag.CACHE_FAMILIARS`).
|
|
@@ -37,15 +44,17 @@ export declare function checkFamiliar(player: EntityPlayer, collectibleType: int
|
|
|
37
44
|
* Manual). If you instead need to have a custom amount of familiars, use the `checkFamiliars`
|
|
38
45
|
* function instead.
|
|
39
46
|
*
|
|
47
|
+
* Note that this will spawn familiars with a completely random `InitSeed`. When calculating random
|
|
48
|
+
* events for this familiar, you should use a data structure that maps familiar `InitSeed` to RNG
|
|
49
|
+
* objects that are initialized based on the seed from
|
|
50
|
+
* `EntityPlayer.GetCollectibleRNG(collectibleType)`.
|
|
51
|
+
*
|
|
40
52
|
* @param player The player that owns the familiars and collectibles.
|
|
41
53
|
* @param collectibleType The collectible type of the collectible associated with this familiar.
|
|
42
54
|
* @param familiarVariant The variant of the familiar to spawn or remove.
|
|
43
55
|
* @param familiarSubType Optional. The sub-type of the familiar to spawn or remove. If not
|
|
44
56
|
* specified, it will search for existing familiars of all sub-types, and spawn new familiars with a
|
|
45
57
|
* sub-type of 0.
|
|
46
|
-
* @returns The amount of familiars that were added or removed. For example, the player has 0
|
|
47
|
-
* collectibles and there were 2 familiars, this function would remove the 2 familiars and return
|
|
48
|
-
* -2.
|
|
49
58
|
*/
|
|
50
|
-
export declare function checkFamiliarFromCollectibles(player: EntityPlayer, collectibleType: int, familiarVariant: int, familiarSubType?: int):
|
|
59
|
+
export declare function checkFamiliarFromCollectibles(player: EntityPlayer, collectibleType: int, familiarVariant: int, familiarSubType?: int): void;
|
|
51
60
|
export declare function isFamiliarThatShootsPlayerTears(familiar: EntityFamiliar): boolean;
|
|
@@ -1,64 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
3
2
|
local ____exports = {}
|
|
3
|
+
local ____cachedClasses = require("cachedClasses")
|
|
4
|
+
local itemConfig = ____cachedClasses.itemConfig
|
|
4
5
|
local ____familiarsThatShootPlayerTearsSet = require("sets.familiarsThatShootPlayerTearsSet")
|
|
5
6
|
local FAMILIARS_THAT_SHOOT_PLAYER_TEARS_SET = ____familiarsThatShootPlayerTearsSet.FAMILIARS_THAT_SHOOT_PLAYER_TEARS_SET
|
|
6
|
-
|
|
7
|
-
local
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
local ____repeat = ____utils["repeat"]
|
|
15
|
-
function ____exports.checkFamiliar(self, player, collectibleType, numTargetFamiliars, familiarVariant, familiarSubType)
|
|
16
|
-
local familiarSubTypeToSearchFor = familiarSubType == nil and -1 or familiarSubType
|
|
17
|
-
local playerPtrHash = GetPtrHash(player)
|
|
18
|
-
local familiars = getFamiliars(nil, familiarVariant, familiarSubTypeToSearchFor)
|
|
19
|
-
local familiarsForThisPlayer = __TS__ArrayFilter(
|
|
20
|
-
familiars,
|
|
21
|
-
function(____, familiar) return GetPtrHash(familiar.Player) == playerPtrHash end
|
|
22
|
-
)
|
|
23
|
-
if #familiarsForThisPlayer == numTargetFamiliars then
|
|
24
|
-
return 0
|
|
25
|
-
end
|
|
26
|
-
if #familiarsForThisPlayer > numTargetFamiliars then
|
|
27
|
-
local numFamiliarsToRemove = #familiarsForThisPlayer - numTargetFamiliars
|
|
28
|
-
local familiarsToRemove = copyArray(nil, familiarsForThisPlayer, numFamiliarsToRemove)
|
|
29
|
-
removeEntities(nil, familiarsToRemove)
|
|
30
|
-
return numFamiliarsToRemove * -1
|
|
31
|
-
end
|
|
32
|
-
local numFamiliarsToSpawn = numTargetFamiliars - #familiarsForThisPlayer
|
|
33
|
-
local collectibleRNG = player:GetCollectibleRNG(collectibleType)
|
|
34
|
-
local familiarSubTypeToUse = familiarSubType == nil and 0 or familiarSubType
|
|
35
|
-
____repeat(
|
|
36
|
-
nil,
|
|
37
|
-
numFamiliarsToSpawn,
|
|
38
|
-
function()
|
|
39
|
-
local seed = collectibleRNG:Next()
|
|
40
|
-
local familiar = spawnFamiliarWithSeed(
|
|
41
|
-
nil,
|
|
42
|
-
familiarVariant,
|
|
43
|
-
familiarSubTypeToUse,
|
|
44
|
-
player.Position,
|
|
45
|
-
seed
|
|
46
|
-
)
|
|
47
|
-
familiar.Player = player
|
|
48
|
-
end
|
|
7
|
+
function ____exports.checkFamiliar(self, player, collectibleType, targetCount, familiarVariant, familiarSubType)
|
|
8
|
+
local itemConfigItem = itemConfig:GetCollectible(collectibleType)
|
|
9
|
+
player:CheckFamiliar(
|
|
10
|
+
familiarVariant,
|
|
11
|
+
targetCount,
|
|
12
|
+
RNG(),
|
|
13
|
+
itemConfigItem,
|
|
14
|
+
familiarSubType
|
|
49
15
|
)
|
|
50
|
-
return numFamiliarsToSpawn
|
|
51
16
|
end
|
|
52
17
|
function ____exports.checkFamiliarFromCollectibles(self, player, collectibleType, familiarVariant, familiarSubType)
|
|
53
18
|
local numCollectibles = player:GetCollectibleNum(collectibleType)
|
|
54
19
|
local effects = player:GetEffects()
|
|
55
20
|
local numCollectibleEffects = effects:GetCollectibleEffectNum(collectibleType)
|
|
56
|
-
local
|
|
57
|
-
|
|
21
|
+
local targetCount = numCollectibles + numCollectibleEffects
|
|
22
|
+
____exports.checkFamiliar(
|
|
58
23
|
nil,
|
|
59
24
|
player,
|
|
60
25
|
collectibleType,
|
|
61
|
-
|
|
26
|
+
targetCount,
|
|
62
27
|
familiarVariant,
|
|
63
28
|
familiarSubType
|
|
64
29
|
)
|
|
@@ -92,6 +92,11 @@ export declare function hexToKColor(hexString: string, alpha: float): KColor;
|
|
|
92
92
|
* is enabled or not.
|
|
93
93
|
*/
|
|
94
94
|
export declare function isLuaDebugEnabled(): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Since this is a UI element, we do not want to draw it in water reflections. `renderOffset` will
|
|
97
|
+
* be a non-zero value in reflections.
|
|
98
|
+
*/
|
|
99
|
+
export declare function isReflectionRender(): boolean;
|
|
95
100
|
/**
|
|
96
101
|
* Helper function to print something to the in-game console. Use this instead of invoking the
|
|
97
102
|
* `Isaac.ConsoleOutput` method directly because it will automatically insert a newline at the end
|
package/dist/functions/utils.lua
CHANGED
|
@@ -6,6 +6,8 @@ local __TS__StringSubstr = ____lualib.__TS__StringSubstr
|
|
|
6
6
|
local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
|
|
7
7
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
8
8
|
local ____exports = {}
|
|
9
|
+
local ____cachedClasses = require("cachedClasses")
|
|
10
|
+
local game = ____cachedClasses.game
|
|
9
11
|
local ____directionNames = require("objects.directionNames")
|
|
10
12
|
local DIRECTION_NAMES = ____directionNames.DIRECTION_NAMES
|
|
11
13
|
local HEX_STRING_LENGTH = 6
|
|
@@ -66,6 +68,11 @@ end
|
|
|
66
68
|
function ____exports.isLuaDebugEnabled(self)
|
|
67
69
|
return package ~= nil
|
|
68
70
|
end
|
|
71
|
+
function ____exports.isReflectionRender(self)
|
|
72
|
+
local room = game:GetRoom()
|
|
73
|
+
local renderMode = room:GetRenderMode()
|
|
74
|
+
return renderMode == RenderMode.RENDER_WATER_REFLECT
|
|
75
|
+
end
|
|
69
76
|
function ____exports.printConsole(self, msg)
|
|
70
77
|
Isaac.ConsoleOutput(msg .. "\n")
|
|
71
78
|
end
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.254",
|
|
4
4
|
"description": "Helper functions for IsaacScript mods",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dist/**/*.d.ts"
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"isaac-typescript-definitions": "^1.0.
|
|
28
|
+
"isaac-typescript-definitions": "^1.0.389",
|
|
29
29
|
"isaacscript-lint": "^1.0.99",
|
|
30
30
|
"isaacscript-tsconfig": "^1.1.8",
|
|
31
31
|
"typedoc": "^0.22.13",
|