You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.3 KiB
84 lines
2.3 KiB
import type { MapTopology } from './MapTopology';
|
|
|
|
/** 阵营区域隔离维度(战斗模式通过 preset 开关) */
|
|
export type CampAreaScope =
|
|
| 'pathfinding'
|
|
| 'targeting'
|
|
| 'projectile'
|
|
| 'aoe'
|
|
| 'spawning'
|
|
| 'concurrentCap'
|
|
| 'waveProgress'
|
|
| 'wall'
|
|
| 'economy'
|
|
| 'deploy'
|
|
| 'placeValidation'
|
|
| 'mechanisms'
|
|
| 'skills';
|
|
|
|
export type CampAreaPreset = 'none' | 'pathOnly' | 'lane' | 'pvp';
|
|
|
|
export interface CampAreaPolicy {
|
|
enabled: boolean;
|
|
scopes: Partial<Record<CampAreaScope, boolean>>;
|
|
}
|
|
|
|
const PRESETS: Record<CampAreaPreset, CampAreaPolicy> = {
|
|
none: { enabled: false, scopes: {} },
|
|
pathOnly: { enabled: true, scopes: { pathfinding: true } },
|
|
lane: {
|
|
enabled: true,
|
|
scopes: { pathfinding: true, mechanisms: true, placeValidation: true },
|
|
},
|
|
pvp: {
|
|
enabled: true,
|
|
scopes: {
|
|
pathfinding: true,
|
|
targeting: true,
|
|
projectile: true,
|
|
aoe: true,
|
|
spawning: true,
|
|
concurrentCap: true,
|
|
waveProgress: true,
|
|
wall: true,
|
|
economy: true,
|
|
deploy: true,
|
|
placeValidation: true,
|
|
mechanisms: true,
|
|
skills: true,
|
|
},
|
|
},
|
|
};
|
|
|
|
/** 从 preset 名解析策略 */
|
|
export function campAreaPolicyFromPreset(preset: CampAreaPreset): CampAreaPolicy {
|
|
const p = PRESETS[preset];
|
|
return { enabled: p.enabled, scopes: { ...p.scopes } };
|
|
}
|
|
|
|
/**
|
|
* 解析本局阵营区域策略:单区域地图等价 none;多区域默认 pathOnly(仅寻路分区)。
|
|
* @param topology 已导入拓扑
|
|
* @param preset 项目层指定 preset,缺省时按区域数量推断
|
|
*/
|
|
export function resolveCampAreaPolicy(
|
|
topology: MapTopology,
|
|
preset?: CampAreaPreset,
|
|
): CampAreaPolicy {
|
|
if (preset) {
|
|
const policy = campAreaPolicyFromPreset(preset);
|
|
if (!topology.hasMultipleCampAreas()) {
|
|
return { enabled: false, scopes: {} };
|
|
}
|
|
return policy;
|
|
}
|
|
if (!topology.hasMultipleCampAreas()) {
|
|
return { enabled: false, scopes: {} };
|
|
}
|
|
return campAreaPolicyFromPreset('pathOnly');
|
|
}
|
|
|
|
/** @returns 是否启用指定隔离维度 */
|
|
export function isCampAreaScoped(policy: CampAreaPolicy, scope: CampAreaScope): boolean {
|
|
return policy.enabled && !!policy.scopes[scope];
|
|
}
|
|
|