isaacscript-common 1.0.602 → 1.0.603

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.
@@ -0,0 +1,2 @@
1
+ export declare const DEFAULT_GLOBALS: Set<string>;
2
+ export declare const LUA_DEBUG_ADDED_GLOBALS: Set<string>;
@@ -0,0 +1,171 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ require("lualib_bundle");
3
+ local ____exports = {}
4
+ ____exports.DEFAULT_GLOBALS = __TS__New(Set, {
5
+ "ActionTriggers",
6
+ "ActiveSlot",
7
+ "BabySubType",
8
+ "BackdropType",
9
+ "BatterySubType",
10
+ "BedSubType",
11
+ "BitSet128",
12
+ "BombSubType",
13
+ "BombVariant",
14
+ "ButtonAction",
15
+ "CacheFlag",
16
+ "Card",
17
+ "Challenge",
18
+ "ChampionColor",
19
+ "ChestSubType",
20
+ "CoinSubType",
21
+ "CollectibleType",
22
+ "Color",
23
+ "CppContainer",
24
+ "DamageFlag",
25
+ "Difficulty",
26
+ "Direction",
27
+ "DoorSlot",
28
+ "DoorState",
29
+ "DoorVariant",
30
+ "EffectVariant",
31
+ "Entity",
32
+ "EntityBomb",
33
+ "EntityCollisionClass",
34
+ "EntityEffect",
35
+ "EntityFamiliar",
36
+ "EntityFlag",
37
+ "EntityGridCollisionClass",
38
+ "EntityKnife",
39
+ "EntityLaser",
40
+ "EntityNPC",
41
+ "EntityPartition",
42
+ "EntityPickup",
43
+ "EntityPlayer",
44
+ "EntityProjectile",
45
+ "EntityPtr",
46
+ "EntityRef",
47
+ "EntityTear",
48
+ "EntityType",
49
+ "FamiliarVariant",
50
+ "Font",
51
+ "Game",
52
+ "GameStateFlag",
53
+ "GetPtrHash",
54
+ "GridCollisionClass",
55
+ "GridEntity",
56
+ "GridEntityDesc",
57
+ "GridEntityDoor",
58
+ "GridEntityPit",
59
+ "GridEntityPoop",
60
+ "GridEntityPressurePlate",
61
+ "GridEntityRock",
62
+ "GridEntitySpikes",
63
+ "GridEntityTNT",
64
+ "GridEntityType",
65
+ "GridRooms",
66
+ "HUD",
67
+ "HeartSubType",
68
+ "Input",
69
+ "InputHook",
70
+ "Isaac",
71
+ "ItemConfig",
72
+ "ItemPool",
73
+ "ItemPoolType",
74
+ "ItemType",
75
+ "KColor",
76
+ "KeySubType",
77
+ "Keyboard",
78
+ "LaserOffset",
79
+ "LaserSubType",
80
+ "Level",
81
+ "LevelCurse",
82
+ "LevelStage",
83
+ "LevelStateFlag",
84
+ "LocustSubtypes",
85
+ "ModCallbacks",
86
+ "Mouse",
87
+ "Music",
88
+ "MusicManager",
89
+ "NpcState",
90
+ "NullItemID",
91
+ "Options",
92
+ "PathFinder",
93
+ "PickupPrice",
94
+ "PickupVariant",
95
+ "PillColor",
96
+ "PillEffect",
97
+ "PlayerForm",
98
+ "PlayerSpriteLayer",
99
+ "PlayerType",
100
+ "PlayerTypes",
101
+ "PoopPickupSubType",
102
+ "PoopSpellType",
103
+ "ProjectileFlags",
104
+ "ProjectileParams",
105
+ "ProjectileVariant",
106
+ "QueueItemData",
107
+ "REPENTANCE",
108
+ "RNG",
109
+ "Random",
110
+ "RandomVector",
111
+ "RegisterMod",
112
+ "RenderMode",
113
+ "Room",
114
+ "RoomConfig",
115
+ "RoomDescriptor",
116
+ "RoomShape",
117
+ "RoomTransitionAnim",
118
+ "RoomType",
119
+ "SFXManager",
120
+ "SackSubType",
121
+ "SeedEffect",
122
+ "Seeds",
123
+ "ShockwaveParams",
124
+ "SortingLayer",
125
+ "SoundEffect",
126
+ "Sprite",
127
+ "StageType",
128
+ "StartDebug",
129
+ "TearFlags",
130
+ "TearParams",
131
+ "TearVariant",
132
+ "TemporaryEffect",
133
+ "TemporaryEffects",
134
+ "TrinketType",
135
+ "UseFlag",
136
+ "Vector",
137
+ "WeaponType",
138
+ "_G",
139
+ "_VERSION",
140
+ "assert",
141
+ "collectgarbage",
142
+ "coroutine",
143
+ "dofile",
144
+ "error",
145
+ "getmetatable",
146
+ "include",
147
+ "ipairs",
148
+ "load",
149
+ "loadfile",
150
+ "math",
151
+ "next",
152
+ "pairs",
153
+ "pcall",
154
+ "print",
155
+ "rawequal",
156
+ "rawget",
157
+ "rawlen",
158
+ "rawset",
159
+ "require",
160
+ "select",
161
+ "setmetatable",
162
+ "string",
163
+ "table",
164
+ "tonumber",
165
+ "tostring",
166
+ "type",
167
+ "utf8",
168
+ "xpcall"
169
+ })
170
+ ____exports.LUA_DEBUG_ADDED_GLOBALS = __TS__New(Set, {"debug", "io", "os", "package"})
171
+ return ____exports
@@ -11,6 +11,8 @@ local LOST_STYLE_PLAYER_TYPES = ____constants.LOST_STYLE_PLAYER_TYPES
11
11
  local MAX_PLAYER_HEART_CONTAINERS = ____constants.MAX_PLAYER_HEART_CONTAINERS
