isaacscript-common 31.3.1 → 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.
- package/dist/index.rollup.d.ts +29 -0
- package/dist/isaacscript-common.lua +101 -40
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayBomb.d.ts.map +1 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayBomb.lua +2 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayDoor.d.ts.map +1 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayDoor.lua +2 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayEffect.d.ts.map +1 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayEffect.lua +2 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayFamiliar.d.ts.map +1 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayFamiliar.lua +2 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayKnife.d.ts.map +1 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayKnife.lua +2 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayLaser.d.ts.map +1 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayLaser.lua +2 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayNPC.d.ts.map +1 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayNPC.lua +2 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayPickup.d.ts.map +1 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayPickup.lua +2 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayPit.d.ts.map +1 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayPit.lua +2 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayPlayer.d.ts.map +1 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayPlayer.lua +2 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayPoop.d.ts.map +1 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayPoop.lua +2 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayPressurePlate.d.ts.map +1 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayPressurePlate.lua +2 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayProjectile.d.ts.map +1 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayProjectile.lua +2 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayRock.d.ts.map +1 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayRock.lua +2 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplaySlot.d.ts.map +1 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplaySlot.lua +2 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplaySpikes.d.ts.map +1 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplaySpikes.lua +2 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayTNT.d.ts.map +1 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayTNT.lua +2 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayTear.d.ts.map +1 -1
- package/dist/src/classes/features/other/debugDisplay/DebugDisplayTear.lua +2 -1
- package/dist/src/classes/features/other/debugDisplay/utils.d.ts +0 -1
- package/dist/src/classes/features/other/debugDisplay/utils.d.ts.map +1 -1
- package/dist/src/classes/features/other/debugDisplay/utils.lua +0 -17
- package/dist/src/functions/render.d.ts +16 -0
- package/dist/src/functions/render.d.ts.map +1 -0
- package/dist/src/functions/render.lua +50 -0
- package/dist/src/functions/utils.d.ts +0 -10
- package/dist/src/functions/utils.d.ts.map +1 -1
- package/dist/src/functions/utils.lua +0 -16
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.lua +8 -0
- package/dist/src/types/AddSubtract.d.ts +15 -0
- package/dist/src/types/AddSubtract.d.ts.map +1 -0
- package/dist/src/types/AddSubtract.lua +2 -0
- package/dist/src/types/Expand.d.ts +8 -0
- package/dist/src/types/Expand.d.ts.map +1 -0
- package/dist/src/types/Expand.lua +2 -0
- package/package.json +1 -1
- package/src/classes/features/other/debugDisplay/DebugDisplayBomb.ts +2 -1
- package/src/classes/features/other/debugDisplay/DebugDisplayDoor.ts +2 -1
- package/src/classes/features/other/debugDisplay/DebugDisplayEffect.ts +2 -1
- package/src/classes/features/other/debugDisplay/DebugDisplayFamiliar.ts +2 -1
- package/src/classes/features/other/debugDisplay/DebugDisplayKnife.ts +2 -1
- package/src/classes/features/other/debugDisplay/DebugDisplayLaser.ts +2 -1
- package/src/classes/features/other/debugDisplay/DebugDisplayNPC.ts +2 -1
- package/src/classes/features/other/debugDisplay/DebugDisplayPickup.ts +2 -1
- package/src/classes/features/other/debugDisplay/DebugDisplayPit.ts +2 -1
- package/src/classes/features/other/debugDisplay/DebugDisplayPlayer.ts +2 -1
- package/src/classes/features/other/debugDisplay/DebugDisplayPoop.ts +2 -1
- package/src/classes/features/other/debugDisplay/DebugDisplayPressurePlate.ts +2 -1
- package/src/classes/features/other/debugDisplay/DebugDisplayProjectile.ts +2 -1
- package/src/classes/features/other/debugDisplay/DebugDisplayRock.ts +2 -1
- package/src/classes/features/other/debugDisplay/DebugDisplaySlot.ts +2 -1
- package/src/classes/features/other/debugDisplay/DebugDisplaySpikes.ts +2 -1
- package/src/classes/features/other/debugDisplay/DebugDisplayTNT.ts +2 -1
- package/src/classes/features/other/debugDisplay/DebugDisplayTear.ts +2 -1
- package/src/classes/features/other/debugDisplay/utils.ts +0 -13
- package/src/functions/render.ts +53 -0
- package/src/functions/utils.ts +0 -17
- package/src/index.ts +3 -0
- package/src/types/AddSubtract.ts +19 -0
- package/src/types/Expand.ts +5 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ModCallback } from "isaac-typescript-definitions";
|
|
2
|
+
import { renderTextOnEntity } from "../../../../functions/render";
|
|
2
3
|
import { Feature } from "../../../private/Feature";
|
|
3
|
-
import { defaultEntityDisplayCallback
|
|
4
|
+
import { defaultEntityDisplayCallback } from "./utils";
|
|
4
5
|
|
|
5
6
|
export class DebugDisplayProjectile extends Feature {
|
|
6
7
|
public textCallback: (projectile: EntityProjectile) => string =
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ModCallbackCustom } from "../../../../enums/ModCallbackCustom";
|
|
2
|
+
import { renderTextOnEntity } from "../../../../functions/render";
|
|
2
3
|
import { Feature } from "../../../private/Feature";
|
|
3
|
-
import { defaultGridEntityDisplayCallback
|
|
4
|
+
import { defaultGridEntityDisplayCallback } from "./utils";
|
|
4
5
|
|
|
5
6
|
export class DebugDisplayRock extends Feature {
|
|
6
7
|
public textCallback: (rock: GridEntityRock) => string =
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ModCallbackCustom } from "../../../../enums/ModCallbackCustom";
|
|
2
|
+
import { renderTextOnEntity } from "../../../../functions/render";
|
|
2
3
|
import { Feature } from "../../../private/Feature";
|
|
3
|
-
import { defaultEntityDisplayCallback
|
|
4
|
+
import { defaultEntityDisplayCallback } from "./utils";
|
|
4
5
|
|
|
5
6
|
export class DebugDisplaySlot extends Feature {
|
|
6
7
|
public textCallback: (slot: EntitySlot) => string =
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ModCallbackCustom } from "../../../../enums/ModCallbackCustom";
|
|
2
|
+
import { renderTextOnEntity } from "../../../../functions/render";
|
|
2
3
|
import { Feature } from "../../../private/Feature";
|
|
3
|
-
import { defaultGridEntityDisplayCallback
|
|
4
|
+
import { defaultGridEntityDisplayCallback } from "./utils";
|
|
4
5
|
|
|
5
6
|
export class DebugDisplaySpikes extends Feature {
|
|
6
7
|
public textCallback: (spikes: GridEntitySpikes) => string =
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ModCallbackCustom } from "../../../../enums/ModCallbackCustom";
|
|
2
|
+
import { renderTextOnEntity } from "../../../../functions/render";
|
|
2
3
|
import { Feature } from "../../../private/Feature";
|
|
3
|
-
import { defaultGridEntityDisplayCallback
|
|
4
|
+
import { defaultGridEntityDisplayCallback } from "./utils";
|
|
4
5
|
|
|
5
6
|
export class DebugDisplayTNT extends Feature {
|
|
6
7
|
public textCallback: (tnt: GridEntityTNT) => string =
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ModCallback } from "isaac-typescript-definitions";
|
|
2
|
+
import { renderTextOnEntity } from "../../../../functions/render";
|
|
2
3
|
import { Feature } from "../../../private/Feature";
|
|
3
|
-
import { defaultEntityDisplayCallback
|
|
4
|
+
import { defaultEntityDisplayCallback } from "./utils";
|
|
4
5
|
|
|
5
6
|
export class DebugDisplayTear extends Feature {
|
|
6
7
|
public textCallback: (tear: EntityTear) => string =
|
|
@@ -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
|
+
}
|
package/src/functions/utils.ts
CHANGED
|
@@ -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";
|
|
@@ -147,6 +148,7 @@ export * from "./maps/roomNameToTypeMap";
|
|
|
147
148
|
export * from "./maps/transformationNameToPlayerFormMap";
|
|
148
149
|
export * from "./objects/colors";
|
|
149
150
|
export * from "./objects/kColors";
|
|
151
|
+
export * from "./types/AddSubtract";
|
|
150
152
|
export * from "./types/AllButFirst";
|
|
151
153
|
export * from "./types/AllButLast";
|
|
152
154
|
export * from "./types/AnyClass";
|
|
@@ -156,6 +158,7 @@ export * from "./types/AnyGridEntity";
|
|
|
156
158
|
export * from "./types/ConversionHeartSubType";
|
|
157
159
|
export * from "./types/Decrement";
|
|
158
160
|
export * from "./types/EntityID";
|
|
161
|
+
export * from "./types/Expand";
|
|
159
162
|
export * from "./types/FunctionTuple";
|
|
160
163
|
export * from "./types/GridEntityID";
|
|
161
164
|
export * from "./types/HasFunction";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** From: https://gist.github.com/ryandabler/8b4ff4f36aed47bc09acc03174638468 */
|
|
2
|
+
export type Add<A extends number, B extends number> = Length<
|
|
3
|
+
[...BuildTuple<A>, ...BuildTuple<B>]
|
|
4
|
+
>;
|
|
5
|
+
|
|
6
|
+
/** From: https://gist.github.com/ryandabler/8b4ff4f36aed47bc09acc03174638468 */
|
|
7
|
+
export type Subtract<A extends number, B extends number> = A extends A
|
|
8
|
+
? BuildTuple<A> extends [...infer U, ...BuildTuple<B>]
|
|
9
|
+
? Length<U>
|
|
10
|
+
: never
|
|
11
|
+
: never;
|
|
12
|
+
|
|
13
|
+
type BuildTuple<L extends number, T extends unknown[] = []> = T extends {
|
|
14
|
+
length: L;
|
|
15
|
+
}
|
|
16
|
+
? T
|
|
17
|
+
: BuildTuple<L, [...T, unknown]>;
|
|
18
|
+
|
|
19
|
+
type Length<T extends unknown[]> = T extends { length: infer L } ? L : never;
|