init with react+axum+spacetimedb
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
2026-04-26 18:06:23 +08:00
commit cbc27bad4a
20199 changed files with 883714 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
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;
}