Files
Genarrative/src/components/npcRenderUtils.ts
T
kdletters 071faa482c 统一 Rust 与 TypeScript 格式化门禁
纳入 AGC Cargo workspace 的统一 rustfmt 检查与格式化入口

完成项目 TypeScript/Prettier 与 Rust 全量格式化

修复 Pingora expected executable 门禁的空白敏感误报

同步开发运维文档与 AGC skill pack 格式化忽略规则
2026-09-01 16:28:34 +08:00

58 lines
1.4 KiB
TypeScript

import type { Encounter, FacingDirection } from '../types';
const DEFAULT_NPC_SCENE_OVERLAY_OFFSETS = {
hpTop: -40,
nameTop: -20,
dialogueTop: -56,
};
const GENERIC_NPC_SCENE_OVERLAY_OFFSETS = {
hpTop: -24,
nameTop: -8,
dialogueTop: -48,
};
export const GENERIC_NPC_SCENE_FOOT_OFFSET_PX = -30;
export function isGenericNpcEncounter(encounter: Encounter | null | undefined) {
return Boolean(
encounter &&
encounter.kind !== 'treasure' &&
!encounter.characterId &&
!encounter.monsterPresetId,
);
}
export function invertFacing(facing: FacingDirection): FacingDirection {
return facing === 'left' ? 'right' : 'left';
}
export function getRenderableNpcFacing(
encounter: Encounter | null | undefined,
facing: FacingDirection,
options?: { medievalVisual?: boolean },
): FacingDirection {
const medieval =
options?.medievalVisual ??
Boolean(
encounter &&
encounter.kind !== 'treasure' &&
isGenericNpcEncounter(encounter),
);
return medieval ? invertFacing(facing) : facing;
}
export function getNpcSceneFootOffset(encounter: Encounter | null | undefined) {
return isGenericNpcEncounter(encounter)
? GENERIC_NPC_SCENE_FOOT_OFFSET_PX
: 0;
}
export function getNpcSceneOverlayOffsets(
encounter: Encounter | null | undefined,
) {
return isGenericNpcEncounter(encounter)
? GENERIC_NPC_SCENE_OVERLAY_OFFSETS
: DEFAULT_NPC_SCENE_OVERLAY_OFFSETS;
}