isaacscript-common 21.8.2 → 21.8.3

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.
@@ -1285,6 +1285,8 @@ export declare function clearCollectibleSprite(collectible: EntityPickup): void;
1285
1285
  /**
1286
1286
  * Helper function to set the value of `DisplayFlag` for every room on the floor to 0.
1287
1287
  *
1288
+ * This function automatically accounts for whether or not MinimapAPI is being used.
1289
+ *
1288
1290
  * This function automatically calls the `Level.UpdateVisibility` after setting the flags so that
1289
1291
  * the changes will be immediately visible.
1290
1292
  */
@@ -4957,6 +4959,8 @@ export declare function getFlagName<T extends BitFlag | BitFlag128>(flag: BitFla
4957
4959
  /**
4958
4960
  * Helper function to get the minimap `DisplayFlag` value for every room on the floor. Returns a map
4959
4961
  * that is indexed by the room's safe grid index.
4962
+ *
4963
+ * This function automatically accounts for whether or not MinimapAPI is being used.
4960
4964
  */
4961
4965
  export declare function getFloorDisplayFlags(): Map<int, BitFlags<DisplayFlag>>;
4962
4966
 
@@ -6145,6 +6149,8 @@ export declare function getRoomDescriptorReadOnly(): Readonly<RoomDescriptor>;
6145
6149
  * Helper function to get a particular room's minimap display flags (e.g. whether or not it is
6146
6150
  * visible and so on).
6147
6151
  *
6152
+ * This function automatically accounts for whether or not MinimapAPI is being used.
6153
+ *
6148
6154
  * @param roomGridIndex Optional. Default is the current room index.
6149
6155
  */
6150
6156
  export declare function getRoomDisplayFlags(roomGridIndex?: int): BitFlags<DisplayFlag>;
@@ -14150,6 +14156,16 @@ export declare function setAdd<T>(set: Set<T>, ...elements: T[]): void;
14150
14156
  */
14151
14157
  export declare function setAddPlayer(set: Set<PlayerIndex>, player: EntityPlayer): Set<PlayerIndex>;
14152
14158
 
14159
+ /**
14160
+ * Helper function to set the minimap `DisplayFlag` value for every room on the floor at once.
14161
+ *
14162
+ * This function automatically calls the `Level.UpdateVisibility` after setting the flags so that
14163
+ * the changes will be immediately visible.
14164
+ *
14165
+ * This function automatically accounts for whether or not MinimapAPI is being used.
14166
+ */
14167
+ export declare function setAllDisplayFlags(displayFlags: BitFlags<DisplayFlag>): void;
14168
+
14153
14169
  /**
14154
14170
  * Helper function to iterate over the provided object and set the seed for all of the values that
14155
14171
  * are RNG objects equal to a particular seed.
@@ -14236,18 +14252,6 @@ export declare function setCollectibleSubType(collectible: EntityPickup, newColl
14236
14252
  */
14237
14253
  export declare function setDeletePlayer(set: Set<PlayerIndex>, player: EntityPlayer): boolean;
14238
14254
 
14239
- /**
14240
- * Helper function to set the minimap `DisplayFlag` value for multiple rooms at once.
14241
- *
14242
- * This function automatically calls the `Level.UpdateVisibility` after setting the flags so that
14243
- * the changes will be immediately visible.
14244
- *
14245
- * This function automatically accounts for whether or not MinimapAPI is being used.
14246
- *
14247
- * @param displayFlagsMap A map of the display flags that is indexed by the room's safe grid index.
14248
- */
14249
- export declare function setDisplayFlags(displayFlagsMap: Map<int, BitFlags<DisplayFlag>>): void;
14250
-
14251
14255
  /**
14252
14256
  * Helper function to make an entity flash red like it is taking damage. This is useful when you
14253
14257
  * want to make it appear as if an entity is taking damage without actually dealing any damage to
@@ -14296,7 +14300,16 @@ export declare function setEntityRandomColor(entity: Entity): void;
14296
14300
  */
14297
14301
  export declare function setEntityVelocities(entityVelocities: Map<PtrHash, Vector>, entities?: Entity[]): void;
14298
14302
 
14299
- /** Alias for the `setDisplayFlags` function. */
14303
+ /**
14304
+ * Helper function to set the minimap `DisplayFlag` value for multiple rooms at once.
14305
+ *
14306
+ * This function automatically calls the `Level.UpdateVisibility` after setting the flags so that
14307
+ * the changes will be immediately visible.
14308
+ *
14309
+ * This function automatically accounts for whether or not MinimapAPI is being used.
14310
+ *
14311
+ * @param displayFlagsMap A map of the display flags that is indexed by the room's safe grid index.
14312
+ */
14300
14313
  export declare function setFloorDisplayFlags(displayFlagsMap: Map<int, BitFlags<DisplayFlag>>): void;
14301
14314
 
