MC_survival/source.d.ts

100 lines
1.8 KiB
TypeScript
Raw Permalink Normal View History

2025-01-14 12:27:52 +08:00
/**
*
*/
type Cls =
| 'autotile'
| 'animates'
| 'enemys'
| 'items'
| 'npcs'
| 'terrains'
| 'enemy48'
| 'npc48'
| 'tileset';
/**
*
*/
type AnimatableCls = Exclude<Cls, 'items' | 'terrains' | 'tileset'>;
/**
*
*/
type ItemCls = 'tools' | 'items' | 'equips' | 'constants';
/**
* id
*/
type AllIds = keyof IdToNumber;
/**
*
*/
type AllNumbers = keyof NumberToId | 0;
/**
* id
*/
type AllIdsOf<T extends Cls> = keyof {
[P in keyof IdToCls as IdToCls[P] extends T ? P : never]: P;
};
/**
* id
*/
type ItemIdOf<T extends ItemCls> = keyof {
[P in keyof ItemDeclaration as ItemDeclaration[P] extends T ? P : never]: P;
};
/**
*
*/
type ItemClsOf<T extends AllIdsOf<'items'>> = ItemDeclaration[T];
/**
*
*/
type ClsOf<T extends AllIds> = IdToCls[T];
/**
*
*/
type AllNumbersOf<T extends Cls> = IdToNumber[AllIdsOf<T>];
/**
*
*/
type NameMapIn<T extends string> = keyof {
[P in keyof NameMap as NameMap[P] extends T ? P : never]: NameMap[P];
};
/**
* id
*/
type EnemyIds = AllIdsOf<'enemys' | 'enemy48'>;
/**
*
*/
interface FrameNumbers {
autotile: 4;
animates: 4;
enemys: 2;
items: 1;
npcs: 2;
terrains: 1;
enemy48: 4;
npc48: 4;
tileset: 1;
}
/**
*
*/
type FrameOf<T extends Cls> = FrameNumbers[T];
/**
*
*/
type SourceIds = ImageIds | AnimationIds | SoundIds | BgmIds | FontIds;