12
12
  local ____HealthType = require("types.HealthType")
13
13
  local HealthType = ____HealthType.HealthType
14
+ local ____array = require("functions.array")
15
+ local arraySum = ____array.arraySum
14
16
  local ____bitwise = require("functions.bitwise")
15
17
  local getKBitOfN = ____bitwise.getKBitOfN
16
18
  local getNumBitsOfN = ____bitwise.getNumBitsOfN
@@ -308,14 +310,14 @@ end
308
310
  function ____exports.getPlayersOfType(self, ...)
309
311
  local characters = {...}
310
312
  local charactersSet = __TS__New(Set, characters)
311
- local players = {}
312
- for ____, player in ipairs(____exports.getPlayers(nil)) do
313
- local character = player:GetPlayerType()
314
- if charactersSet:has(character) then
315
- __TS__ArrayPush(players, player)
313
+ local players = ____exports.getPlayers(nil)
314
+ return __TS__ArrayFilter(
315
+ players,
316
+ function(____, player)
317
+ local character = player:GetPlayerType()
318
+ return charactersSet:has(character)
316
319
  end
317
- end
318
- return players
320
+ )
319
321
  end
320
322
  function ____exports.getTotalCharge(self, player, activeSlot)
321
323
  local activeCharge = player:GetActiveCharge(activeSlot)
@@ -323,11 +325,12 @@ function ____exports.getTotalCharge(self, player, activeSlot)
323
325
  return activeCharge + batteryCharge
324
326
  end
325
327
  function ____exports.getTotalPlayerCollectibles(self, collectibleType)
326
- local numCollectibles = 0
327
- for ____, player in ipairs(____exports.getPlayers(nil)) do
328
- numCollectibles = numCollectibles + player:GetCollectibleNum(collectibleType)
329
- end
330
- return numCollectibles
328
+ local players = ____exports.getPlayers(nil)
329
+ local numCollectiblesArray = __TS__ArrayMap(
330
+ players,
331
+ function(____, player) return player:GetCollectibleNum(collectibleType) end
332
+ )
333
+ return arraySum(nil, numCollectiblesArray)
331
334
  end
332
335
  function ____exports.hasLostCurse(self, player)
333
336
  local effects = player:GetEffects()
@@ -452,9 +455,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
452
455
  itemPool:RemoveCollectible(collectibleType)
453
456
  end
454
457
  repeat
455
- local ____switch112 = activeSlot
456
- local ____cond112 = ____switch112 == ActiveSlot.SLOT_PRIMARY
457
- if ____cond112 then
458
+ local ____switch109 = activeSlot
459
+ local ____cond109 = ____switch109 == ActiveSlot.SLOT_PRIMARY
460
+ if ____cond109 then
458
461
  do
459
462
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
460
463
  player:RemoveCollectible(primaryCollectibleType)
@@ -463,8 +466,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
463
466
  break
464
467
  end
465
468
  end
466
- ____cond112 = ____cond112 or ____switch112 == ActiveSlot.SLOT_SECONDARY
467
- if ____cond112 then
469
+ ____cond109 = ____cond109 or ____switch109 == ActiveSlot.SLOT_SECONDARY
470
+ if ____cond109 then
468
471
  do
469
472
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
470
473
  player:RemoveCollectible(primaryCollectibleType)
@@ -479,16 +482,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
479
482
  break
480
483
  end
481
484
  end
482
- ____cond112 = ____cond112 or ____switch112 == ActiveSlot.SLOT_POCKET
483
- if ____cond112 then
485
+ ____cond109 = ____cond109 or ____switch109 == ActiveSlot.SLOT_POCKET
486
+ if ____cond109 then
484
487
  do
485
488
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
486
489
  player:SetActiveCharge(charge, activeSlot)
487
490
  break
488
491
  end
489
492
  end
490
- ____cond112 = ____cond112 or ____switch112 == ActiveSlot.SLOT_POCKET2
491
- if ____cond112 then
493
+ ____cond109 = ____cond109 or ____switch109 == ActiveSlot.SLOT_POCKET2
494
+ if ____cond109 then
492
495
  do
493
496
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
494
497
  break
@@ -10,6 +10,7 @@ export declare function copyMap<K, V>(oldMap: Map<K, V>): Map<K, V>;
10
10
  * instead.
11
11
  */
12
12
  export declare function copySet<T>(oldSet: Set<T>): Set<T>;
13
+ export declare function combineSets<T>(...sets: Array<Set<T>>): Set<T>;
13
14
  /**
14
15
  * Helper function to get type safety on a switch statement.
15
16
  * Very useful to be future-safe against people adding values to a type or an enum.
@@ -18,6 +18,16 @@ function ____exports.copySet(self, oldSet)
18
18
  end
19
19
  return newSet
20
20
  end
21
+ function ____exports.combineSets(self, ...)
22
+ local sets = {...}
23
+ local newSet = __TS__New(Set)
24
+ for ____, set in ipairs(sets) do
25
+ for ____, value in __TS__Iterator(set:values()) do
26
+ newSet:add(value)
27
+ end
28
+ end
29
+ return newSet
30
+ end
21
31
  ____exports.ensureAllCases = function(____, obj) return obj end
22
32
  function ____exports.getEnumValues(self, transpiledEnum)
23
33
  local enumValues = {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.602",
3
+ "version": "1.0.603",
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.332",
28
+ "isaac-typescript-definitions": "^1.0.333",
29
29
  "isaacscript-lint": "^1.0.79",
30
30
  "isaacscript-tsconfig": "^1.1.8",
31
31
  "typedoc": "^0.22.11",