isaacscript-common 9.15.0 → 9.16.0

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.
@@ -1,4 +1,14 @@
1
1
  import { DisplayFlag } from "isaac-typescript-definitions";
2
+ /**
3
+ * Helper function to add a `DisplayFlag` to a particular room's minimap display flags (e.g. whether
4
+ * or not it is visible and so on).
5
+ *
6
+ * @param roomGridIndex Set to undefined to use the current room index.
7
+ * @param displayFlag The `DisplayFlag` to set. (See the `DisplayFlag` enum.)
8
+ * @param updateVisibility Optional. Whether to call the `Level.UpdateVisibility` method in order to
9
+ * make the changes immediately visible. Default is true.
10
+ */
11
+ export declare function addRoomDisplayFlag(roomGridIndex: int | undefined, displayFlag: DisplayFlag, updateVisibility?: boolean): void;
2
12
  /**
3
13
  * Helper function to set the value of `DisplayFlag` for every room on the floor to 0.
4
14
  *
@@ -33,11 +43,19 @@ export declare function setFloorDisplayFlags(displayFlagsMap: Map<int, BitFlags<
33
43
  * Helper function to set a particular room's minimap display flags (e.g. whether or not it is
34
44
  * visible and so on).
35
45
  *
36
- * You must call the `Level.UpdateVisibility` method after using this function for the changes to
37
- * take effect.
38
- *
39
46
  * @param roomGridIndex Set to undefined to use the current room index.
40
47
  * @param displayFlags The bit flags value to set. (See the `DisplayFlag` enum.)
48
+ * @param updateVisibility Optional. Whether to call the `Level.UpdateVisibility` method in order to
49
+ * make the changes immediately visible. Default is true.
50
+ */
51
+ export declare function setRoomDisplayFlags(roomGridIndex: int | undefined, displayFlags: BitFlags<DisplayFlag>, updateVisibility?: boolean): void;
52
+ /**
53
+ * Helper function to make a single room visible in a similar way to how the Compass makes a Boss
54
+ * Room visible (e.g. by adding `DisplayFlag.SHOW_ICON`).
55
+ *
56
+ * @param roomGridIndex Set to undefined to use the current room index.
57
+ * @param updateVisibility Optional. Whether to call the `Level.UpdateVisibility` method in order to
58
+ * make the changes immediately visible. Default is true.
41
59
  */
42
- export declare function setRoomDisplayFlags(roomGridIndex: int | undefined, displayFlags: BitFlags<DisplayFlag>): void;
60
+ export declare function setRoomVisible(roomGridIndex: int | undefined, updateVisibility?: boolean): void;
43
61
  //# sourceMappingURL=minimap.d.ts.map
@@ -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;AAK5E;;;;;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;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,eAAe,EAAE,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC,GAC/C,IAAI,CAgBN;AAED,gDAAgD;AAChD,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC,GAC/C,IAAI,CAEN;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,GAAG,GAAG,SAAS,EAC9B,YAAY,EAAE,QAAQ,CAAC,WAAW,CAAC,GAClC,IAAI,CAGN"}
1
+ {"version":3,"file":"minimap.d.ts","sourceRoot":"","sources":["../../src/functions/minimap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAmB,MAAM,8BAA8B,CAAC;AAM5E;;;;;;;;GAQG;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;;;;;;;GAOG;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"}
@@ -4,24 +4,72 @@ local __TS__New = ____lualib.__TS__New
4
4
  local __TS__Iterator = ____lualib.__TS__Iterator
5
5
  local ____exports = {}
6
6
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
7
+ local DisplayFlag = ____isaac_2Dtypescript_2Ddefinitions.DisplayFlag
7
8
  local DisplayFlagZero = ____isaac_2Dtypescript_2Ddefinitions.DisplayFlagZero
8
9
  local ____cachedClasses = require("core.cachedClasses")
9
10
  local game = ____cachedClasses.game
11
+ local ____flag = require("functions.flag")
12
+ local addFlag = ____flag.addFlag
10
13
  local ____roomData = require("functions.roomData")
11
14
  local getRoomDescriptor = ____roomData.getRoomDescriptor
15
+ local getRoomGridIndex = ____roomData.getRoomGridIndex
12
16
  local ____rooms = require("functions.rooms")
13
17
  local getRoomsInsideGrid = ____rooms.getRoomsInsideGrid
14
18
  --- Helper function to set a particular room's minimap display flags (e.g. whether or not it is
15
19
  -- visible and so on).
16
20
  --
17
- -- You must call the `Level.UpdateVisibility` method after using this function for the changes to
18
- -- take effect.
19
- --
20
21
  -- @param roomGridIndex Set to undefined to use the current room index.
