import { BaseTool } from '../catalog/base-tool.js'; import type { StandardActionResponse } from '../../types/tools/tool-interfaces.js'; import type { LevelOperationContext } from './level-operation-types.js'; import { ManagedLevelState } from './level-state.js'; import { createLevel as createLevelOperation, deleteLevels as deleteLevelsOperation, exportLevel as exportLevelOperation, getLevelSummary as getLevelSummaryOperation, importLevel as importLevelOperation, listLevels as listLevelsOperation, saveLevel as saveLevelOperation, saveLevelAs as saveLevelAsOperation } from './level-asset-operations.js'; import { addSubLevel as addSubLevelOperation, loadLevel as loadLevelOperation, streamLevel as streamLevelOperation } from './level-load-operations.js'; import { buildNavMesh as buildNavMeshOperation, createSubLevel as createSubLevelOperation, editLevelBlueprint as editLevelBlueprintOperation, setLevelBounds as setLevelBoundsOperation, setLevelVisibility as setLevelVisibilityOperation, setWorldSettings as setWorldSettingsOperation, setupWorldComposition as setupWorldCompositionOperation } from './level-world-operations.js'; export class LevelTools extends BaseTool { private readonly state = new ManagedLevelState(); async listLevels(): Promise { return listLevelsOperation(this.createOperationContext()); } async getLevelSummary(levelPath?: string): Promise { return getLevelSummaryOperation(this.createOperationContext(), levelPath); } registerLight(levelPath: string | undefined, info: { name: string; type: string; details?: Record }): void { this.state.registerLight(levelPath, info); } async exportLevel(params: { levelPath?: string; exportPath: string; note?: string; timeoutMs?: number }): Promise { return exportLevelOperation(this.createOperationContext(), params); } async importLevel(params: { packagePath: string; destinationPath?: string; streaming?: boolean; timeoutMs?: number }): Promise { return importLevelOperation(this.createOperationContext(), params); } async saveLevelAs(params: { sourcePath?: string; targetPath: string }): Promise { return saveLevelAsOperation(this.createOperationContext(), params); } async deleteLevels(params: { levelPaths: string[] }): Promise { return deleteLevelsOperation(this.createOperationContext(), params); } async loadLevel(params: { levelPath: string; streaming?: boolean; position?: [number, number, number] }): Promise { return loadLevelOperation(this.createOperationContext(), params); } async saveLevel(params: { levelName?: string; savePath?: string }): Promise { return saveLevelOperation(this.createOperationContext(), params); } async createLevel(params: { levelName: string; template?: 'Empty' | 'Default' | 'VR' | 'TimeOfDay'; savePath?: string; useWorldPartition?: boolean }): Promise { return createLevelOperation(this.createOperationContext(), params); } async addSubLevel(params: { parentLevel?: string; subLevelPath: string; streamingMethod?: 'Blueprint' | 'AlwaysLoaded' }): Promise { return addSubLevelOperation(this.createOperationContext(), params); } async streamLevel(params: { levelPath?: string; levelName?: string; shouldBeLoaded: boolean; shouldBeVisible?: boolean; position?: [number, number, number] }): Promise { return streamLevelOperation(this.createOperationContext(), params); } async setupWorldComposition(params: { enableComposition: boolean; tileSize?: number; distanceStreaming?: boolean; streamingDistance?: number }): Promise { return setupWorldCompositionOperation(this.createOperationContext(), params); } async editLevelBlueprint(params: { eventType: 'BeginPlay' | 'EndPlay' | 'Tick' | 'Custom'; customEventName?: string; nodes?: Array<{ nodeType: string; position: [number, number]; connections?: string[] }> }): Promise { return editLevelBlueprintOperation(this.createOperationContext(), params); } async createSubLevel(params: { name: string; type: 'Persistent' | 'Streaming' | 'Lighting' | 'Gameplay'; parent?: string }): Promise { return createSubLevelOperation(this.createOperationContext(), params); } async setWorldSettings(params: { gravity?: number; worldScale?: number; gameMode?: string; defaultPawn?: string; killZ?: number }): Promise { return setWorldSettingsOperation(this.createOperationContext(), params); } async setLevelBounds(params: { min: [number, number, number]; max: [number, number, number] }): Promise { return setLevelBoundsOperation(this.createOperationContext(), params); } async buildNavMesh(params: { rebuildAll?: boolean; selectedOnly?: boolean }): Promise { return buildNavMeshOperation(this.createOperationContext(), params); } async setLevelVisibility(params: { levelName: string; visible: boolean }): Promise { return setLevelVisibilityOperation(this.createOperationContext(), params); } private createOperationContext(): LevelOperationContext { return { state: this.state, bridge: this.bridge, getAutomationBridge: () => this.getAutomationBridge(), sendAutomationRequest: (action, params, options) => this.sendAutomationRequest(action, params, options) }; } }