isaacscript-common 31.4.0 → 31.5.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.
Files changed (77) hide show
  1. package/dist/index.rollup.d.ts +12 -0
  2. package/dist/isaacscript-common.lua +97 -40
  3. package/dist/src/classes/features/other/debugDisplay/DebugDisplayBomb.d.ts.map +1 -1
  4. package/dist/src/classes/features/other/debugDisplay/DebugDisplayBomb.lua +2 -1
  5. package/dist/src/classes/features/other/debugDisplay/DebugDisplayDoor.d.ts.map +1 -1
  6. package/dist/src/classes/features/other/debugDisplay/DebugDisplayDoor.lua +2 -1
  7. package/dist/src/classes/features/other/debugDisplay/DebugDisplayEffect.d.ts.map +1 -1
  8. package/dist/src/classes/features/other/debugDisplay/DebugDisplayEffect.lua +2 -1
  9. package/dist/src/classes/features/other/debugDisplay/DebugDisplayFamiliar.d.ts.map +1 -1
  10. package/dist/src/classes/features/other/debugDisplay/DebugDisplayFamiliar.lua +2 -1
  11. package/dist/src/classes/features/other/debugDisplay/DebugDisplayKnife.d.ts.map +1 -1
  12. package/dist/src/classes/features/other/debugDisplay/DebugDisplayKnife.lua +2 -1
  13. package/dist/src/classes/features/other/debugDisplay/DebugDisplayLaser.d.ts.map +1 -1
  14. package/dist/src/classes/features/other/debugDisplay/DebugDisplayLaser.lua +2 -1
  15. package/dist/src/classes/features/other/debugDisplay/DebugDisplayNPC.d.ts.map +1 -1
  16. package/dist/src/classes/features/other/debugDisplay/DebugDisplayNPC.lua +2 -1
  17. package/dist/src/classes/features/other/debugDisplay/DebugDisplayPickup.d.ts.map +1 -1
  18. package/dist/src/classes/features/other/debugDisplay/DebugDisplayPickup.lua +2 -1
  19. package/dist/src/classes/features/other/debugDisplay/DebugDisplayPit.d.ts.map +1 -1
  20. package/dist/src/classes/features/other/debugDisplay/DebugDisplayPit.lua +2 -1
  21. package/dist/src/classes/features/other/debugDisplay/DebugDisplayPlayer.d.ts.map +1 -1
  22. package/dist/src/classes/features/other/debugDisplay/DebugDisplayPlayer.lua +2 -1
  23. package/dist/src/classes/features/other/debugDisplay/DebugDisplayPoop.d.ts.map +1 -1
  24. package/dist/src/classes/features/other/debugDisplay/DebugDisplayPoop.lua +2 -1
  25. package/dist/src/classes/features/other/debugDisplay/DebugDisplayPressurePlate.d.ts.map +1 -1
  26. package/dist/src/classes/features/other/debugDisplay/DebugDisplayPressurePlate.lua +2 -1
  27. package/dist/src/classes/features/other/debugDisplay/DebugDisplayProjectile.d.ts.map +1 -1
  28. package/dist/src/classes/features/other/debugDisplay/DebugDisplayProjectile.lua +2 -1
  29. package/dist/src/classes/features/other/debugDisplay/DebugDisplayRock.d.ts.map +1 -1
  30. package/dist/src/classes/features/other/debugDisplay/DebugDisplayRock.lua +2 -1
  31. package/dist/src/classes/features/other/debugDisplay/DebugDisplaySlot.d.ts.map +1 -1
  32. package/dist/src/classes/features/other/debugDisplay/DebugDisplaySlot.lua +2 -1
  33. package/dist/src/classes/features/other/debugDisplay/DebugDisplaySpikes.d.ts.map +1 -1
  34. package/dist/src/classes/features/other/debugDisplay/DebugDisplaySpikes.lua +2 -1
  35. package/dist/src/classes/features/other/debugDisplay/DebugDisplayTNT.d.ts.map +1 -1
  36. package/dist/src/classes/features/other/debugDisplay/DebugDisplayTNT.lua +2 -1
  37. package/dist/src/classes/features/other/debugDisplay/DebugDisplayTear.d.ts.map +1 -1
  38. package/dist/src/classes/features/other/debugDisplay/DebugDisplayTear.lua +2 -1
  39. package/dist/src/classes/features/other/debugDisplay/utils.d.ts +0 -1
  40. package/dist/src/classes/features/other/debugDisplay/utils.d.ts.map +1 -1
  41. package/dist/src/classes/features/other/debugDisplay/utils.lua +0 -17
  42. package/dist/src/functions/render.d.ts +16 -0
  43. package/dist/src/functions/render.d.ts.map +1 -0
  44. package/dist/src/functions/render.lua +50 -0
  45. package/dist/src/functions/utils.d.ts +0 -10
  46. package/dist/src/functions/utils.d.ts.map +1 -1
  47. package/dist/src/functions/utils.lua +0 -16
  48. package/dist/src/index.d.ts +2 -0
  49. package/dist/src/index.d.ts.map +1 -1
  50. package/dist/src/index.lua +8 -0
  51. package/dist/src/types/Expand.d.ts +8 -0
  52. package/dist/src/types/Expand.d.ts.map +1 -0
  53. package/dist/src/types/Expand.lua +2 -0
  54. package/package.json +1 -1
  55. package/src/classes/features/other/debugDisplay/DebugDisplayBomb.ts +2 -1
  56. package/src/classes/features/other/debugDisplay/DebugDisplayDoor.ts +2 -1
  57. package/src/classes/features/other/debugDisplay/DebugDisplayEffect.ts +2 -1
  58. package/src/classes/features/other/debugDisplay/DebugDisplayFamiliar.ts +2 -1
  59. package/src/classes/features/other/debugDisplay/DebugDisplayKnife.ts +2 -1
  60. package/src/classes/features/other/debugDisplay/DebugDisplayLaser.ts +2 -1
  61. package/src/classes/features/other/debugDisplay/DebugDisplayNPC.ts +2 -1
  62. package/src/classes/features/other/debugDisplay/DebugDisplayPickup.ts +2 -1
  63. package/src/classes/features/other/debugDisplay/DebugDisplayPit.ts +2 -1
  64. package/src/classes/features/other/debugDisplay/DebugDisplayPlayer.ts +2 -1
  65. package/src/classes/features/other/debugDisplay/DebugDisplayPoop.ts +2 -1
  66. package/src/classes/features/other/debugDisplay/DebugDisplayPressurePlate.ts +2 -1
  67. package/src/classes/features/other/debugDisplay/DebugDisplayProjectile.ts +2 -1
  68. package/src/classes/features/other/debugDisplay/DebugDisplayRock.ts +2 -1
  69. package/src/classes/features/other/debugDisplay/DebugDisplaySlot.ts +2 -1
  70. package/src/classes/features/other/debugDisplay/DebugDisplaySpikes.ts +2 -1
  71. package/src/classes/features/other/debugDisplay/DebugDisplayTNT.ts +2 -1
  72. package/src/classes/features/other/debugDisplay/DebugDisplayTear.ts +2 -1
  73. package/src/classes/features/other/debugDisplay/utils.ts +0 -13
  74. package/src/functions/render.ts +53 -0
  75. package/src/functions/utils.ts +0 -17
  76. package/src/index.ts +2 -0
  77. package/src/types/Expand.ts +5 -0