21
22
  -- @param displayFlags The bit flags value to set. (See the `DisplayFlag` enum.)
22
- function ____exports.setRoomDisplayFlags(self, roomGridIndex, displayFlags)
23
- local roomDescriptor = getRoomDescriptor(nil, roomGridIndex)
24
- roomDescriptor.DisplayFlags = displayFlags
23
+ -- @param updateVisibility Optional. Whether to call the `Level.UpdateVisibility` method in order to
24
+ -- make the changes immediately visible. Default is true.
25
+ function ____exports.setRoomDisplayFlags(self, roomGridIndex, displayFlags, updateVisibility)
26
+ if updateVisibility == nil then
27
+ updateVisibility = true
28
+ end
29
+ if MinimapAPI == nil then
30
+ local roomDescriptor = getRoomDescriptor(nil, roomGridIndex)
31
+ roomDescriptor.DisplayFlags = displayFlags
32
+ else
33
+ if roomGridIndex == nil then
34
+ roomGridIndex = getRoomGridIndex(nil)
35
+ end
36
+ local roomDescriptor = MinimapAPI:GetRoomByIdx(roomGridIndex)
37
+ if roomDescriptor ~= nil then
38
+ roomDescriptor.DisplayFlags = displayFlags
39
+ end
40
+ end
41
+ if updateVisibility then
42
+ local level = game:GetLevel()
43
+ level:UpdateVisibility()
44
+ end
45
+ end
46
+ --- Helper function to add a `DisplayFlag` to a particular room's minimap display flags (e.g. whether
47
+ -- or not it is visible and so on).
48
+ --
49
+ -- @param roomGridIndex Set to undefined to use the current room index.
50
+ -- @param displayFlag The `DisplayFlag` to set. (See the `DisplayFlag` enum.)
51
+ -- @param updateVisibility Optional. Whether to call the `Level.UpdateVisibility` method in order to
52
+ -- make the changes immediately visible. Default is true.
53
+ function ____exports.addRoomDisplayFlag(self, roomGridIndex, displayFlag, updateVisibility)
54
+ if updateVisibility == nil then
55
+ updateVisibility = true
56
+ end
57
+ if MinimapAPI == nil then
58
+ local roomDescriptor = getRoomDescriptor(nil, roomGridIndex)
59
+ roomDescriptor.DisplayFlags = addFlag(nil, roomDescriptor.DisplayFlags, displayFlag)
60
+ else
61
+ if roomGridIndex == nil then
62
+ roomGridIndex = getRoomGridIndex(nil)
63
+ end
64
+ local roomDescriptor = MinimapAPI:GetRoomByIdx(roomGridIndex)
65
+ if roomDescriptor ~= nil then
66
+ roomDescriptor.DisplayFlags = addFlag(nil, roomDescriptor.DisplayFlags, displayFlag)
67
+ end
68
+ end
69
+ if updateVisibility then
70
+ local level = game:GetLevel()
71
+ level:UpdateVisibility()
72
+ end
25
73
  end
26
74
  --- Helper function to set the value of `DisplayFlag` for every room on the floor to 0.
27
75
  --
@@ -64,7 +112,7 @@ function ____exports.setDisplayFlags(self, displayFlagsMap)
64
112
  local roomGridIndex = ____value[1]
65
113
  local displayFlags = ____value[2]
66
114
  if MinimapAPI == nil then
67
- ____exports.setRoomDisplayFlags(nil, roomGridIndex, displayFlags)
115
+ ____exports.setRoomDisplayFlags(nil, roomGridIndex, displayFlags, false)
68
116
  else
69
117
  local roomDescriptor = MinimapAPI:GetRoomByIdx(roomGridIndex)
70
118
  if roomDescriptor ~= nil then
@@ -78,4 +126,16 @@ end
78
126
  function ____exports.setFloorDisplayFlags(self, displayFlagsMap)
79
127
  ____exports.setDisplayFlags(nil, displayFlagsMap)
80
128
  end
129
+ --- Helper function to make a single room visible in a similar way to how the Compass makes a Boss
130
+ -- Room visible (e.g. by adding `DisplayFlag.SHOW_ICON`).
131
+ --
132
+ -- @param roomGridIndex Set to undefined to use the current room index.
133
+ -- @param updateVisibility Optional. Whether to call the `Level.UpdateVisibility` method in order to
134
+ -- make the changes immediately visible. Default is true.
135
+ function ____exports.setRoomVisible(self, roomGridIndex, updateVisibility)
136
+ if updateVisibility == nil then
137
+ updateVisibility = true
138
+ end
139
+ ____exports.addRoomDisplayFlag(nil, roomGridIndex, DisplayFlag.SHOW_ICON, updateVisibility)
140
+ end
81
141
  return ____exports
