import type { World } from 'db://assets/mx/module/ecs'; import type { EntityId } from 'db://assets/mx/module/ecs'; import { BattlePhase } from '../core/BattlePhase'; import type { BattleFlowMode } from '../core/BattleFlowMode'; import type { SeededRNG } from '../core/SeededRNG'; import type { BattleClock } from '../core/BattleClock'; import type { BattleEventBus } from '../events/BattleEventBus'; import type { GridMap } from '../battlefield/GridMap'; import type { SpatialGrid } from '../battlefield/SpatialGrid'; import type { MapTopology } from '../battlefield/MapTopology'; import type { Pathfinder } from '../battlefield/Pathfinder'; import type { IConfigProvider } from '../config/IConfigProvider'; import type { PlayerSlot } from '../player/PlayerSlot'; import type { AttributeSystem } from './AttributeSystem'; import type { BuffSystem } from './BuffSystem'; import type { AbilitySystem } from './AbilitySystem'; import type { ProjectileSystem } from './ProjectileSystem'; import type { MovementSystem } from './MovementSystem'; import type { LifecycleSystem } from './LifecycleSystem'; import type { DamagePipeline } from './DamagePipeline'; import type { EffectExecutor } from './EffectExecutor'; import type { TargetResolver } from './TargetResolver'; import type { DeploySystem } from '../deploy/DeploySystem'; import type { WaveSpawner } from '../unit/WaveSpawner'; import type { PresentationPipeline } from './PresentationPipeline'; /** * 战斗服务聚合接口:供 effect/condition 等数据驱动脚本扩展点访问各子系统。 * 子系统之间不通过此接口互调,应通过构造注入的具体协作者。 */ export interface BattleServices { /** 实体世界 */ world: World; /** 配置提供者 */ config: IConfigProvider; /** 格子地图 */ grid: GridMap; /** 空间索引 */ spatial: SpatialGrid; /** 寻路 */ pathfinder: Pathfinder; /** 地图拓扑 */ topology: MapTopology; /** 事件总线 */ events: BattleEventBus; /** 逻辑时钟 */ clock: BattleClock; /** 随机数 */ rng: SeededRNG; /** 玩家槽列表 */ players: PlayerSlot[]; /** 当前战斗阶段(动态查询) */ readonly phase: BattlePhase; /** 连续战斗流程 */ readonly isContinuousFlow: boolean; /** 战斗流程模式 */ readonly flowMode: BattleFlowMode; /** 当前关卡 ID */ readonly levelId: string; /** 属性系统 */ attributes: AttributeSystem; /** Buff 系统 */ buffs: BuffSystem; /** 技能系统 */ abilities: AbilitySystem; /** 投射物系统 */ projectiles: ProjectileSystem; /** 移动系统 */ movement: MovementSystem; /** 生命周期系统 */ lifecycle: LifecycleSystem; /** 伤害管线 */ damage: DamagePipeline; /** 效果执行器 */ effects: EffectExecutor; /** 选敌解析 */ targets: TargetResolver; /** 部署系统 */ deploy: DeploySystem; /** 波次出怪 */ spawner: WaveSpawner; /** 表现 deferred 管线(hit/finish 推进 timeline) */ presentation: PresentationPipeline; /** 项目层:返回 true 时禁止该实体施法 */ castBlockPredicate?: (entityId: EntityId) => boolean; /** 项目层:返回 true 时暂缓该实体 OnTick 计时 */ holdAbilityTickPredicate?: (entityId: EntityId) => boolean; /** * 项目层:返回 true 时暂缓 lifecycle.kill(如还魂丹待死亡特效后再判定)。 * 暂缓期间实体仍存活,由项目层稍后补调 kill 或恢复战斗。 * @param hpBeforeKill 致死前血量 */ tryDeferEntityKill?: (victim: EntityId, killer: EntityId, hpBeforeKill: number) => boolean; /** * 中间波结波是否须清场。false:出怪队列耗尽即可进下一波(sdkConfig.isSwitchSpawnLogic)。 * 最后一波不受此项影响,始终须清场才胜利。 */ readonly waveClearRequiresKillAll: boolean; }