Skip to content

Commit 24c3d0f

Browse files
committed
fix isRepentancePlus
1 parent 7c12da5 commit 24c3d0f

File tree

1 file changed

+10
-20
lines changed
  • packages/isaacscript-common/src/functions

1 file changed

+10
-20
lines changed

packages/isaacscript-common/src/functions/utils.ts

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { game } from "../core/cachedClasses";
12
import { ReadonlySet } from "../types/ReadonlySet";
23
import { getAllPlayers } from "./playerIndex";
34
import { isFunction } from "./types";
@@ -177,8 +178,8 @@ export function isRepentance(): boolean {
177178
'Failed to get the "__class" key of the Sprite metatable.',
178179
);
179180

180-
const getAnimation = classTable.get("GetAnimation");
181-
return isFunction(getAnimation);
181+
const func = classTable.get("GetAnimation");
182+
return isFunction(func);
182183
}
183184

184185
/**
@@ -187,26 +188,15 @@ export function isRepentance(): boolean {
187188
* This function should always be used over the `REPENTANCE_PLUS` constant, since the latter is not
188189
* safe.
189190
*
190-
* Specifically, this function checks for TODO:
191-
* https://bindingofisaacrebirth.fandom.com/wiki/V1.06.J818#Lua_Changes
191+
* Specifically, this function checks for `Room:DamageGridWithSource` method:
192+
* https://bindingofisaacrebirth.wiki.gg/wiki/The_Binding_of_Isaac:_Repentance%2B#Modding_Changes
192193
*/
193194
export function isRepentancePlus(): boolean {
194-
const metatable = getmetatable(Sprite) as LuaMap<string, unknown> | undefined;
195-
assertDefined(
196-
metatable,
197-
"Failed to get the metatable of the Sprite global table.",
198-
);
199-
200-
const classTable = metatable.get("__class") as
201-
| LuaMap<string, unknown>
202-
| undefined;
203-
assertDefined(
204-
classTable,
205-
'Failed to get the "__class" key of the Sprite metatable.',
206-
);
207-
208-
const getAnimation = classTable.get("GetAnimation");
209-
return isFunction(getAnimation);
195+
const room = game.GetRoom();
196+
const metatable = getmetatable(room) as LuaMap<string, unknown> | undefined;
197+
assertDefined(metatable, "Failed to get the metatable of the room class.");
198+
const func = metatable.get("DamageGridWithSource");
199+
return isFunction(func);
210200
}
211201

212202
/**

0 commit comments

Comments
 (0)