14302
14315
  /**
@@ -14347,10 +14360,14 @@ export declare function setRoomData(roomGridIndex: int, roomData: RoomConfig): v
14347
14360
  * Helper function to set a particular room's minimap display flags (e.g. whether or not it is
14348
14361
  * visible and so on).
14349
14362
  *
14363
+ * This function automatically accounts for whether or not MinimapAPI is being used.
14364
+ *
14350
14365
  * @param roomGridIndex Set to undefined to use the current room index.
14351
14366
  * @param displayFlags The bit flags value to set. (See the `DisplayFlag` enum.)
14352
14367
  * @param updateVisibility Optional. Whether to call the `Level.UpdateVisibility` method in order to
14353
- * make the changes immediately visible. Default is true.
14368
+ * make the changes immediately visible. Default is true. Set this to false
14369
+ * if you are doing a bunch of display flag setting and then manually call
14370
+ * the `Level.UpdateVisibility` method after you are done.
14354
14371
  */
14355
14372
  export declare function setRoomDisplayFlags(roomGridIndex: int | undefined, displayFlags: BitFlags<DisplayFlag>, updateVisibility?: boolean): void;
14356
14373
 
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 21.8.2
3
+ isaacscript-common 21.8.3
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -10569,7 +10569,7 @@ ____exports.CanaryVariant.CANARY = 0
10569
10569
  ____exports.CanaryVariant[____exports.CanaryVariant.CANARY] = "CANARY"
10570
10570
  ____exports.CanaryVariant.FOREIGNER = 1
10571
10571
  ____exports.CanaryVariant[____exports.CanaryVariant.FOREIGNER] = "FOREIGNER"
10572
- --- For `EntityType.GAPER_L2` (850).
10572
+ --- For `EntityType.GAPER_LVL_2` (850).
10573
10573
  ____exports.Gaper2Variant = {}
10574
10574
  ____exports.Gaper2Variant.GAPER = 0
10575
10575
  ____exports.Gaper2Variant[____exports.Gaper2Variant.GAPER] = "GAPER"
@@ -10577,7 +10577,7 @@ ____exports.Gaper2Variant.HORF = 1
10577
10577
  ____exports.Gaper2Variant[____exports.Gaper2Variant.HORF] = "HORF"
10578
10578
  ____exports.Gaper2Variant.GUSHER = 2
10579
10579
  ____exports.Gaper2Variant[____exports.Gaper2Variant.GUSHER] = "GUSHER"
10580
- --- For `EntityType.CHARGER_L2` (855).
10580
+ --- For `EntityType.CHARGER_LVL_2` (855).
10581
10581
  ____exports.Charger2Variant = {}
10582
10582
  ____exports.Charger2Variant.CHARGER = 0
10583
10583
  ____exports.Charger2Variant[____exports.Charger2Variant.CHARGER] = "CHARGER"
@@ -51547,85 +51547,81 @@ local getRoomDescriptor = ____roomData.getRoomDescriptor
51547
51547
  local getRoomGridIndex = ____roomData.getRoomGridIndex
51548
51548
  local ____rooms = require("src.functions.rooms")
51549
51549
  local getRoomsInsideGrid = ____rooms.getRoomsInsideGrid
51550
- function ____exports.setRoomDisplayFlags(self, roomGridIndex, displayFlags, updateVisibility)
51551
- if updateVisibility == nil then
51552
- updateVisibility = true
51550
+ function ____exports.getRoomDisplayFlags(self, roomGridIndex)
51551
+ if roomGridIndex == nil then
51552
+ roomGridIndex = getRoomGridIndex(nil)
51553
51553
  end
51554
51554
  if MinimapAPI == nil then
51555
51555
  local roomDescriptor = getRoomDescriptor(nil, roomGridIndex)
51556
- roomDescriptor.DisplayFlags = displayFlags
51557
- else
51558
- if roomGridIndex == nil then
51559
- roomGridIndex = getRoomGridIndex(nil)
51560
- end
51561
- local roomDescriptor = MinimapAPI:GetRoomByIdx(roomGridIndex)
51562
- if roomDescriptor ~= nil then
51563
- roomDescriptor.DisplayFlags = displayFlags
51564
- end
51556
+ return roomDescriptor.DisplayFlags
51557
+ end
51558
+ local minimapAPIRoomDescriptor = MinimapAPI:GetRoomByIdx(roomGridIndex)
51559
+ if minimapAPIRoomDescriptor == nil then
51560
+ error("Failed to get the MinimapAPI room descriptor for the room at index: " .. tostring(roomGridIndex))
51561
+ end
51562
+ return minimapAPIRoomDescriptor:GetDisplayFlags()
51563
+ end
51564
+ function ____exports.setAllDisplayFlags(self, displayFlags)
51565
+ for ____, room in ipairs(getRoomsInsideGrid(nil)) do
51566
+ ____exports.setRoomDisplayFlags(nil, room.SafeGridIndex, displayFlags, false)
51565
51567
  end
51566
- if updateVisibility then
51568
+ if MinimapAPI == nil then
51567
51569
  local level = game:GetLevel()
51568
51570
  level:UpdateVisibility()
51569
51571
  end
51570
51572
  end
51571
- function ____exports.addRoomDisplayFlag(self, roomGridIndex, displayFlag, updateVisibility)
51573
+ function ____exports.setRoomDisplayFlags(self, roomGridIndex, displayFlags, updateVisibility)
51572
51574
  if updateVisibility == nil then
51573
51575
  updateVisibility = true
51574
51576
  end
51577
+ if roomGridIndex == nil then
51578
+ roomGridIndex = getRoomGridIndex(nil)
51579
+ end
51575
51580
  if MinimapAPI == nil then
