isaacscript-common 1.0.553 → 1.0.557

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 @@
1
+ export {};
@@ -0,0 +1,71 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ require("lualib_bundle");
3
+ local ____exports = {}
4
+ local hasSubscriptions, postPEffectUpdate, entityTakeDmgPlayer, getTrinketMap, TRINKETS_THAT_CAN_BREAK, v
5
+ local ____exports = require("features.saveDataManager.exports")
6
+ local saveDataManager = ____exports.saveDataManager
7
+ local ____player = require("functions.player")
8
+ local getPlayerIndex = ____player.getPlayerIndex
9
+ local ____postTrinketBreak = require("callbacks.subscriptions.postTrinketBreak")
10
+ local postTrinketBreakFire = ____postTrinketBreak.postTrinketBreakFire
11
+ local postTrinketBreakHasSubscriptions = ____postTrinketBreak.postTrinketBreakHasSubscriptions
12
+ function hasSubscriptions(self)
13
+ return postTrinketBreakHasSubscriptions(nil)
14
+ end
15
+ function postPEffectUpdate(self, player)
16
+ if not hasSubscriptions(nil) then
17
+ return
18
+ end
19
+ local trinketMap = getTrinketMap(nil, player)
20
+ for ____, trinketType in ipairs(TRINKETS_THAT_CAN_BREAK) do
21
+ local numTrinkets = player:GetTrinketMultiplier(trinketType)
22
+ trinketMap:set(trinketType, numTrinkets)
23
+ end
24
+ end
25
+ function entityTakeDmgPlayer(self, tookDamage, _damageAmount, _damageFlags, _damageSource, _damageCountdownFrames)
26
+ if not hasSubscriptions(nil) then
27
+ return
28
+ end
29
+ local player = tookDamage:ToPlayer()
30
+ if player == nil then
31
+ return
32
+ end
33
+ local trinketMap = getTrinketMap(nil, player)
34
+ for ____, trinketType in ipairs(TRINKETS_THAT_CAN_BREAK) do
35
+ do
36
+ local numTrinketsHeld = player:GetTrinketMultiplier(trinketType)
37
+ local oldNumTrinketsHeld = trinketMap:get(trinketType)
38
+ if (oldNumTrinketsHeld == nil) or (numTrinketsHeld >= oldNumTrinketsHeld) then
39
+ goto __continue10
40
+ end
41
+ trinketMap:set(trinketType, numTrinketsHeld)
42
+ local numTrinketsOnGround = Isaac.CountEntities(nil, EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, trinketType)
43
+ if numTrinketsOnGround > 0 then
44
+ goto __continue10
45
+ end
46
+ postTrinketBreakFire(nil, player, trinketType)
47
+ end
48
+ ::__continue10::
49
+ end
50
+ end
51
+ function getTrinketMap(self, player)
52
+ local playerIndex = getPlayerIndex(nil, player)
53
+ local playerTrinketMap = v.run.playerTrinketMap:get(playerIndex)
54
+ if playerTrinketMap == nil then
55
+ playerTrinketMap = __TS__New(Map)
56
+ v.run.playerTrinketMap:set(playerIndex, playerTrinketMap)
57
+ end
58
+ return playerTrinketMap
59
+ end
60
+ TRINKETS_THAT_CAN_BREAK = {TrinketType.TRINKET_WISH_BONE, TrinketType.TRINKET_WALNUT}
61
+ v = {
62
+ run = {
63
+ playerTrinketMap = __TS__New(Map)
64
+ }
65
+ }
66
+ function ____exports.postTrinketBreakCallbackInit(self, mod)
67
+ saveDataManager(nil, "postTrinketBreak", v, hasSubscriptions)
68
+ mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, postPEffectUpdate)
69
+ mod:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, entityTakeDmgPlayer, EntityType.ENTITY_PLAYER)
70
+ end
71
+ return ____exports
@@ -0,0 +1,2 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ export declare type PostTrinketBreakCallbackType = (player: EntityPlayer, trinketType: TrinketType) => void;
@@ -0,0 +1,26 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ require("lualib_bundle");
3
+ local ____exports = {}
4
+ local subscriptions = {}
5
+ function ____exports.postTrinketBreakHasSubscriptions(self)
6
+ return #subscriptions > 0
7
+ end
8
+ function ____exports.postTrinketBreakRegister(self, callback, trinketType)
9
+ __TS__ArrayPush(subscriptions, {callback, trinketType})
10
+ end
11
+ function ____exports.postTrinketBreakFire(self, player, trinketType)
12
+ for ____, ____value in ipairs(subscriptions) do
13
+ local callback
14
+ callback = ____value[1]
15
+ local callbackTrinketType
16
+ callbackTrinketType = ____value[2]
17
+ do
18
+ if (callbackTrinketType ~= nil) and (callbackTrinketType ~= trinketType) then
19
+ goto __continue5
20
+ end
21
+ callback(nil, player, trinketType)
22
+ end
23
+ ::__continue5::
24
+ end
25
+ end
26
+ return ____exports
@@ -1,6 +1,11 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  export declare function closeAllDoors(): void;
3
- export declare function getDoors(roomType?: RoomType): GridEntityDoor[];
3
+ /**
4
+ * Helper function to get all of the doors in the room. By default, it will return every door. You
5
+ * can optionally specify one or more room types to return only the doors that match the specified
6
+ * room types.
7
+ */
8
+ export declare function getDoors(...roomTypes: RoomType[]): GridEntityDoor[];
4
9
  export declare function getAngelRoomDoor(): GridEntityDoor | undefined;
