isaacscript-common 1.2.50 → 1.2.53
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.
|
@@ -34,8 +34,8 @@ function setDamageFrame(self, tookDamage, damageFlags)
|
|
|
34
34
|
local playerIndex = getPlayerIndex(nil, player)
|
|
35
35
|
local trackingArray = v.run.damageFrameMap:get(playerIndex)
|
|
36
36
|
if trackingArray ~= nil then
|
|
37
|
-
local lastDamageFrame,
|
|
38
|
-
if lastDamageFrame == gameFrameCount and
|
|
37
|
+
local lastDamageFrame, callbackFiredOnThisFrame = table.unpack(trackingArray)
|
|
38
|
+
if lastDamageFrame == gameFrameCount and callbackFiredOnThisFrame then
|
|
39
39
|
return
|
|
40
40
|
end
|
|
41
41
|
end
|
|
@@ -29,6 +29,7 @@ function postPEffectUpdateReordered(self, player)
|
|
|
29
29
|
local playerHealthMap = v.run.playersHealthMap:get(playerIndex)
|
|
30
30
|
if playerHealthMap == nil then
|
|
31
31
|
playerHealthMap = __TS__New(Map)
|
|
32
|
+
v.run.playersHealthMap:set(playerIndex, playerHealthMap)
|
|
32
33
|
end
|
|
33
34
|
local healthTypes = getEnumValues(nil, HealthType)
|
|
34
35
|
for ____, healthType in ipairs(healthTypes) do
|
package/dist/index.d.ts
CHANGED
|
@@ -73,6 +73,7 @@ export * from "./maps/trinketNameMap";
|
|
|
73
73
|
export * from "./sets/cards";
|
|
74
74
|
export * from "./types/AnyEntity";
|
|
75
75
|
export * from "./types/CallbackParametersCustom";
|
|
76
|
+
export * from "./types/DefaultMap";
|
|
76
77
|
export * from "./types/HealthType";
|
|
77
78
|
export * from "./types/JSONDoor";
|
|
78
79
|
export * from "./types/JSONEntity";
|
package/dist/index.lua
CHANGED
|
@@ -578,6 +578,14 @@ do
|
|
|
578
578
|
end
|
|
579
579
|
end
|
|
580
580
|
end
|
|
581
|
+
do
|
|
582
|
+
local ____export = require("types.DefaultMap")
|
|
583
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
584
|
+
if ____exportKey ~= "default" then
|
|
585
|
+
____exports[____exportKey] = ____exportValue
|
|
586
|
+
end
|
|
587
|
+
end
|
|
588
|
+
end
|
|
581
589
|
do
|
|
582
590
|
local ____export = require("types.HealthType")
|
|
583
591
|
for ____exportKey, ____exportValue in pairs(____export) do
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare type FirstArg<K, V> = Iterable<[K, V]> | V | ((k: K) => V);
|
|
2
|
+
declare type SecondArg<K, V> = V | ((k: K) => V);
|
|
3
|
+
/**
|
|
4
|
+
* An extended Map with a new method of `getAndSetDefault`.
|
|
5
|
+
*
|
|
6
|
+
* When instantiating the object, you must specify either a default value or a function that returns
|
|
7
|
+
* a default value.
|
|
8
|
+
*
|
|
9
|
+
* Example:
|
|
10
|
+
* ```ts
|
|
11
|
+
* const defaultMap1 = new DefaultMap<string, string>("foo");
|
|
12
|
+
* const defaultMap2 = new DefaultMap<string, string>(["a", "b", "c"], "bar");
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare class DefaultMap<K, V> extends Map<K, V> {
|
|
16
|
+
private defaultValue;
|
|
17
|
+
private defaultValueFactory;
|
|
18
|
+
constructor(iterableOrDefaultValueOrDefaultValueFactory: FirstArg<K, V>, defaultValueOrDefaultValueFactory?: SecondArg<K, V>);
|
|
19
|
+
/**
|
|
20
|
+
* Almost the same as `Map.prototype.get`. However, if the key does not exist in the map, then
|
|
21
|
+
* this method will set the default value for the key and return the default value.
|
|
22
|
+
*/
|
|
23
|
+
getAndSetDefault(key: K): V | undefined;
|
|
24
|
+
getDefaultValue(key: K): V;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
local ____lualib = require("lualib_bundle")
|
|
3
|
+
local __TS__Class = ____lualib.__TS__Class
|
|
4
|
+
local Map = ____lualib.Map
|
|
5
|
+
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
6
|
+
local ____exports = {}
|
|
7
|
+
local parseArguments, parseArgumentsOne, parseArgumentsTwo, parseDefaultValueOrDefaultValueFactory
|
|
8
|
+
function parseArguments(self, firstArg, secondArg)
|
|
9
|
+
return secondArg == nil and parseArgumentsOne(nil, firstArg) or parseArgumentsTwo(nil, firstArg, secondArg)
|
|
10
|
+
end
|
|
11
|
+
function parseArgumentsOne(self, firstArg)
|
|
12
|
+
local defaultValue, defaultValueFactory = table.unpack(parseDefaultValueOrDefaultValueFactory(nil, firstArg))
|
|
13
|
+
return {nil, defaultValue, defaultValueFactory}
|
|
14
|
+
end
|
|
15
|
+
function parseArgumentsTwo(self, firstArg, secondArg)
|
|
16
|
+
local firstArgType = type(firstArg)
|
|
17
|
+
if firstArgType ~= "table" then
|
|
18
|
+
error("A DefaultMap constructor with two arguments must have the first argument be an array.")
|
|
19
|
+
end
|
|
20
|
+
local defaultValue, defaultValueFactory = table.unpack(parseDefaultValueOrDefaultValueFactory(nil, secondArg))
|
|
21
|
+
return {firstArg, defaultValue, defaultValueFactory}
|
|
22
|
+
end
|
|
23
|
+
function parseDefaultValueOrDefaultValueFactory(self, arg)
|
|
24
|
+
local argType = type(arg)
|
|
25
|
+
if argType == "function" then
|
|
26
|
+
return {nil, arg}
|
|
27
|
+
end
|
|
28
|
+
if argType == "boolean" or argType == "number" or argType == "string" then
|
|
29
|
+
return {arg, nil}
|
|
30
|
+
end
|
|
31
|
+
return error("A DefaultMap must be initialized with a default value that is either a primitive or a function that returns a default value.")
|
|
32
|
+
end
|
|
33
|
+
____exports.DefaultMap = __TS__Class()
|
|
34
|
+
local DefaultMap = ____exports.DefaultMap
|
|
35
|
+
DefaultMap.name = "DefaultMap"
|
|
36
|
+
__TS__ClassExtends(DefaultMap, Map)
|
|
37
|
+
function DefaultMap.prototype.____constructor(self, iterableOrDefaultValueOrDefaultValueFactory, defaultValueOrDefaultValueFactory)
|
|
38
|
+
local iterable, defaultValue, defaultValueFactory = table.unpack(parseArguments(nil, iterableOrDefaultValueOrDefaultValueFactory, defaultValueOrDefaultValueFactory))
|
|
39
|
+
if defaultValue == nil and defaultValueFactory == nil then
|
|
40
|
+
error("A DefaultMap must be instantiated with either a default value or a function that returns a default value.")
|
|
41
|
+
end
|
|
42
|
+
if iterable == nil then
|
|
43
|
+
Map.prototype.____constructor(self)
|
|
44
|
+
else
|
|
45
|
+
Map.prototype.____constructor(self, iterable)
|
|
46
|
+
end
|
|
47
|
+
self.defaultValue = defaultValue
|
|
48
|
+
self.defaultValueFactory = defaultValueFactory
|
|
49
|
+
end
|
|
50
|
+
function DefaultMap.prototype.getAndSetDefault(self, key)
|
|
51
|
+
if self:has(key) then
|
|
52
|
+
return self:get(key)
|
|
53
|
+
end
|
|
54
|
+
local defaultValue = self:getDefaultValue(key)
|
|
55
|
+
self:set(key, defaultValue)
|
|
56
|
+
return defaultValue
|
|
57
|
+
end
|
|
58
|
+
function DefaultMap.prototype.getDefaultValue(self, key)
|
|
59
|
+
if self.defaultValue ~= nil then
|
|
60
|
+
return self.defaultValue
|
|
61
|
+
end
|
|
62
|
+
if self.defaultValueFactory ~= nil then
|
|
63
|
+
return self:defaultValueFactory(key)
|
|
64
|
+
end
|
|
65
|
+
return error("A DefaultMap was incorrectly instantiated.")
|
|
66
|
+
end
|
|
67
|
+
return ____exports
|