51576
51581
  local roomDescriptor = getRoomDescriptor(nil, roomGridIndex)
51577
- roomDescriptor.DisplayFlags = addFlag(nil, roomDescriptor.DisplayFlags, displayFlag)
51578
- else
51579
- if roomGridIndex == nil then
51580
- roomGridIndex = getRoomGridIndex(nil)
51582
+ roomDescriptor.DisplayFlags = displayFlags
51583
+ if updateVisibility then
51584
+ local level = game:GetLevel()
51585
+ level:UpdateVisibility()
51581
51586
  end
51582
- local roomDescriptor = MinimapAPI:GetRoomByIdx(roomGridIndex)
51583
- if roomDescriptor ~= nil then
51584
- roomDescriptor.DisplayFlags = addFlag(nil, roomDescriptor.DisplayFlags, displayFlag)
51587
+ else
51588
+ local minimapAPIRoomDescriptor = MinimapAPI:GetRoomByIdx(roomGridIndex)
51589
+ if minimapAPIRoomDescriptor == nil then
51590
+ error("Failed to get the MinimapAPI room descriptor for the room at index: " .. tostring(roomGridIndex))
51585
51591
  end
51592
+ minimapAPIRoomDescriptor:SetDisplayFlags(displayFlags)
51586
51593
  end
51587
- if updateVisibility then
51588
- local level = game:GetLevel()
51589
- level:UpdateVisibility()
51594
+ end
51595
+ function ____exports.addRoomDisplayFlag(self, roomGridIndex, displayFlag, updateVisibility)
51596
+ if updateVisibility == nil then
51597
+ updateVisibility = true
51590
51598
  end
51599
+ local oldDisplayFlags = ____exports.getRoomDisplayFlags(nil, roomGridIndex)
51600
+ local newDisplayFlags = addFlag(nil, oldDisplayFlags, displayFlag)
51601
+ ____exports.setRoomDisplayFlags(nil, roomGridIndex, newDisplayFlags, updateVisibility)
51591
51602
  end
51592
51603
  function ____exports.clearFloorDisplayFlags(self)
51593
- local level = game:GetLevel()
51594
- for ____, room in ipairs(getRoomsInsideGrid(nil)) do
51595
- room.DisplayFlags = DisplayFlagZero
51596
- end
51597
- level:UpdateVisibility()
51604
+ ____exports.setAllDisplayFlags(nil, DisplayFlagZero)
51598
51605
  end
51599
51606
  function ____exports.getFloorDisplayFlags(self)
51600
51607
  local displayFlagsMap = __TS__New(Map)
51601
- local roomsInGrid = getRoomsInsideGrid(nil)
51602
- for ____, roomDescriptor in ipairs(roomsInGrid) do
51603
- displayFlagsMap:set(roomDescriptor.SafeGridIndex, roomDescriptor.DisplayFlags)
51608
+ for ____, roomDescriptor in ipairs(getRoomsInsideGrid(nil)) do
51609
+ local roomGridIndex = roomDescriptor.SafeGridIndex
51610
+ local displayFlags = ____exports.getRoomDisplayFlags(nil, roomGridIndex)
51611
+ displayFlagsMap:set(roomGridIndex, displayFlags)
51604
51612
  end
51605
51613
  return displayFlagsMap
51606
51614
  end
51607
- function ____exports.getRoomDisplayFlags(self, roomGridIndex)
51608
- local roomDescriptor = getRoomDescriptor(nil, roomGridIndex)
51609
- return roomDescriptor.DisplayFlags
51610
- end
51611
- function ____exports.setDisplayFlags(self, displayFlagsMap)
51612
- local level = game:GetLevel()
51615
+ function ____exports.setFloorDisplayFlags(self, displayFlagsMap)
51613
51616
  for ____, ____value in __TS__Iterator(displayFlagsMap) do
51614
51617
  local roomGridIndex = ____value[1]
51615
51618
  local displayFlags = ____value[2]
51616
- if MinimapAPI == nil then
51617
- ____exports.setRoomDisplayFlags(nil, roomGridIndex, displayFlags, false)
51618
- else
51619
- local roomDescriptor = MinimapAPI:GetRoomByIdx(roomGridIndex)
51620
- if roomDescriptor ~= nil then
51621
- roomDescriptor.DisplayFlags = displayFlags
51622
- end
51623
- end
51619
+ ____exports.setRoomDisplayFlags(nil, roomGridIndex, displayFlags, false)
51620
+ end
51621
+ if MinimapAPI == nil then
51622
+ local level = game:GetLevel()
51623
+ level:UpdateVisibility()
51624
51624
  end
51625
- level:UpdateVisibility()
51626
- end
51627
- function ____exports.setFloorDisplayFlags(self, displayFlagsMap)
51628
- ____exports.setDisplayFlags(nil, displayFlagsMap)
51629
51625
  end
51630
51626
  function ____exports.setRoomVisible(self, roomGridIndex, updateVisibility)
51631
51627
  if updateVisibility == nil then
