-
Notifications
You must be signed in to change notification settings - Fork 21
/
FlyingDetection.ts
64 lines (54 loc) · 1.99 KB
/
FlyingDetection.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { NullItemID } from "isaac-typescript-definitions";
import { Exported } from "../../../decorators";
import { ISCFeature } from "../../../enums/ISCFeature";
import { Feature } from "../../private/Feature";
import type { ModdedElementSets } from "./ModdedElementSets";
const FLYING_NULL_ITEMS = [
NullItemID.REVERSE_SUN, // 66
NullItemID.SPIRIT_SHACKLES_SOUL, // 10
NullItemID.LOST_CURSE, // 112
] as const;
export class FlyingDetection extends Feature {
private readonly moddedElementSets: ModdedElementSets;
/** @internal */
constructor(moddedElementSets: ModdedElementSets) {
super();
this.featuresUsed = [ISCFeature.MODDED_ELEMENT_SETS];
this.moddedElementSets = moddedElementSets;
}
/**
* Helper function to see if the player currently has flying from a temporary effect such as
* Hanged Man, Bat Wing, and so on.
*
* In order to use this function, you must upgrade your mod with `ISCFeature.FLYING_DETECTION`.
*
* @public
*/
@Exported
public hasFlyingTemporaryEffect(player: EntityPlayer): boolean {
const effects = player.GetEffects();
// - We specify true to the `getFlyingCollectibles` function since conditional flying
// collectibles will only grant a temporary effect if their condition is activated.
// - The Hanged Man card gives a Transcendence temporary effect.
// - Pinking Shears gives a Transcendence temporary effect.
const flyingCollectibles =
this.moddedElementSets.getFlyingCollectibleTypes(true);
for (const collectibleType of flyingCollectibles) {
if (effects.HasCollectibleEffect(collectibleType)) {
return true;
}
}
const flyingTrinkets = this.moddedElementSets.getFlyingTrinketTypes();
for (const trinketType of flyingTrinkets) {
if (effects.HasTrinketEffect(trinketType)) {
return true;
}
}
for (const nullItemID of FLYING_NULL_ITEMS) {
if (effects.HasNullEffect(nullItemID)) {
return true;
}
}
return false;
}
}