Files
cocos/assets/scripts/level/EntitySpawnDefaults.ts
刘宇飞 d393302388 Complete Cocos Creator port with level bundles, themes, and tooling.
Adds level prefabs, theme assets, audio, extensions, and deployment scripts for the Unity WebGL migration.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-16 15:30:58 +08:00

26 lines
977 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { SpawnKind } from './LevelTypes';
import { CELL_PIXEL } from '../core/GridConstants';
import { getEntityCellBox } from '../visual/EntityDisplayRefs';
/** spawns[].scale 为相对默认值的比例1 = 默认大小 */
export function resolveEntityScaleMul(kind: SpawnKind, spawnScale?: number): number {
const mul = spawnScale !== undefined && spawnScale !== null && !Number.isNaN(spawnScale)
? spawnScale
: 1;
return Math.max(0.1, Math.min(4, mul));
}
export function resolveEntityHeight(kind: 'player' | 'vehicle', spawnScale?: number, theme?: string): number {
const box = getEntityCellBox(theme)[kind];
return CELL_PIXEL * box.h * resolveEntityScaleMul(kind, spawnScale);
}
/** 可拾取物等基准缩放spawn scale 倍率用,显示尺寸见 themes-database entityDisplay */
export const ENTITY_BASE_SCALE: Record<SpawnKind, number> = {
player: 1,
vehicle: 1,
prop: 1,
prop_decor: 0.87,
enemy: 1,
};