5
10
  export declare function getDevilRoomDoor(): GridEntityDoor | undefined;
6
11
  /**
@@ -3,9 +3,11 @@ require("lualib_bundle");
3
3
  local ____exports = {}
4
4
  local ____constants = require("constants")
5
5
  local MAX_NUM_DOORS = ____constants.MAX_NUM_DOORS
6
- function ____exports.getDoors(self, roomType)
6
+ function ____exports.getDoors(self, ...)
7
+ local roomTypes = {...}
7
8
  local game = Game()
8
9
  local room = game:GetRoom()
10
+ local roomTypesSet = __TS__New(Set, roomTypes)
9
11
  local doors = {}
10
12
  do
11
13
  local i = 0
@@ -15,9 +17,9 @@ function ____exports.getDoors(self, roomType)
15
17
  if door == nil then
16
18
  goto __continue5
17
19
  end
18
- if roomType == nil then
20
+ if #roomTypes == 0 then
19
21
  __TS__ArrayPush(doors, door)
20
- elseif door:IsRoomType(roomType) then
22
+ elseif roomTypesSet:has(door.TargetRoomType) then
21
23
  __TS__ArrayPush(doors, door)
22
24
  end
23
25
  end
@@ -61,7 +61,6 @@ export declare function getEnumValues(transpiledEnum: unknown): int[];
61
61
  * @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
62
62
  */
63
63
  export declare function hexToKColor(hexString: string, alpha: float): KColor;