package/dist/index.d.ts CHANGED
@@ -287,6 +287,17 @@ export declare function addRoomClearCharges(bigRoomDoubleCharge?: boolean): void
287
287
  */
288
288
  export declare function addRoomClearChargeToSlot(player: EntityPlayer, activeSlot: ActiveSlot, bigRoomDoubleCharge?: boolean, playSoundEffect?: boolean): void;
289
289
 
290
+ /**
291
+ * Helper function to add a `DisplayFlag` to a particular room's minimap display flags (e.g. whether
292
+ * or not it is visible and so on).
293
+ *
294
+ * @param roomGridIndex Set to undefined to use the current room index.
295
+ * @param displayFlag The `DisplayFlag` to set. (See the `DisplayFlag` enum.)
296
+ * @param updateVisibility Optional. Whether to call the `Level.UpdateVisibility` method in order to
297
+ * make the changes immediately visible. Default is true.
298
+ */
299
+ export declare function addRoomDisplayFlag(roomGridIndex: int | undefined, displayFlag: DisplayFlag, updateVisibility?: boolean): void;
300
+
290
301
  /**
291
302
  * Helper function to add all of the values in one set to another set. The first set passed will be
292
303
  * modified in place.
@@ -10728,13 +10739,12 @@ export declare function setRoomData(roomGridIndex: int, roomData: Readonly<RoomC
10728
10739
  * Helper function to set a particular room's minimap display flags (e.g. whether or not it is
10729
10740
  * visible and so on).
10730
10741
  *
10731
- * You must call the `Level.UpdateVisibility` method after using this function for the changes to
10732
- * take effect.
10733
- *
10734
10742
  * @param roomGridIndex Set to undefined to use the current room index.
10735
10743
  * @param displayFlags The bit flags value to set. (See the `DisplayFlag` enum.)
10744
+ * @param updateVisibility Optional. Whether to call the `Level.UpdateVisibility` method in order to
10745
+ * make the changes immediately visible. Default is true.
10736
10746
  */
10737
- export declare function setRoomDisplayFlags(roomGridIndex: int | undefined, displayFlags: BitFlags<DisplayFlag>): void;
10747
+ export declare function setRoomDisplayFlags(roomGridIndex: int | undefined, displayFlags: BitFlags<DisplayFlag>, updateVisibility?: boolean): void;
10738
10748
 
10739
10749
  /**
10740
10750
  * Helper function to emulate what happens when you bomb an Angel Statue or push a Reward Plate that
@@ -10742,6 +10752,16 @@ export declare function setRoomDisplayFlags(roomGridIndex: int | undefined, disp
10742
10752
  */
10743
10753
  export declare function setRoomUncleared(): void;
10744
10754
 
10755
+ /**
10756
+ * Helper function to make a single room visible in a similar way to how the Compass makes a Boss
10757
+ * Room visible (e.g. by adding `DisplayFlag.SHOW_ICON`).
10758
+ *
10759
+ * @param roomGridIndex Set to undefined to use the current room index.
10760
+ * @param updateVisibility Optional. Whether to call the `Level.UpdateVisibility` method in order to
10761
+ * make the changes immediately visible. Default is true.
10762
+ */
10763
+ export declare function setRoomVisible(roomGridIndex: int | undefined, updateVisibility?: boolean): void;
10764
+
10745
10765
  /** Helper function to set a seed to an RNG object using Blade's recommended shift index. */
10746
10766
  export declare function setSeed(rng: RNG, seed: Seed): void;
10747
10767
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "9.15.0",
3
+ "version": "9.16.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -1,8 +1,48 @@
1
1
  import { DisplayFlag, DisplayFlagZero } from "isaac-typescript-definitions";
2
2
  import { game } from "../core/cachedClasses";
3
- import { getRoomDescriptor } from "./roomData";
3
+ import { addFlag } from "./flag";
4
+ import { getRoomDescriptor, getRoomGridIndex } from "./roomData";
4
5
  import { getRoomsInsideGrid } from "./rooms";
5
6
 
