Skip to content

Commit 5a41c85

Browse files
committed
fix(common): custom trapdoors not opening
1 parent cb0d86a commit 5a41c85

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/isaacscript-common/src/classes/features/other/CustomTrapdoors.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ import { CUSTOM_FLOOR_STAGE } from "./customStages/constants";
5959

6060
const DEBUG = false as boolean;
6161

62-
/** This also applies to crawl spaces. The value was determined through trial and error. */
62+
/**
63+
* This also applies to crawl spaces. The value was determined through trial and error to match
64+
* vanilla behavior.
65+
*/
6366
const TRAPDOOR_OPEN_DISTANCE = 60;
6467

6568
const TRAPDOOR_OPEN_DISTANCE_AFTER_BOSS = TRAPDOOR_OPEN_DISTANCE * 2.5;
@@ -415,6 +418,15 @@ export class CustomTrapdoors extends Feature {
415418
): void {
416419
/** By default, trapdoors will never close if they are already open. */
417420
if (trapdoorDescription.open) {
421+
// Sometimes, the `sprite.Play(TrapdoorAnimation.OPEN_ANIMATION, true)` function does not take
422+
// effect. Check for this case.
423+
const sprite = gridEntity.GetSprite();
424+
const animation = sprite.GetAnimation();
425+
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
426+
if (animation === TrapdoorAnimation.CLOSED) {
427+
// Try it again.
428+
sprite.Play(TrapdoorAnimation.OPEN_ANIMATION, true);
429+
}
418430
return;
419431
}
420432

0 commit comments

Comments
 (0)