@@ -14,6 +14,8 @@ export declare function addRoomDisplayFlag(roomGridIndex: int | undefined, displ
14
14
  /**
15
15
  * Helper function to set the value of `DisplayFlag` for every room on the floor to 0.
16
16
  *
17
+ * This function automatically accounts for whether or not MinimapAPI is being used.
18
+ *
17
19
  * This function automatically calls the `Level.UpdateVisibility` after setting the flags so that
18
20
  * the changes will be immediately visible.
19
21
  */
@@ -21,15 +23,28 @@ export declare function clearFloorDisplayFlags(): void;
21
23
  /**
22
24
  * Helper function to get the minimap `DisplayFlag` value for every room on the floor. Returns a map
23
25
  * that is indexed by the room's safe grid index.
26
+ *
27
+ * This function automatically accounts for whether or not MinimapAPI is being used.
24
28
  */
25
29
  export declare function getFloorDisplayFlags(): Map<int, BitFlags<DisplayFlag>>;
26
30
  /**
27
31
  * Helper function to get a particular room's minimap display flags (e.g. whether or not it is
28
32
  * visible and so on).
29
33
  *
34
+ * This function automatically accounts for whether or not MinimapAPI is being used.
35
+ *
30
36
  * @param roomGridIndex Optional. Default is the current room index.
31
37
  */
32
38
  export declare function getRoomDisplayFlags(roomGridIndex?: int): BitFlags<DisplayFlag>;
39
+ /**
40
+ * Helper function to set the minimap `DisplayFlag` value for every room on the floor at once.
41
+ *
42
+ * This function automatically calls the `Level.UpdateVisibility` after setting the flags so that
43
+ * the changes will be immediately visible.
44
+ *
45
+ * This function automatically accounts for whether or not MinimapAPI is being used.
46
+ */
47
+ export declare function setAllDisplayFlags(displayFlags: BitFlags<DisplayFlag>): void;
33
48
  /**
34
49
  * Helper function to set the minimap `DisplayFlag` value for multiple rooms at once.
35
50
  *
@@ -40,17 +55,19 @@ export declare function getRoomDisplayFlags(roomGridIndex?: int): BitFlags<Displ
40
55
  *
41
56
  * @param displayFlagsMap A map of the display flags that is indexed by the room's safe grid index.
42
57
  */
43
- export declare function setDisplayFlags(displayFlagsMap: Map<int, BitFlags<DisplayFlag>>): void;
44
- /** Alias for the `setDisplayFlags` function. */
45
58
  export declare function setFloorDisplayFlags(displayFlagsMap: Map<int, BitFlags<DisplayFlag>>): void;
46
59
  /**
47
60
  * Helper function to set a particular room's minimap display flags (e.g. whether or not it is
48
61
  * visible and so on).
49
62
  *
63
+ * This function automatically accounts for whether or not MinimapAPI is being used.
64
+ *
50
65
  * @param roomGridIndex Set to undefined to use the current room index.
51
66
  * @param displayFlags The bit flags value to set. (See the `DisplayFlag` enum.)
52
67
  * @param updateVisibility Optional. Whether to call the `Level.UpdateVisibility` method in order to
53
- * make the changes immediately visible. Default is true.
68
+ * make the changes immediately visible. Default is true. Set this to false
69
+ * if you are doing a bunch of display flag setting and then manually call
70
+ * the `Level.UpdateVisibility` method after you are done.
54
71
  */
55
72
  export declare function setRoomDisplayFlags(roomGridIndex: int | undefined, displayFlags: BitFlags<DisplayFlag>, updateVisibility?: boolean): void;
56
73
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"minimap.d.ts","sourceRoot":"","sources":["../../../src/functions/minimap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAmB,MAAM,8BAA8B,CAAC;AAM5E;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,GAAG,GAAG,SAAS,EAC9B,WAAW,EAAE,WAAW,EACxB,gBAAgB,UAAO,GACtB,IAAI,CAwBN;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAS7C;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC,CAYtE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,CAAC,EAAE,GAAG,GAClB,QAAQ,CAAC,WAAW,CAAC,CAGvB;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,eAAe,EAAE,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC,GAC/C,IAAI,CAiBN;AAED,gDAAgD;AAChD,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC,GAC/C,IAAI,CAEN;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,GAAG,GAAG,SAAS,EAC9B,YAAY,EAAE,QAAQ,CAAC,WAAW,CAAC,EACnC,gBAAgB,UAAO,GACtB,IAAI,CAkBN;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,aAAa,EAAE,GAAG,GAAG,SAAS,EAC9B,gBAAgB,UAAO,GACtB,IAAI,CAEN"}
1
+ {"version":3,"file":"minimap.d.ts","sourceRoot":"","sources":["../../../src/functions/minimap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAmB,MAAM,8BAA8B,CAAC;AAM5E;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,GAAG,GAAG,SAAS,EAC9B,WAAW,EAAE,WAAW,EACxB,gBAAgB,UAAO,GACtB,IAAI,CAIN;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC,CAUtE;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,CAAC,EAAE,GAAG,GAClB,QAAQ,CAAC,WAAW,CAAC,CAiBvB;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,CAW5E;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC,GAC/C,IAAI,CAWN;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,GAAG,GAAG,SAAS,EAC9B,YAAY,EAAE,QAAQ,CAAC,WAAW,CAAC,EACnC,gBAAgB,UAAO,GACtB,IAAI,CAsBN;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,aAAa,EAAE,GAAG,GAAG,SAAS,EAC9B,gBAAgB,UAAO,GACtB,IAAI,CAEN"}
@@ -15,32 +15,72 @@ local getRoomDescriptor = ____roomData.getRoomDescriptor
15
15
  local getRoomGridIndex = ____roomData.getRoomGridIndex
16
16
  local ____rooms = require("src.functions.rooms")
17
17
  local getRoomsInsideGrid = ____rooms.getRoomsInsideGrid
18
+ --- Helper function to get a particular room's minimap display flags (e.g. whether or not it is
19
+ -- visible and so on).
20
+ --
21
+ -- This function automatically accounts for whether or not MinimapAPI is being used.
22
+ --
23
+ -- @param roomGridIndex Optional. Default is the current room index.
24
+ function ____exports.getRoomDisplayFlags(self, roomGridIndex)
25
+ if roomGridIndex == nil then
26
+ roomGridIndex = getRoomGridIndex(nil)
27
+ end
28
+ if MinimapAPI == nil then
29
+ local roomDescriptor = getRoomDescriptor(nil, roomGridIndex)
30
+ return roomDescriptor.DisplayFlags
31
+ end
32
+ local minimapAPIRoomDescriptor = MinimapAPI:GetRoomByIdx(roomGridIndex)
33
+ if minimapAPIRoomDescriptor == nil then
34
+ error("Failed to get the MinimapAPI room descriptor for the room at index: " .. tostring(roomGridIndex))
35
+ end
36
+ return minimapAPIRoomDescriptor:GetDisplayFlags()
37
+ end
38
+ --- Helper function to set the minimap `DisplayFlag` value for every room on the floor at once.
39
+ --
40
+ -- This function automatically calls the `Level.UpdateVisibility` after setting the flags so that
41
+ -- the changes will be immediately visible.
42
+ --
43
+ -- This function automatically accounts for whether or not MinimapAPI is being used.
44
+ function ____exports.setAllDisplayFlags(self, displayFlags)
45
+ for ____, room in ipairs(getRoomsInsideGrid(nil)) do
46
+ ____exports.setRoomDisplayFlags(nil, room.SafeGridIndex, displayFlags, false)
47
+ end
48
+ if MinimapAPI == nil then
49
+ local level = game:GetLevel()
50
+ level:UpdateVisibility()
51
+ end
52
+ end
18
53
  --- Helper function to set a particular room's minimap display flags (e.g. whether or not it is
19
54
  -- visible and so on).
