'use strict';

/** 与 assets/scripts/level/EntitySpawnDefaults.ts 保持一致 */

const ENTITY_BASE_HEIGHT = {
    player: 90,
    vehicle: 80,
};

const ENTITY_BASE_SCALE = {
    player: 1,
    vehicle: 1,
    prop: 0.85,
    prop_decor: 0.6,
    enemy: 1,
};

const DEFAULT_SPAWN_SCALE = {
    player: 1,
    vehicle: 1,
    prop: 1,
};

function clampScale(v) {
    const n = typeof v === 'number' ? v : parseFloat(String(v));
    if (Number.isNaN(n)) return 1;
    return Math.max(0.1, Math.min(4, n));
}

function normalizeSpawnScale(scale) {
    const s = clampScale(scale);
    return Math.abs(s - 1) < 0.001 ? undefined : s;
}

function resolveEntityScaleMul(kind, spawnScale) {
    return clampScale(spawnScale !== undefined && spawnScale !== null ? spawnScale : 1);
}

module.exports = {
    ENTITY_BASE_HEIGHT,
    ENTITY_BASE_SCALE,
    DEFAULT_SPAWN_SCALE,
    clampScale,
    normalizeSpawnScale,
    resolveEntityScaleMul,
};