7
+ /**
8
+ * Helper function to add a `DisplayFlag` to a particular room's minimap display flags (e.g. whether
9
+ * or not it is visible and so on).
10
+ *
11
+ * @param roomGridIndex Set to undefined to use the current room index.
12
+ * @param displayFlag The `DisplayFlag` to set. (See the `DisplayFlag` enum.)
13
+ * @param updateVisibility Optional. Whether to call the `Level.UpdateVisibility` method in order to
14
+ * make the changes immediately visible. Default is true.
15
+ */
16
+ export function addRoomDisplayFlag(
17
+ roomGridIndex: int | undefined,
18
+ displayFlag: DisplayFlag,
19
+ updateVisibility = true,
20
+ ): void {
21
+ if (MinimapAPI === undefined) {
22
+ const roomDescriptor = getRoomDescriptor(roomGridIndex);
23
+ roomDescriptor.DisplayFlags = addFlag(
24
+ roomDescriptor.DisplayFlags,
25
+ displayFlag,
26
+ );
27
+ } else {
28
+ if (roomGridIndex === undefined) {
29
+ roomGridIndex = getRoomGridIndex();
30
+ }
31
+ const roomDescriptor = MinimapAPI.GetRoomByIdx(roomGridIndex);
32
+ if (roomDescriptor !== undefined) {
33
+ roomDescriptor.DisplayFlags = addFlag(
34
+ roomDescriptor.DisplayFlags,
35
+ displayFlag,
36
+ );
37
+ }
38
+ }
39
+
40
+ if (updateVisibility) {
41
+ const level = game.GetLevel();
42
+ level.UpdateVisibility();
43
+ }
44
+ }
45
+
6
46
  /**
7
47
  * Helper function to set the value of `DisplayFlag` for every room on the floor to 0.
8
48
  *
@@ -66,7 +106,8 @@ export function setDisplayFlags(
66
106
 
67
107
  for (const [roomGridIndex, displayFlags] of displayFlagsMap.entries()) {
68
108
  if (MinimapAPI === undefined) {
69
- setRoomDisplayFlags(roomGridIndex, displayFlags);
109
+ // We pass false to the `updateVisibility` argument as a small optimization.
110
+ setRoomDisplayFlags(roomGridIndex, displayFlags, false);
70
111
  } else {
71
112
  const roomDescriptor = MinimapAPI.GetRoomByIdx(roomGridIndex);
72
113
  if (roomDescriptor !== undefined) {
@@ -90,16 +131,46 @@ export function setFloorDisplayFlags(
90
131
  * Helper function to set a particular room's minimap display flags (e.g. whether or not it is
91
132
  * visible and so on).
92
133
  *
93
- * You must call the `Level.UpdateVisibility` method after using this function for the changes to
94
- * take effect.
95
- *
96
134
  * @param roomGridIndex Set to undefined to use the current room index.
97
135
  * @param displayFlags The bit flags value to set. (See the `DisplayFlag` enum.)
136
+ * @param updateVisibility Optional. Whether to call the `Level.UpdateVisibility` method in order to
137
+ * make the changes immediately visible. Default is true.
98
138
  */
99
139
  export function setRoomDisplayFlags(
100
140
  roomGridIndex: int | undefined,
101
141
  displayFlags: BitFlags<DisplayFlag>,
142
+ updateVisibility = true,
102
143
  ): void {
103
- const roomDescriptor = getRoomDescriptor(roomGridIndex);
104
- roomDescriptor.DisplayFlags = displayFlags;
144
+ if (MinimapAPI === undefined) {
145
+ const roomDescriptor = getRoomDescriptor(roomGridIndex);
146
+ roomDescriptor.DisplayFlags = displayFlags;
147
+ } else {
148
+ if (roomGridIndex === undefined) {
149
+ roomGridIndex = getRoomGridIndex();
150
+ }
151
+ const roomDescriptor = MinimapAPI.GetRoomByIdx(roomGridIndex);
152
+ if (roomDescriptor !== undefined) {
153
+ roomDescriptor.DisplayFlags = displayFlags;
154
+ }
155
+ }
156
+
157
+ if (updateVisibility) {
158
+ const level = game.GetLevel();
159
+ level.UpdateVisibility();
160
+ }
161
+ }
162
+
163
+ /**
164
+ * Helper function to make a single room visible in a similar way to how the Compass makes a Boss
165
+ * Room visible (e.g. by adding `DisplayFlag.SHOW_ICON`).
166
+ *
167
+ * @param roomGridIndex Set to undefined to use the current room index.
168
+ * @param updateVisibility Optional. Whether to call the `Level.UpdateVisibility` method in order to
169
+ * make the changes immediately visible. Default is true.
170
+ */
171
+ export function setRoomVisible(
172
+ roomGridIndex: int | undefined,
173
+ updateVisibility = true,
174
+ ): void {
175
+ addRoomDisplayFlag(roomGridIndex, DisplayFlag.SHOW_ICON, updateVisibility);
105
176
  }