import { DeviceCapability, type DeviceQuality } from '../../game/DeviceCapability'; import { BattlePresentationBudget } from './BattlePresentationBudget'; /** 设备画质档位(与 DeviceCapability 对齐) */ export type QualityTier = DeviceQuality; /** * 设备画像与画质分级。 * 分档阈值见 {@link device-capability-standards.ts}(微信 benchmarkLevel / 抖音 deviceScore 官方区间)。 */ export class DeviceProfile { private static _tier: QualityTier | null = null; /** 当前画质档位(首次访问时惰性判定并缓存) */ static get tier(): QualityTier { if (this._tier) return this._tier; this._tier = DeviceCapability.quality; return this._tier; } /** 强制覆盖档位(设置面板 / 调试用) */ static setTier(t: QualityTier): void { this._tier = t; DeviceCapability.overrideQuality(t); } /** 是否启用受击特效 prefab */ static get enableHitEffect(): boolean { return this.tier !== 'low'; } /** 是否启用伤害飘字 */ static get enableDamageText(): boolean { return this.tier !== 'low'; } /** 是否启用投射物独立飞行节点(low 档直接命中不飞) */ static get enableProjectileVisual(): boolean { return this.tier !== 'low'; } /** 怪物 Y 排序间隔(渲染帧);Sorting2D 写入,约 10–15Hz */ static get monsterSortInterval(): number { let base = this.tier === 'low' ? 6 : this.tier === 'medium' ? 4 : 3; if (BattlePresentationBudget.intensityScale < 0.85) base += 2; return base; } /** 塔正面 buff 特效同步频率(帧);buff 为秒级逻辑,略降频不影响表现 */ static get towerBuffSyncInterval(): number { return this.tier === 'low' ? 6 : this.tier === 'medium' ? 4 : 3; } /** 同屏飘字爆发上限(表现预算) */ static get damageTextBurstMax(): number { const base = this.tier === 'low' ? 12 : this.tier === 'medium' ? 24 : 40; return BattlePresentationBudget.scaleCount(base, 6); } /** 同屏受击特效软上限 */ static get hitEffectBurstMax(): number { const base = this.tier === 'low' ? 8 : this.tier === 'medium' ? 16 : 32; return BattlePresentationBudget.scaleCount(base, 4); } /** 同屏状态飘字(晕眩/加速等)上限 */ static get statusTextBurstMax(): number { const base = this.tier === 'low' ? 10 : this.tier === 'medium' ? 18 : 28; return BattlePresentationBudget.scaleCount(base, 5); } /** 落子 / 交换飞字拖尾(low 关,减透明叠加) */ static get enableBoardPlaceTrail(): boolean { return this.tier !== 'low'; } /** mapGrid / textGrid 升级与合成 Spine(low 关) */ static get enableGridUpgradeSpine(): boolean { return this.tier !== 'low'; } /** 升级飘字 levelUpText(low 关) */ static get enableLevelUpTextFloater(): boolean { return this.tier !== 'low'; } /** 战斗 ECS system 分片数(1=每帧全量;2=轮询减半 CPU) */ static get battleTickSlice(): number { if (this.tier === 'low') return 2; return Math.max(1, BattlePresentationBudget.combatTickSlice); } /** 是否对离屏怪物 Spine 停更 */ static get enableSpineLod(): boolean { return this.tier !== 'high'; } /** Spine LOD 检测间隔(帧) */ static get spineLodInterval(): number { return this.tier === 'low' ? 45 : 30; } }