20
55
  --
56
+ -- This function automatically accounts for whether or not MinimapAPI is being used.
57
+ --
21
58
  -- @param roomGridIndex Set to undefined to use the current room index.
22
59
  -- @param displayFlags The bit flags value to set. (See the `DisplayFlag` enum.)
23
60
  -- @param updateVisibility Optional. Whether to call the `Level.UpdateVisibility` method in order to
24
- -- make the changes immediately visible. Default is true.
61
+ -- make the changes immediately visible. Default is true. Set this to false
62
+ -- if you are doing a bunch of display flag setting and then manually call
63
+ -- the `Level.UpdateVisibility` method after you are done.
25
64
  function ____exports.setRoomDisplayFlags(self, roomGridIndex, displayFlags, updateVisibility)
26
65
  if updateVisibility == nil then
27
66
  updateVisibility = true
28
67
  end
68
+ if roomGridIndex == nil then
69
+ roomGridIndex = getRoomGridIndex(nil)
70
+ end
29
71
  if MinimapAPI == nil then
30
72
  local roomDescriptor = getRoomDescriptor(nil, roomGridIndex)
31
73
  roomDescriptor.DisplayFlags = displayFlags
32
- else
33
- if roomGridIndex == nil then
34
- roomGridIndex = getRoomGridIndex(nil)
74
+ if updateVisibility then
75
+ local level = game:GetLevel()
76
+ level:UpdateVisibility()
35
77
  end
36
- local roomDescriptor = MinimapAPI:GetRoomByIdx(roomGridIndex)
37
- if roomDescriptor ~= nil then
38
- roomDescriptor.DisplayFlags = displayFlags
78
+ else
79
+ local minimapAPIRoomDescriptor = MinimapAPI:GetRoomByIdx(roomGridIndex)
80
+ if minimapAPIRoomDescriptor == nil then
81
+ error("Failed to get the MinimapAPI room descriptor for the room at index: " .. tostring(roomGridIndex))
39
82
  end
40
- end
41
- if updateVisibility then
42
- local level = game:GetLevel()
43
- level:UpdateVisibility()
83
+ minimapAPIRoomDescriptor:SetDisplayFlags(displayFlags)
44
84
  end
45
85
  end
46
86
  --- Helper function to add a `DisplayFlag` to a particular room's minimap display flags (e.g. whether