@@ -1,6 +1,5 @@
1
1
  import { getEntityID } from "../../../../functions/entities";
2
2
  import { getGridEntityID } from "../../../../functions/gridEntities";
3
- import { isReflectionRender } from "../../../../functions/utils";
4
3
 
5
4
  export function defaultEntityDisplayCallback(entity: Entity): string {
6
5
  return getEntityID(entity);
@@ -11,15 +10,3 @@ export function defaultGridEntityDisplayCallback(
11
10
  ): string {
12
11
  return getGridEntityID(gridEntity);
13
12
  }
14
-
15
- export function renderTextOnEntity(
16
- entity: Entity | GridEntity,
17
- text: string,
18
- ): void {
19
- if (isReflectionRender()) {
20
- return;
21
- }
22
-
23
- const position = Isaac.WorldToScreen(entity.Position);
24
- Isaac.RenderText(text, position.X, position.Y, 1, 1, 1, 1);
25
- }
@@ -0,0 +1,53 @@
1
+ import { RenderMode } from "isaac-typescript-definitions";
2
+ import { game } from "../core/cachedClasses";
3
+
4
+ /**
5
+ * Helper function to see if the current render callback is rendering a water reflection.
6
+ *
7
+ * When the player is in a room with water, things will be rendered twice: once for the normal
8
+ * rendering, and once for the reflecting rendering. Thus, any mod code in a render callback will
9
+ * run twice per frame in these situations, which may be unexpected or cause bugs.
10
+ *
11
+ * This function is typically used to early return from a render function if it returns true.
12
+ */
13
+ export function isReflectionRender(): boolean {
14
+ const room = game.GetRoom();
15
+ const renderMode = room.GetRenderMode();
16
+ return renderMode === RenderMode.WATER_REFLECT;
17
+ }
18
+
19
+ export function renderScaledTextOnEntity(
20
+ entity: Entity | GridEntity,
21
+ text: string,
22
+ scaleX: float,
23
+ scaleY: float,
24
+ ): void {
25
+ if (isReflectionRender()) {
26
+ return;
27
+ }
28
+
29
+ const position = Isaac.WorldToScreen(entity.Position);
30
+ Isaac.RenderScaledText(
31
+ text,
32
+ position.X,
33
+ position.Y,
34
+ scaleX,
35
+ scaleY,
36
+ 1,
37
+ 1,
38
+ 1,
39
+ 1,
40
+ );
41
+ }
42
+
43
+ export function renderTextOnEntity(
44
+ entity: Entity | GridEntity,
45
+ text: string,
46
+ ): void {
47
+ if (isReflectionRender()) {
48
+ return;
49
+ }
50
+
51
+ const position = Isaac.WorldToScreen(entity.Position);
52
+ Isaac.RenderText(text, position.X, position.Y, 1, 1, 1, 1);
53
+ }
@@ -1,5 +1,3 @@
1
- import { RenderMode } from "isaac-typescript-definitions";
2
- import { game } from "../core/cachedClasses";
3
1
  import { ReadonlySet } from "../types/ReadonlySet";
4
2
  import { getAllPlayers } from "./playerIndex";
5
3
  import { isFunction } from "./types";
@@ -123,21 +121,6 @@ export function isMultiplayer(): boolean {
123
121
  return controllerIndexesSet.size > 1;
124
122
  }
125
123
 
126
- /**
127
- * Helper function to see if the current render callback is rendering a water reflection.
128
- *
129
- * When the player is in a room with water, things will be rendered twice: once for the normal
130
- * rendering, and once for the reflecting rendering. Thus, any mod code in a render callback will
131
- * run twice per frame in these situations, which may be unexpected or cause bugs.
132
- *
133
- * This function is typically used to early return from a render function if it returns true.
134
- */
135
- export function isReflectionRender(): boolean {
136
- const room = game.GetRoom();
137
- const renderMode = room.GetRenderMode();
138
- return renderMode === RenderMode.WATER_REFLECT;
139
- }
140
-
141
124
  /**
142
125
  * Helper function to check if the player is using Afterbirth+ or Repentance.
143
126
  *
package/src/index.ts CHANGED
@@ -95,6 +95,7 @@ export * from "./functions/pressurePlate";
95
95
  export * from "./functions/projectiles";
96
96
  export * from "./functions/random";
97
97
  export * from "./functions/readOnly";
98
+ export * from "./functions/render";
98
99
  export * from "./functions/revive";
99
100
  export * from "./functions/rng";
100
101
  export * from "./functions/rockAlt";
@@ -157,6 +158,7 @@ export * from "./types/AnyGridEntity";
157
158
  export * from "./types/ConversionHeartSubType";
158
159
  export * from "./types/Decrement";
159
160
  export * from "./types/EntityID";
161
+ export * from "./types/Expand";
160
162
  export * from "./types/FunctionTuple";
161
163
  export * from "./types/GridEntityID";
162
164
  export * from "./types/HasFunction";
@@ -0,0 +1,5 @@
1
+ /**
2
+ * From:
3
+ * https://stackoverflow.com/questions/57683303/how-can-i-see-the-full-expanded-contract-of-a-typescript-type
4
+ */
5
+ export type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;