64
- export declare function isGreedMode(): boolean;
65
64
  /**
66
65
  * Players can boot the game with an launch option called "--luadebug", which will enable additional
67
66
  * functionality that is considered to be unsafe. For more information about this flag, see the
@@ -60,10 +60,6 @@ function ____exports.hexToKColor(self, hexString, alpha)
60
60
  local base = 255
61
61
  return KColor(R / base, G / base, B / base, alpha)
62
62
  end
63
- function ____exports.isGreedMode(self)
64
- local game = Game()
65
- return (game.Difficulty == Difficulty.DIFFICULTY_GREED) or (game.Difficulty == Difficulty.DIFFICULTY_GREEDIER)
66
- end
67
63
  function ____exports.isLuaDebugEnabled(self)
68
64
  return package ~= nil
69
65
  end
@@ -38,6 +38,7 @@ import { PostSlotUpdateCallbackType } from "../callbacks/subscriptions/postSlotU
38
38
  import { PostTearInitLateCallbackType } from "../callbacks/subscriptions/postTearInitLate";
39
39
  import { PostTearInitVeryLateCallbackType } from "../callbacks/subscriptions/postTearInitVeryLate";
40
40
  import { PostTransformationCallbackType } from "../callbacks/subscriptions/postTransformation";
41
+ import { PostTrinketBreakCallbackType } from "../callbacks/subscriptions/postTrinketBreak";
41
42
  import { PreCustomReviveCallbackType } from "../callbacks/subscriptions/preCustomRevive";
42
43
  import { PreItemPickupCallbackType } from "../callbacks/subscriptions/preItemPickup";
43
44
  import { PreNewLevelCallbackType } from "../callbacks/subscriptions/PreNewLevel";
@@ -164,6 +165,9 @@ export interface CallbackParametersCustom {
164
165
  [ModCallbacksCustom.MC_POST_CURSED_TELEPORT]: [
165
166
  callback: PostCursedTeleportCallbackType
166
167
  ];
168
+ [ModCallbacksCustom.MC_POST_TRINKET_BREAK]: [
169
+ callback: PostTrinketBreakCallbackType
170
+ ];
167
171
  [ModCallbacksCustom.MC_POST_SLOT_INIT]: [
168
172
  callback: PostSlotInitCallbackType,
169
173
  slotVariant?: SlotVariant
@@ -41,11 +41,12 @@ export declare enum ModCallbacksCustom {
41
41
  MC_POST_PURCHASE = 32,
42
42
  MC_POST_SACRIFICE = 33,
43
43
  MC_POST_CURSED_TELEPORT = 34,
44
- MC_POST_SLOT_INIT = 35,
45
- MC_POST_SLOT_UPDATE = 36,
46
- MC_POST_SLOT_RENDER = 37,
47
- MC_POST_SLOT_DESTROYED = 38,
48
- MC_POST_GRID_ENTITY_INIT = 39,
49
- MC_POST_GRID_ENTITY_UPDATE = 40,
50
- MC_POST_GRID_ENTITY_REMOVE = 41
44
+ MC_POST_TRINKET_BREAK = 35,
45
+ MC_POST_SLOT_INIT = 36,
46
+ MC_POST_SLOT_UPDATE = 37,
47
+ MC_POST_SLOT_RENDER = 38,
48
+ MC_POST_SLOT_DESTROYED = 39,
49
+ MC_POST_GRID_ENTITY_INIT = 40,
50
+ MC_POST_GRID_ENTITY_UPDATE = 41,
51
+ MC_POST_GRID_ENTITY_REMOVE = 42
51
52
  }
@@ -71,18 +71,20 @@ ____exports.ModCallbacksCustom.MC_POST_SACRIFICE = 33
71
71
  ____exports.ModCallbacksCustom[____exports.ModCallbacksCustom.MC_POST_SACRIFICE] = "MC_POST_SACRIFICE"
72
72
  ____exports.ModCallbacksCustom.MC_POST_CURSED_TELEPORT = 34
73
73
  ____exports.ModCallbacksCustom[____exports.ModCallbacksCustom.MC_POST_CURSED_TELEPORT] = "MC_POST_CURSED_TELEPORT"
74
- ____exports.ModCallbacksCustom.MC_POST_SLOT_INIT = 35
74
+ ____exports.ModCallbacksCustom.MC_POST_TRINKET_BREAK = 35
75
+ ____exports.ModCallbacksCustom[____exports.ModCallbacksCustom.MC_POST_TRINKET_BREAK] = "MC_POST_TRINKET_BREAK"
76
+ ____exports.ModCallbacksCustom.MC_POST_SLOT_INIT = 36
75
77
  ____exports.ModCallbacksCustom[____exports.ModCallbacksCustom.MC_POST_SLOT_INIT] = "MC_POST_SLOT_INIT"
76
- ____exports.ModCallbacksCustom.MC_POST_SLOT_UPDATE = 36
78
+ ____exports.ModCallbacksCustom.MC_POST_SLOT_UPDATE = 37
77
79
  ____exports.ModCallbacksCustom[____exports.ModCallbacksCustom.MC_POST_SLOT_UPDATE] = "MC_POST_SLOT_UPDATE"
78
- ____exports.ModCallbacksCustom.MC_POST_SLOT_RENDER = 37
80
+ ____exports.ModCallbacksCustom.MC_POST_SLOT_RENDER = 38
79
81
  ____exports.ModCallbacksCustom[____exports.ModCallbacksCustom.MC_POST_SLOT_RENDER] = "MC_POST_SLOT_RENDER"
80
- ____exports.ModCallbacksCustom.MC_POST_SLOT_DESTROYED = 38
82
+ ____exports.ModCallbacksCustom.MC_POST_SLOT_DESTROYED = 39
81
83
  ____exports.ModCallbacksCustom[____exports.ModCallbacksCustom.MC_POST_SLOT_DESTROYED] = "MC_POST_SLOT_DESTROYED"
82
- ____exports.ModCallbacksCustom.MC_POST_GRID_ENTITY_INIT = 39
84
+ ____exports.ModCallbacksCustom.MC_POST_GRID_ENTITY_INIT = 40
83
85
  ____exports.ModCallbacksCustom[____exports.ModCallbacksCustom.MC_POST_GRID_ENTITY_INIT] = "MC_POST_GRID_ENTITY_INIT"
84
- ____exports.ModCallbacksCustom.MC_POST_GRID_ENTITY_UPDATE = 40
86
+ ____exports.ModCallbacksCustom.MC_POST_GRID_ENTITY_UPDATE = 41
85
87
  ____exports.ModCallbacksCustom[____exports.ModCallbacksCustom.MC_POST_GRID_ENTITY_UPDATE] = "MC_POST_GRID_ENTITY_UPDATE"
86
- ____exports.ModCallbacksCustom.MC_POST_GRID_ENTITY_REMOVE = 41
88
+ ____exports.ModCallbacksCustom.MC_POST_GRID_ENTITY_REMOVE = 42
87
89
  ____exports.ModCallbacksCustom[____exports.ModCallbacksCustom.MC_POST_GRID_ENTITY_REMOVE] = "MC_POST_GRID_ENTITY_REMOVE"
88
90
  return ____exports
@@ -80,6 +80,8 @@ local ____postTearInitVeryLate = require("callbacks.subscriptions.postTearInitVe
80
80
  local postTearInitVeryLateRegister = ____postTearInitVeryLate.postTearInitVeryLateRegister
81
81
  local ____postTransformation = require("callbacks.subscriptions.postTransformation")
82
82
  local postTransformationRegister = ____postTransformation.postTransformationRegister
83
+ local ____postTrinketBreak = require("callbacks.subscriptions.postTrinketBreak")
84
+ local postTrinketBreakRegister = ____postTrinketBreak.postTrinketBreakRegister
83
85
  local ____preCustomRevive = require("callbacks.subscriptions.preCustomRevive")
84
86
  local preCustomReviveRegister = ____preCustomRevive.preCustomReviveRegister
85
87
  local ____preItemPickup = require("callbacks.subscriptions.preItemPickup")
@@ -319,6 +321,12 @@ function getCallbackRegisterFunction(self, callbackID)
319
321
  return postCursedTeleportRegister
320
322
  end
321
323
  end
324
+ ____cond18 = ____cond18 or (____switch18 == ModCallbacksCustom.MC_POST_TRINKET_BREAK)
325
+ if ____cond18 then
326
+ do
327
+ return postTrinketBreakRegister
328
+ end
329
+ end
322
330
  ____cond18 = ____cond18 or (____switch18 == ModCallbacksCustom.MC_POST_SLOT_INIT)
323
331
  if ____cond18 then
324
332
  do
@@ -58,6 +58,8 @@ local ____postTearInitVeryLate = require("callbacks.postTearInitVeryLate")
58
58
  local postTearInitVeryLateCallbackInit = ____postTearInitVeryLate.postTearInitVeryLateCallbackInit
59
59
  local ____postTransformation = require("callbacks.postTransformation")
60
60
  local postTransformationCallbackInit = ____postTransformation.postTransformationCallbackInit
61
+ local ____postTrinketBreak = require("callbacks.postTrinketBreak")
62
+ local postTrinketBreakCallbackInit = ____postTrinketBreak.postTrinketBreakCallbackInit
61
63
  local ____preNewLevel = require("callbacks.preNewLevel")
62
64
  local preNewLevelCallbackInit = ____preNewLevel.preNewLevelCallbackInit
63
65
  local ____reorderedCallbacks = require("callbacks.reorderedCallbacks")
@@ -111,6 +113,7 @@ function initCustomCallbacks(self, mod)
111
113
  postTransformationCallbackInit(nil, mod)
112
114
  postPurchaseCallbackInit(nil, mod)
113
115
  postSacrificeCallbackInit(nil, mod)
116
+ postTrinketBreakCallbackInit(nil, mod)
114
117
  postCursedTeleportCallbackInit(nil, mod)
115
118
  postSlotInitUpdateCallbacksInit(nil, mod)
116
119
  postSlotRenderBrokenCallbacksInit(nil, mod)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.553",
3
+ "version": "1.0.557",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",