@@ -56,52 +96,32 @@ function ____exports.addRoomDisplayFlag(self, roomGridIndex, displayFlag, update
56
96
  if updateVisibility == nil then
57
97
  updateVisibility = true
58
98
  end
59
- if MinimapAPI == nil then
60
- local roomDescriptor = getRoomDescriptor(nil, roomGridIndex)
61
- roomDescriptor.DisplayFlags = addFlag(nil, roomDescriptor.DisplayFlags, displayFlag)
62
- else
63
- if roomGridIndex == nil then
64
- roomGridIndex = getRoomGridIndex(nil)
65
- end
66
- local roomDescriptor = MinimapAPI:GetRoomByIdx(roomGridIndex)
67
- if roomDescriptor ~= nil then
68
- roomDescriptor.DisplayFlags = addFlag(nil, roomDescriptor.DisplayFlags, displayFlag)
69
- end
70
- end
71
- if updateVisibility then
72
- local level = game:GetLevel()
73
- level:UpdateVisibility()
74
- end
99
+ local oldDisplayFlags = ____exports.getRoomDisplayFlags(nil, roomGridIndex)
100
+ local newDisplayFlags = addFlag(nil, oldDisplayFlags, displayFlag)
101
+ ____exports.setRoomDisplayFlags(nil, roomGridIndex, newDisplayFlags, updateVisibility)
75
102
  end
76
103
  --- Helper function to set the value of `DisplayFlag` for every room on the floor to 0.
77
104
  --
105
+ -- This function automatically accounts for whether or not MinimapAPI is being used.
106
+ --
78
107
  -- This function automatically calls the `Level.UpdateVisibility` after setting the flags so that
79
108
  -- the changes will be immediately visible.
80
109
  function ____exports.clearFloorDisplayFlags(self)
81
- local level = game:GetLevel()
82
- for ____, room in ipairs(getRoomsInsideGrid(nil)) do
83
- room.DisplayFlags = DisplayFlagZero
84
- end
85
- level:UpdateVisibility()
110
+ ____exports.setAllDisplayFlags(nil, DisplayFlagZero)
86
111
  end
87
112
  --- Helper function to get the minimap `DisplayFlag` value for every room on the floor. Returns a map
88
113
  -- that is indexed by the room's safe grid index.
114
+ --
115
+ -- This function automatically accounts for whether or not MinimapAPI is being used.
89
116
  function ____exports.getFloorDisplayFlags(self)
90
117
  local displayFlagsMap = __TS__New(Map)
91
- local roomsInGrid = getRoomsInsideGrid(nil)
92
- for ____, roomDescriptor in ipairs(roomsInGrid) do
93
- displayFlagsMap:set(roomDescriptor.SafeGridIndex, roomDescriptor.DisplayFlags)
118
+ for ____, roomDescriptor in ipairs(getRoomsInsideGrid(nil)) do
119
+ local roomGridIndex = roomDescriptor.SafeGridIndex
120
+ local displayFlags = ____exports.getRoomDisplayFlags(nil, roomGridIndex)
121
+ displayFlagsMap:set(roomGridIndex, displayFlags)
94
122
  end
95
123
  return displayFlagsMap
96
124
  end
97
- --- Helper function to get a particular room's minimap display flags (e.g. whether or not it is
98
- -- visible and so on).
99
- --
100
- -- @param roomGridIndex Optional. Default is the current room index.
101
- function ____exports.getRoomDisplayFlags(self, roomGridIndex)
102
- local roomDescriptor = getRoomDescriptor(nil, roomGridIndex)
103
- return roomDescriptor.DisplayFlags
104
- end
105
125
  --- Helper function to set the minimap `DisplayFlag` value for multiple rooms at once.
106
126
  --
107
127
  -- This function automatically calls the `Level.UpdateVisibility` after setting the flags so that
@@ -110,25 +130,16 @@ end
110
130
  -- This function automatically accounts for whether or not MinimapAPI is being used.
111
131
  --
112
132
  -- @param displayFlagsMap A map of the display flags that is indexed by the room's safe grid index.
113
- function ____exports.setDisplayFlags(self, displayFlagsMap)
114
- local level = game:GetLevel()
133
+ function ____exports.setFloorDisplayFlags(self, displayFlagsMap)
115
134
  for ____, ____value in __TS__Iterator(displayFlagsMap) do
116
135
  local roomGridIndex = ____value[1]
117
136
  local displayFlags = ____value[2]
118
- if MinimapAPI == nil then
119
- ____exports.setRoomDisplayFlags(nil, roomGridIndex, displayFlags, false)
120
- else
121
- local roomDescriptor = MinimapAPI:GetRoomByIdx(roomGridIndex)
122
- if roomDescriptor ~= nil then
123
- roomDescriptor.DisplayFlags = displayFlags
124
- end
125
- end
137
+ ____exports.setRoomDisplayFlags(nil, roomGridIndex, displayFlags, false)
138
+ end
139
+ if MinimapAPI == nil then
140
+ local level = game:GetLevel()
141
+ level:UpdateVisibility()
126
142
  end
127
- level:UpdateVisibility()
128
- end
129
- --- Alias for the `setDisplayFlags` function.
130
- function ____exports.setFloorDisplayFlags(self, displayFlagsMap)
131
- ____exports.setDisplayFlags(nil, displayFlagsMap)
132
143
  end
133
144
  --- Helper function to make a single room visible in a similar way to how the Compass makes a Boss
