// @ts-nocheck import type { Disposable } from "../Common" import { Cruise } from "./Cruise" import { CruiseExecutor, Cruiseble } from "./Cruiser" export class CruiseManager> implements Disposable { readonly executor: CruiseExecutor; readonly taskMap: Map>; constructor(executor: CruiseExecutor) { this.executor = executor; this.taskMap = new Map(); } dispose(): void { this.clearTask(); } /** * 清除所有巡航 * @returns */ clearTask() { this.taskMap.forEach((cruise) => { this.deleteTask(cruise); }); } /** * 移除目标巡航 * @param taskId 巡航id * @returns */ removeTask(taskId: string): Cruise | undefined { const cruise = this.findTask(taskId); if (cruise == undefined) { return; } this.taskMap.delete(taskId); return cruise; } private deleteTask(cruise: Cruise): void { this.taskMap.delete(cruise.id); } /** * 获取目标巡航 * @param taskId 巡航id * @returns */ findTask(taskId: string): Cruise | undefined { return this.taskMap.get(taskId); } /** * 创建新巡航任务 * @param id 任务id * @param name 任务名称 * @returns */ createTask(id: string, name: string): Cruise { const cruise = Cruise._create(id, name, this); this.taskMap.set(id, cruise); return cruise; } }