-
Notifications
You must be signed in to change notification settings - Fork 21
/
EntityPartition.ts
49 lines (40 loc) · 1.23 KB
/
EntityPartition.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
/**
* This is represented as an object instead of an enum due to limitations with TypeScript enums. (We
* want this type to be a child of the `BitFlag` type.)
*
* @enum
* @notExported
* @rename EntityPartition
*/
const EntityPartitionInternal = {
/** 1 << 0 (1) */
FAMILIAR: 1 << 0,
/** 1 << 1 (2) */
BULLET: 1 << 1,
/** 1 << 2 (4) */
TEAR: 1 << 2,
/** 1 << 3 (8) */
ENEMY: 1 << 3,
/** 1 << 4 (16) */
PICKUP: 1 << 4,
/** 1 << 5 (32) */
PLAYER: 1 << 5,
/**
* 1 << 6 (64)
*
* @deprecated The `Isaac.FindInRadius` method will only work with entities that have collision.
* Since effects do not have collision, they will never be returned. Thus, this enum
* is useless.
*/
// eslint-disable-next-line deprecation/deprecation
EFFECT: 1 << 6,
} as const;
type EntityPartitionValue = BitFlag & {
readonly __entityPartitionBrand: symbol;
};
type EntityPartitionType = {
readonly [K in keyof typeof EntityPartitionInternal]: EntityPartitionValue;
};
export const EntityPartition = EntityPartitionInternal as EntityPartitionType;
export type EntityPartition = EntityPartitionType[keyof EntityPartitionType];
export const EntityPartitionZero = 0 as BitFlags<EntityPartition>;