134
145
  -- Room visible (e.g. by adding `DisplayFlag.SHOW_ICON`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "21.8.2",
3
+ "version": "21.8.3",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -22,6 +22,6 @@
22
22
  "main": "dist/src/index",
23
23
  "types": "dist/index.rollup.d.ts",
24
24
  "dependencies": {
25
- "isaac-typescript-definitions": "^11.1.3"
25
+ "isaac-typescript-definitions": "^11.1.4"
26
26
  }
27
27
  }
@@ -20,61 +20,36 @@ export function addRoomDisplayFlag(
20
20
  displayFlag: DisplayFlag,
21
21
  updateVisibility = true,
22
22
  ): void {
23
- if (MinimapAPI === undefined) {
24
- const roomDescriptor = getRoomDescriptor(roomGridIndex);
25
- roomDescriptor.DisplayFlags = addFlag(
26
- roomDescriptor.DisplayFlags,
27
- displayFlag,
28
- );
29
- } else {
30
- if (roomGridIndex === undefined) {
31
- roomGridIndex = getRoomGridIndex();
32
- }
33
- const roomDescriptor = MinimapAPI.GetRoomByIdx(roomGridIndex);
34
- if (roomDescriptor !== undefined) {
35
- roomDescriptor.DisplayFlags = addFlag(
36
- roomDescriptor.DisplayFlags,
37
- displayFlag,
38
- );
39
- }
40
- }
41
-
42
- if (updateVisibility) {
43
- const level = game.GetLevel();
44
- level.UpdateVisibility();
45
- }
23
+ const oldDisplayFlags = getRoomDisplayFlags(roomGridIndex);
24
+ const newDisplayFlags = addFlag(oldDisplayFlags, displayFlag);
25
+ setRoomDisplayFlags(roomGridIndex, newDisplayFlags, updateVisibility);
46
26
  }
47
27
 
48
28
  /**
49
29
  * Helper function to set the value of `DisplayFlag` for every room on the floor to 0.
50
30
  *
31
+ * This function automatically accounts for whether or not MinimapAPI is being used.
32
+ *
51
33
  * This function automatically calls the `Level.UpdateVisibility` after setting the flags so that
52
34
  * the changes will be immediately visible.
53
35
  */
54
36
  export function clearFloorDisplayFlags(): void {
55
- const level = game.GetLevel();
56
-
57
- for (const room of getRoomsInsideGrid()) {
58
- room.DisplayFlags = DisplayFlagZero;
59
- }
60
-
61
- // We must call the "Level.UpdateVisibility" method for the changes to be visible.
62
- level.UpdateVisibility();
37
+ setAllDisplayFlags(DisplayFlagZero);
63
38
  }
64
39
 
65
40
  /**
66
41
  * Helper function to get the minimap `DisplayFlag` value for every room on the floor. Returns a map
67
42
  * that is indexed by the room's safe grid index.
43
+ *
44
+ * This function automatically accounts for whether or not MinimapAPI is being used.
68
45
  */
69
46
  export function getFloorDisplayFlags(): Map<int, BitFlags<DisplayFlag>> {
70
47
  const displayFlagsMap = new Map<int, BitFlags<DisplayFlag>>();
71
48
 
72
- const roomsInGrid = getRoomsInsideGrid();
73
- for (const roomDescriptor of roomsInGrid) {
74
- displayFlagsMap.set(
75
- roomDescriptor.SafeGridIndex,
76
- roomDescriptor.DisplayFlags,
77
- );
49
+ for (const roomDescriptor of getRoomsInsideGrid()) {
50
+ const roomGridIndex = roomDescriptor.SafeGridIndex;
51
+ const displayFlags = getRoomDisplayFlags(roomGridIndex);
52
+ displayFlagsMap.set(roomGridIndex, displayFlags);
78
53
  }
79
54
 
80
55
  return displayFlagsMap;
@@ -84,13 +59,50 @@ export function getFloorDisplayFlags(): Map<int, BitFlags<DisplayFlag>> {
84
59
  * Helper function to get a particular room's minimap display flags (e.g. whether or not it is
85
60
  * visible and so on).
86
61
  *
62
+ * This function automatically accounts for whether or not MinimapAPI is being used.
63
+ *
87
64
  * @param roomGridIndex Optional. Default is the current room index.
88
65
  */
89
66
  export function getRoomDisplayFlags(
90
67
  roomGridIndex?: int,
91
68
  ): BitFlags<DisplayFlag> {
92
- const roomDescriptor = getRoomDescriptor(roomGridIndex);
93
- return roomDescriptor.DisplayFlags;
69
+ if (roomGridIndex === undefined) {
70
+ roomGridIndex = getRoomGridIndex();
71
+ }
72
+
73
+ if (MinimapAPI === undefined) {
74
+ const roomDescriptor = getRoomDescriptor(roomGridIndex);
75
+ return roomDescriptor.DisplayFlags;
76
+ }
77
+
78
+ const minimapAPIRoomDescriptor = MinimapAPI.GetRoomByIdx(roomGridIndex);
79
+ if (minimapAPIRoomDescriptor === undefined) {
80
+ error(
81
+ `Failed to get the MinimapAPI room descriptor for the room at index: ${roomGridIndex}`,
82
+ );
83
+ }
84
+ return minimapAPIRoomDescriptor.GetDisplayFlags();
85
+ }
86
+
87
+ /**
88
+ * Helper function to set the minimap `DisplayFlag` value for every room on the floor at once.
89
+ *
90
+ * This function automatically calls the `Level.UpdateVisibility` after setting the flags so that
91
+ * the changes will be immediately visible.
92
+ *
93
+ * This function automatically accounts for whether or not MinimapAPI is being used.
94
+ */
95
+ export function setAllDisplayFlags(displayFlags: BitFlags<DisplayFlag>): void {
96
+ for (const room of getRoomsInsideGrid()) {
97
+ // We pass false to the `updateVisibility` argument as a small optimization.
98
+ setRoomDisplayFlags(room.SafeGridIndex, displayFlags, false);
99
+ }
100
+
101
+ // In vanilla, we must call the "Level.UpdateVisibility" method for the changes to be visible.
102
+ if (MinimapAPI === undefined) {
103
+ const level = game.GetLevel();
104
+ level.UpdateVisibility();
105
+ }
94
106
  }
95
107
 
96
108
  /**
@@ -103,64 +115,59 @@ export function getRoomDisplayFlags(
103
115
  *
104
116
  * @param displayFlagsMap A map of the display flags that is indexed by the room's safe grid index.
105
117
  */
106
- export function setDisplayFlags(
118
+ export function setFloorDisplayFlags(
107
119
  displayFlagsMap: Map<int, BitFlags<DisplayFlag>>,
108
120
  ): void {
109
- const level = game.GetLevel();
110
-
111
121
  for (const [roomGridIndex, displayFlags] of displayFlagsMap) {
112
- if (MinimapAPI === undefined) {
113
- // We pass false to the `updateVisibility` argument as a small optimization.
114
- setRoomDisplayFlags(roomGridIndex, displayFlags, false);
115
- } else {
116
- const roomDescriptor = MinimapAPI.GetRoomByIdx(roomGridIndex);
117
- if (roomDescriptor !== undefined) {
118
- roomDescriptor.DisplayFlags = displayFlags;
119
- }
120
- }
122
+ // We pass false to the `updateVisibility` argument as a small optimization.
123
+ setRoomDisplayFlags(roomGridIndex, displayFlags, false);
121
124
  }
122
125
 
123
- // We must call the "Level.UpdateVisibility" method for the changes to be visible.
124
- level.UpdateVisibility();
125
- }
126
-
127
- /** Alias for the `setDisplayFlags` function. */
128
- export function setFloorDisplayFlags(
129
- displayFlagsMap: Map<int, BitFlags<DisplayFlag>>,
130
- ): void {
131
- setDisplayFlags(displayFlagsMap);
126
+ // In vanilla, we must call the "Level.UpdateVisibility" method for the changes to be visible.
127
+ if (MinimapAPI === undefined) {
128
+ const level = game.GetLevel();
129
+ level.UpdateVisibility();
130
+ }
132
131
  }
133
132
 
134
133
  /**
135
134
  * Helper function to set a particular room's minimap display flags (e.g. whether or not it is
136
135
  * visible and so on).
137
136
  *
137
+ * This function automatically accounts for whether or not MinimapAPI is being used.
138
+ *
138
139
  * @param roomGridIndex Set to undefined to use the current room index.
139
140
  * @param displayFlags The bit flags value to set. (See the `DisplayFlag` enum.)
140
141
  * @param updateVisibility Optional. Whether to call the `Level.UpdateVisibility` method in order to
141
- * make the changes immediately visible. Default is true.
142
+ * make the changes immediately visible. Default is true. Set this to false
143
+ * if you are doing a bunch of display flag setting and then manually call
144
+ * the `Level.UpdateVisibility` method after you are done.
142
145
  */
143
146
  export function setRoomDisplayFlags(
144
147
  roomGridIndex: int | undefined,
145
148
  displayFlags: BitFlags<DisplayFlag>,
146
149
  updateVisibility = true,
147
150
  ): void {
151
+ if (roomGridIndex === undefined) {
152
+ roomGridIndex = getRoomGridIndex();
153
+ }
154
+
148
155
  if (MinimapAPI === undefined) {
149
156
  const roomDescriptor = getRoomDescriptor(roomGridIndex);
150
157
  roomDescriptor.DisplayFlags = displayFlags;
151
- } else {
152
- if (roomGridIndex === undefined) {
153
- roomGridIndex = getRoomGridIndex();
158
+
159
+ if (updateVisibility) {
160
+ const level = game.GetLevel();
161
+ level.UpdateVisibility();
154
162
  }
155
- const roomDescriptor = MinimapAPI.GetRoomByIdx(roomGridIndex);
156
- if (roomDescriptor !== undefined) {
157
- roomDescriptor.DisplayFlags = displayFlags;
163
+ } else {
164
+ const minimapAPIRoomDescriptor = MinimapAPI.GetRoomByIdx(roomGridIndex);
165
+ if (minimapAPIRoomDescriptor === undefined) {
166
+ error(
167
+ `Failed to get the MinimapAPI room descriptor for the room at index: ${roomGridIndex}`,
168
+ );
158
169
  }
159
- }
160
-
161
- if (updateVisibility) {
162
- const level = game.GetLevel();
163
- level.UpdateVisibility();
170
+ minimapAPIRoomDescriptor.SetDisplayFlags(displayFlags);
164
171
  }
165
172
  }
166
173