unreal-engine-mcp-server 0.5.3 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +66 -0
- package/dist/automation/bridge.d.ts +1 -0
- package/dist/automation/bridge.d.ts.map +1 -0
- package/dist/automation/bridge.js +62 -4
- package/dist/automation/bridge.js.map +1 -0
- package/dist/automation/connection-manager.d.ts.map +1 -0
- package/dist/automation/connection-manager.js.map +1 -0
- package/dist/automation/handshake.d.ts.map +1 -0
- package/dist/automation/handshake.js.map +1 -0
- package/dist/automation/index.d.ts.map +1 -0
- package/dist/automation/index.js.map +1 -0
- package/dist/automation/message-handler.d.ts.map +1 -0
- package/dist/automation/message-handler.js.map +1 -0
- package/dist/automation/request-tracker.d.ts.map +1 -0
- package/dist/automation/request-tracker.js.map +1 -0
- package/dist/automation/types.d.ts +1 -0
- package/dist/automation/types.d.ts.map +1 -0
- package/dist/automation/types.js.map +1 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +4 -3
- package/dist/cli.js.map +1 -0
- package/dist/config/class-aliases.d.ts.map +1 -0
- package/dist/config/class-aliases.js.map +1 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +2 -0
- package/dist/constants.js.map +1 -0
- package/dist/graphql/loaders.d.ts.map +1 -0
- package/dist/graphql/loaders.js.map +1 -0
- package/dist/graphql/resolvers.d.ts.map +1 -0
- package/dist/graphql/resolvers.js +29 -29
- package/dist/graphql/resolvers.js.map +1 -0
- package/dist/graphql/schema.d.ts.map +1 -0
- package/dist/graphql/schema.js.map +1 -0
- package/dist/graphql/server.d.ts +0 -1
- package/dist/graphql/server.d.ts.map +1 -0
- package/dist/graphql/server.js +15 -16
- package/dist/graphql/server.js.map +1 -0
- package/dist/graphql/types.d.ts.map +1 -0
- package/dist/graphql/types.js.map +1 -0
- package/dist/handlers/resource-handlers.d.ts.map +1 -0
- package/dist/handlers/resource-handlers.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +64 -7
- package/dist/index.js.map +1 -0
- package/dist/resources/actors.d.ts.map +1 -0
- package/dist/resources/actors.js.map +1 -0
- package/dist/resources/assets.d.ts.map +1 -0
- package/dist/resources/assets.js +6 -4
- package/dist/resources/assets.js.map +1 -0
- package/dist/resources/levels.d.ts.map +1 -0
- package/dist/resources/levels.js.map +1 -0
- package/dist/server/resource-registry.d.ts.map +1 -0
- package/dist/server/resource-registry.js.map +1 -0
- package/dist/server/tool-registry.d.ts.map +1 -0
- package/dist/server/tool-registry.js.map +1 -0
- package/dist/server-setup.d.ts.map +1 -0
- package/dist/server-setup.js.map +1 -0
- package/dist/services/health-monitor.d.ts.map +1 -0
- package/dist/services/health-monitor.js.map +1 -0
- package/dist/services/metrics-server.d.ts.map +1 -0
- package/dist/services/metrics-server.js +3 -3
- package/dist/services/metrics-server.js.map +1 -0
- package/dist/tools/actors.d.ts.map +1 -0
- package/dist/tools/actors.js +3 -1
- package/dist/tools/actors.js.map +1 -0
- package/dist/tools/animation.d.ts.map +1 -0
- package/dist/tools/animation.js +2 -2
- package/dist/tools/animation.js.map +1 -0
- package/dist/tools/assets.d.ts.map +1 -0
- package/dist/tools/assets.js.map +1 -0
- package/dist/tools/audio.d.ts.map +1 -0
- package/dist/tools/audio.js.map +1 -0
- package/dist/tools/base-tool.d.ts.map +1 -0
- package/dist/tools/base-tool.js.map +1 -0
- package/dist/tools/behavior-tree.d.ts.map +1 -0
- package/dist/tools/behavior-tree.js.map +1 -0
- package/dist/tools/blueprint.d.ts.map +1 -0
- package/dist/tools/blueprint.js +4 -2
- package/dist/tools/blueprint.js.map +1 -0
- package/dist/tools/consolidated-tool-definitions.d.ts.map +1 -0
- package/dist/tools/consolidated-tool-definitions.js.map +1 -0
- package/dist/tools/consolidated-tool-handlers.d.ts.map +1 -0
- package/dist/tools/consolidated-tool-handlers.js.map +1 -0
- package/dist/tools/debug.d.ts.map +1 -0
- package/dist/tools/debug.js +3 -1
- package/dist/tools/debug.js.map +1 -0
- package/dist/tools/dynamic-handler-registry.d.ts.map +1 -0
- package/dist/tools/dynamic-handler-registry.js +3 -1
- package/dist/tools/dynamic-handler-registry.js.map +1 -0
- package/dist/tools/editor.d.ts.map +1 -0
- package/dist/tools/editor.js +1 -1
- package/dist/tools/editor.js.map +1 -0
- package/dist/tools/engine.d.ts.map +1 -0
- package/dist/tools/engine.js.map +1 -0
- package/dist/tools/environment.d.ts.map +1 -0
- package/dist/tools/environment.js +2 -2
- package/dist/tools/environment.js.map +1 -0
- package/dist/tools/foliage.d.ts.map +1 -0
- package/dist/tools/foliage.js.map +1 -0
- package/dist/tools/handlers/actor-handlers.d.ts +1 -1
- package/dist/tools/handlers/actor-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/actor-handlers.js +6 -5
- package/dist/tools/handlers/actor-handlers.js.map +1 -0
- package/dist/tools/handlers/animation-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/animation-handlers.js.map +1 -0
- package/dist/tools/handlers/argument-helper.d.ts.map +1 -0
- package/dist/tools/handlers/argument-helper.js.map +1 -0
- package/dist/tools/handlers/asset-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/asset-handlers.js +5 -1
- package/dist/tools/handlers/asset-handlers.js.map +1 -0
- package/dist/tools/handlers/audio-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/audio-handlers.js.map +1 -0
- package/dist/tools/handlers/blueprint-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/blueprint-handlers.js +2 -1
- package/dist/tools/handlers/blueprint-handlers.js.map +1 -0
- package/dist/tools/handlers/common-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/common-handlers.js.map +1 -0
- package/dist/tools/handlers/editor-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/editor-handlers.js +12 -2
- package/dist/tools/handlers/editor-handlers.js.map +1 -0
- package/dist/tools/handlers/effect-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/effect-handlers.js.map +1 -0
- package/dist/tools/handlers/environment-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/environment-handlers.js.map +1 -0
- package/dist/tools/handlers/graph-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/graph-handlers.js +61 -1
- package/dist/tools/handlers/graph-handlers.js.map +1 -0
- package/dist/tools/handlers/input-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/input-handlers.js.map +1 -0
- package/dist/tools/handlers/inspect-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/inspect-handlers.js.map +1 -0
- package/dist/tools/handlers/level-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/level-handlers.js.map +1 -0
- package/dist/tools/handlers/lighting-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/lighting-handlers.js +23 -1
- package/dist/tools/handlers/lighting-handlers.js.map +1 -0
- package/dist/tools/handlers/performance-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/performance-handlers.js +15 -2
- package/dist/tools/handlers/performance-handlers.js.map +1 -0
- package/dist/tools/handlers/pipeline-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/pipeline-handlers.js +61 -7
- package/dist/tools/handlers/pipeline-handlers.js.map +1 -0
- package/dist/tools/handlers/sequence-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/sequence-handlers.js.map +1 -0
- package/dist/tools/handlers/system-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/system-handlers.js +16 -1
- package/dist/tools/handlers/system-handlers.js.map +1 -0
- package/dist/tools/input.d.ts.map +1 -0
- package/dist/tools/input.js +3 -1
- package/dist/tools/input.js.map +1 -0
- package/dist/tools/introspection.d.ts.map +1 -0
- package/dist/tools/introspection.js.map +1 -0
- package/dist/tools/landscape.d.ts.map +1 -0
- package/dist/tools/landscape.js +3 -1
- package/dist/tools/landscape.js.map +1 -0
- package/dist/tools/level.d.ts.map +1 -0
- package/dist/tools/level.js.map +1 -0
- package/dist/tools/lighting.d.ts.map +1 -0
- package/dist/tools/lighting.js +3 -1
- package/dist/tools/lighting.js.map +1 -0
- package/dist/tools/logs.d.ts.map +1 -0
- package/dist/tools/logs.js.map +1 -0
- package/dist/tools/materials.d.ts.map +1 -0
- package/dist/tools/materials.js +3 -1
- package/dist/tools/materials.js.map +1 -0
- package/dist/tools/niagara.d.ts.map +1 -0
- package/dist/tools/niagara.js +7 -5
- package/dist/tools/niagara.js.map +1 -0
- package/dist/tools/performance.d.ts.map +1 -0
- package/dist/tools/performance.js.map +1 -0
- package/dist/tools/physics.d.ts.map +1 -0
- package/dist/tools/physics.js +9 -7
- package/dist/tools/physics.js.map +1 -0
- package/dist/tools/property-dictionary.d.ts.map +1 -0
- package/dist/tools/property-dictionary.js.map +1 -0
- package/dist/tools/sequence.d.ts.map +1 -0
- package/dist/tools/sequence.js +3 -1
- package/dist/tools/sequence.js.map +1 -0
- package/dist/tools/tool-definition-utils.d.ts.map +1 -0
- package/dist/tools/tool-definition-utils.js.map +1 -0
- package/dist/tools/ui.d.ts.map +1 -0
- package/dist/tools/ui.js +3 -1
- package/dist/tools/ui.js.map +1 -0
- package/dist/types/automation-responses.d.ts.map +1 -0
- package/dist/types/automation-responses.js.map +1 -0
- package/dist/types/env.d.ts.map +1 -0
- package/dist/types/env.js.map +1 -0
- package/dist/types/handler-types.d.ts.map +1 -0
- package/dist/types/handler-types.js.map +1 -0
- package/dist/types/tool-interfaces.d.ts.map +1 -0
- package/dist/types/tool-interfaces.js.map +1 -0
- package/dist/types/tool-types.d.ts.map +1 -0
- package/dist/types/tool-types.js.map +1 -0
- package/dist/unreal-bridge.d.ts +1 -0
- package/dist/unreal-bridge.d.ts.map +1 -0
- package/dist/unreal-bridge.js +8 -0
- package/dist/unreal-bridge.js.map +1 -0
- package/dist/utils/command-validator.d.ts.map +1 -0
- package/dist/utils/command-validator.js.map +1 -0
- package/dist/utils/elicitation.d.ts.map +1 -0
- package/dist/utils/elicitation.js.map +1 -0
- package/dist/utils/error-handler.d.ts.map +1 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/ini-reader.d.ts.map +1 -0
- package/dist/utils/ini-reader.js.map +1 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/normalize.d.ts.map +1 -0
- package/dist/utils/normalize.js.map +1 -0
- package/dist/utils/path-security.d.ts.map +1 -0
- package/dist/utils/path-security.js.map +1 -0
- package/dist/utils/response-factory.d.ts.map +1 -0
- package/dist/utils/response-factory.js +3 -1
- package/dist/utils/response-factory.js.map +1 -0
- package/dist/utils/response-validator.d.ts.map +1 -0
- package/dist/utils/response-validator.js.map +1 -0
- package/dist/utils/result-helpers.d.ts.map +1 -0
- package/dist/utils/result-helpers.js.map +1 -0
- package/dist/utils/safe-json.d.ts.map +1 -0
- package/dist/utils/safe-json.js.map +1 -0
- package/dist/utils/unreal-command-queue.d.ts.map +1 -0
- package/dist/utils/unreal-command-queue.js.map +1 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js.map +1 -0
- package/dist/wasm/index.d.ts.map +1 -0
- package/dist/wasm/index.js.map +1 -0
- package/package.json +12 -34
- package/server.json +2 -2
- package/.dockerignore +0 -57
- package/.env.example +0 -26
- package/.env.production +0 -61
- package/.eslintrc.json +0 -0
- package/.eslintrc.override.json +0 -8
- package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -94
- package/.github/ISSUE_TEMPLATE/config.yml +0 -8
- package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -56
- package/.github/copilot-instructions.md +0 -478
- package/.github/dependabot.yml +0 -19
- package/.github/labeler.yml +0 -24
- package/.github/labels.yml +0 -70
- package/.github/pull_request_template.md +0 -42
- package/.github/release-drafter-config.yml +0 -51
- package/.github/workflows/auto-merge.yml +0 -38
- package/.github/workflows/ci.yml +0 -38
- package/.github/workflows/dependency-review.yml +0 -17
- package/.github/workflows/gemini-issue-triage.yml +0 -172
- package/.github/workflows/greetings.yml +0 -27
- package/.github/workflows/labeler.yml +0 -17
- package/.github/workflows/links.yml +0 -80
- package/.github/workflows/pr-size-labeler.yml +0 -137
- package/.github/workflows/publish-mcp.yml +0 -79
- package/.github/workflows/release-drafter.yml +0 -24
- package/.github/workflows/release.yml +0 -112
- package/.github/workflows/semantic-pull-request.yml +0 -35
- package/.github/workflows/smoke-test.yml +0 -36
- package/.github/workflows/stale.yml +0 -28
- package/CONTRIBUTING.md +0 -140
- package/Dockerfile +0 -37
- package/GEMINI.md +0 -115
- package/Public/Plugin_setup_guide.mp4 +0 -0
- package/Public/icon.png +0 -0
- package/claude_desktop_config_example.json +0 -15
- package/dist/types/responses.d.ts +0 -249
- package/dist/types/responses.js +0 -2
- package/docs/GraphQL-API.md +0 -888
- package/docs/Migration-Guide-v0.5.0.md +0 -684
- package/docs/Roadmap.md +0 -53
- package/docs/WebAssembly-Integration.md +0 -628
- package/docs/editor-plugin-extension.md +0 -370
- package/docs/handler-mapping.md +0 -249
- package/docs/native-automation-progress.md +0 -128
- package/docs/testing-guide.md +0 -423
- package/eslint.config.mjs +0 -68
- package/mcp-config-example.json +0 -14
- package/plugins/McpAutomationBridge/Config/FilterPlugin.ini +0 -8
- package/plugins/McpAutomationBridge/McpAutomationBridge.uplugin +0 -64
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/McpAutomationBridge.Build.cs +0 -189
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeGlobals.cpp +0 -22
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeGlobals.h +0 -30
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeHelpers.h +0 -1983
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeModule.cpp +0 -72
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeSettings.cpp +0 -46
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeSubsystem.cpp +0 -846
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_AnimationHandlers.cpp +0 -2393
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_AssetQueryHandlers.cpp +0 -300
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_AssetWorkflowHandlers.cpp +0 -2807
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_AudioHandlers.cpp +0 -1087
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BehaviorTreeHandlers.cpp +0 -488
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintCreationHandlers.cpp +0 -643
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintCreationHandlers.h +0 -31
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintGraphHandlers.cpp +0 -1094
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintHandlers.cpp +0 -5750
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintHandlers_List.cpp +0 -152
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_ControlHandlers.cpp +0 -2614
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_DebugHandlers.cpp +0 -42
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_EditorFunctionHandlers.cpp +0 -1237
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_EffectHandlers.cpp +0 -1725
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_EnvironmentHandlers.cpp +0 -2241
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_FoliageHandlers.cpp +0 -954
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_InputHandlers.cpp +0 -209
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_InsightsHandlers.cpp +0 -41
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_LandscapeHandlers.cpp +0 -1164
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_LevelHandlers.cpp +0 -762
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_LightingHandlers.cpp +0 -663
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_LogHandlers.cpp +0 -136
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_MaterialGraphHandlers.cpp +0 -494
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_NiagaraGraphHandlers.cpp +0 -278
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_NiagaraHandlers.cpp +0 -625
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_PerformanceHandlers.cpp +0 -401
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_PipelineHandlers.cpp +0 -67
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_ProcessRequest.cpp +0 -472
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_PropertyHandlers.cpp +0 -2634
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_RenderHandlers.cpp +0 -189
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_SCSHandlers.cpp +0 -917
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_SCSHandlers.h +0 -39
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_SequenceHandlers.cpp +0 -2706
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_SequencerHandlers.cpp +0 -519
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_TestHandlers.cpp +0 -38
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_UiHandlers.cpp +0 -668
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_WorldPartitionHandlers.cpp +0 -346
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpBridgeWebSocket.cpp +0 -1330
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpBridgeWebSocket.h +0 -149
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpConnectionManager.cpp +0 -782
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Public/McpAutomationBridgeSettings.h +0 -115
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Public/McpAutomationBridgeSubsystem.h +0 -796
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Public/McpConnectionManager.h +0 -117
- package/scripts/check-unreal-connection.mjs +0 -19
- package/scripts/clean-tmp.js +0 -23
- package/scripts/patch-wasm.js +0 -26
- package/scripts/run-all-tests.mjs +0 -136
- package/scripts/smoke-test.ts +0 -94
- package/scripts/sync-mcp-plugin.js +0 -143
- package/scripts/test-no-plugin-alternates.mjs +0 -113
- package/scripts/validate-server.js +0 -46
- package/scripts/verify-automation-bridge.js +0 -200
- package/src/automation/bridge.ts +0 -560
- package/src/automation/connection-manager.ts +0 -148
- package/src/automation/handshake.ts +0 -99
- package/src/automation/index.ts +0 -2
- package/src/automation/message-handler.ts +0 -192
- package/src/automation/request-tracker.ts +0 -155
- package/src/automation/types.ts +0 -107
- package/src/cli.ts +0 -34
- package/src/config/class-aliases.ts +0 -65
- package/src/config.ts +0 -73
- package/src/constants.ts +0 -24
- package/src/graphql/loaders.ts +0 -244
- package/src/graphql/resolvers.ts +0 -1008
- package/src/graphql/schema.ts +0 -452
- package/src/graphql/server.ts +0 -156
- package/src/graphql/types.ts +0 -10
- package/src/handlers/resource-handlers.ts +0 -186
- package/src/index.ts +0 -243
- package/src/resources/actors.ts +0 -127
- package/src/resources/assets.ts +0 -286
- package/src/resources/levels.ts +0 -68
- package/src/server/resource-registry.ts +0 -47
- package/src/server/tool-registry.ts +0 -354
- package/src/server-setup.ts +0 -114
- package/src/services/health-monitor.ts +0 -132
- package/src/services/metrics-server.ts +0 -176
- package/src/tools/actors.ts +0 -564
- package/src/tools/animation.ts +0 -941
- package/src/tools/assets.ts +0 -394
- package/src/tools/audio.ts +0 -499
- package/src/tools/base-tool.ts +0 -52
- package/src/tools/behavior-tree.ts +0 -45
- package/src/tools/blueprint.ts +0 -940
- package/src/tools/consolidated-tool-definitions.ts +0 -1256
- package/src/tools/consolidated-tool-handlers.ts +0 -302
- package/src/tools/debug.ts +0 -622
- package/src/tools/dynamic-handler-registry.ts +0 -33
- package/src/tools/editor.ts +0 -435
- package/src/tools/engine.ts +0 -43
- package/src/tools/environment.ts +0 -281
- package/src/tools/foliage.ts +0 -596
- package/src/tools/handlers/actor-handlers.ts +0 -244
- package/src/tools/handlers/animation-handlers.ts +0 -237
- package/src/tools/handlers/argument-helper.ts +0 -142
- package/src/tools/handlers/asset-handlers.ts +0 -550
- package/src/tools/handlers/audio-handlers.ts +0 -194
- package/src/tools/handlers/blueprint-handlers.ts +0 -380
- package/src/tools/handlers/common-handlers.ts +0 -108
- package/src/tools/handlers/editor-handlers.ts +0 -124
- package/src/tools/handlers/effect-handlers.ts +0 -224
- package/src/tools/handlers/environment-handlers.ts +0 -183
- package/src/tools/handlers/graph-handlers.ts +0 -117
- package/src/tools/handlers/input-handlers.ts +0 -28
- package/src/tools/handlers/inspect-handlers.ts +0 -450
- package/src/tools/handlers/level-handlers.ts +0 -253
- package/src/tools/handlers/lighting-handlers.ts +0 -151
- package/src/tools/handlers/performance-handlers.ts +0 -132
- package/src/tools/handlers/pipeline-handlers.ts +0 -128
- package/src/tools/handlers/sequence-handlers.ts +0 -438
- package/src/tools/handlers/system-handlers.ts +0 -564
- package/src/tools/input.ts +0 -160
- package/src/tools/introspection.ts +0 -689
- package/src/tools/landscape.ts +0 -649
- package/src/tools/level.ts +0 -989
- package/src/tools/lighting.ts +0 -1052
- package/src/tools/logs.ts +0 -219
- package/src/tools/materials.ts +0 -295
- package/src/tools/niagara.ts +0 -485
- package/src/tools/performance.ts +0 -661
- package/src/tools/physics.ts +0 -679
- package/src/tools/property-dictionary.ts +0 -98
- package/src/tools/sequence.ts +0 -385
- package/src/tools/tool-definition-utils.ts +0 -35
- package/src/tools/ui.ts +0 -452
- package/src/types/automation-responses.ts +0 -119
- package/src/types/env.ts +0 -17
- package/src/types/handler-types.ts +0 -442
- package/src/types/responses.ts +0 -355
- package/src/types/tool-interfaces.ts +0 -250
- package/src/types/tool-types.ts +0 -575
- package/src/unreal-bridge.ts +0 -693
- package/src/utils/command-validator.ts +0 -139
- package/src/utils/elicitation.ts +0 -132
- package/src/utils/error-handler.ts +0 -287
- package/src/utils/ini-reader.ts +0 -86
- package/src/utils/logger.ts +0 -35
- package/src/utils/normalize.test.ts +0 -162
- package/src/utils/normalize.ts +0 -146
- package/src/utils/path-security.ts +0 -43
- package/src/utils/response-factory.ts +0 -44
- package/src/utils/response-validator.ts +0 -395
- package/src/utils/result-helpers.ts +0 -195
- package/src/utils/safe-json.test.ts +0 -90
- package/src/utils/safe-json.ts +0 -70
- package/src/utils/unreal-command-queue.ts +0 -166
- package/src/utils/validation.test.ts +0 -184
- package/src/utils/validation.ts +0 -312
- package/src/wasm/index.ts +0 -838
- package/test-server.mjs +0 -100
- package/tests/run-unreal-tool-tests.mjs +0 -948
- package/tests/test-animation.mjs +0 -369
- package/tests/test-asset-advanced.mjs +0 -82
- package/tests/test-asset-errors.mjs +0 -35
- package/tests/test-asset-graph.mjs +0 -311
- package/tests/test-audio.mjs +0 -417
- package/tests/test-automation-timeouts.mjs +0 -98
- package/tests/test-behavior-tree.mjs +0 -444
- package/tests/test-blueprint-graph.mjs +0 -410
- package/tests/test-blueprint.mjs +0 -577
- package/tests/test-client-mode.mjs +0 -86
- package/tests/test-console-command.mjs +0 -56
- package/tests/test-control-actor.mjs +0 -425
- package/tests/test-control-editor.mjs +0 -112
- package/tests/test-graphql.mjs +0 -372
- package/tests/test-input.mjs +0 -349
- package/tests/test-inspect.mjs +0 -302
- package/tests/test-landscape.mjs +0 -316
- package/tests/test-lighting.mjs +0 -428
- package/tests/test-manage-asset.mjs +0 -438
- package/tests/test-manage-level.mjs +0 -89
- package/tests/test-materials.mjs +0 -356
- package/tests/test-niagara.mjs +0 -185
- package/tests/test-no-inline-python.mjs +0 -122
- package/tests/test-performance.mjs +0 -539
- package/tests/test-plugin-handshake.mjs +0 -82
- package/tests/test-runner.mjs +0 -933
- package/tests/test-sequence.mjs +0 -104
- package/tests/test-system.mjs +0 -96
- package/tests/test-wasm.mjs +0 -283
- package/tests/test-world-partition.mjs +0 -215
- package/tsconfig.json +0 -56
- package/vitest.config.ts +0 -35
- package/wasm/Cargo.lock +0 -363
- package/wasm/Cargo.toml +0 -42
- package/wasm/LICENSE +0 -21
- package/wasm/README.md +0 -253
- package/wasm/src/dependency_resolver.rs +0 -377
- package/wasm/src/lib.rs +0 -153
- package/wasm/src/property_parser.rs +0 -271
- package/wasm/src/transform_math.rs +0 -396
- package/wasm/tests/integration.rs +0 -109
|
@@ -1,954 +0,0 @@
|
|
|
1
|
-
#include "McpAutomationBridgeGlobals.h"
|
|
2
|
-
#include "McpAutomationBridgeHelpers.h"
|
|
3
|
-
#include "McpAutomationBridgeSubsystem.h"
|
|
4
|
-
|
|
5
|
-
#if WITH_EDITOR
|
|
6
|
-
#include "EditorAssetLibrary.h"
|
|
7
|
-
#include "Engine/StaticMesh.h"
|
|
8
|
-
#include "Engine/World.h"
|
|
9
|
-
#include "EngineUtils.h"
|
|
10
|
-
#include "FoliageType.h"
|
|
11
|
-
#include "FoliageTypeObject.h"
|
|
12
|
-
#include "FoliageType_InstancedStaticMesh.h"
|
|
13
|
-
#include "InstancedFoliageActor.h"
|
|
14
|
-
#include "ProceduralFoliageComponent.h"
|
|
15
|
-
#include "ProceduralFoliageSpawner.h"
|
|
16
|
-
#include "ProceduralFoliageVolume.h"
|
|
17
|
-
#include "UObject/SavePackage.h"
|
|
18
|
-
#include "WorldPartition/WorldPartition.h"
|
|
19
|
-
|
|
20
|
-
#if __has_include("Subsystems/EditorActorSubsystem.h")
|
|
21
|
-
#include "Subsystems/EditorActorSubsystem.h"
|
|
22
|
-
#elif __has_include("EditorActorSubsystem.h")
|
|
23
|
-
#include "EditorActorSubsystem.h"
|
|
24
|
-
#endif
|
|
25
|
-
|
|
26
|
-
// Add these includes unconditionally for Editor builds
|
|
27
|
-
#include "ActorPartition/ActorPartitionSubsystem.h"
|
|
28
|
-
#include "EditorBuildUtils.h"
|
|
29
|
-
#endif
|
|
30
|
-
|
|
31
|
-
#if WITH_EDITOR
|
|
32
|
-
static AInstancedFoliageActor *
|
|
33
|
-
GetOrCreateFoliageActorForWorldSafe(UWorld *World, bool bCreateIfNone) {
|
|
34
|
-
if (!World) {
|
|
35
|
-
return nullptr;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (UWorldPartition *WorldPartition = World->GetWorldPartition()) {
|
|
39
|
-
// Check if the world is actually using the Actor Partition Subsystem to
|
|
40
|
-
// avoid crashes in non-partitioned levels that happen to have a WP object.
|
|
41
|
-
if (UActorPartitionSubsystem *ActorPartitionSubsystem =
|
|
42
|
-
World->GetSubsystem<UActorPartitionSubsystem>()) {
|
|
43
|
-
if (ActorPartitionSubsystem->IsLevelPartition()) {
|
|
44
|
-
return AInstancedFoliageActor::GetInstancedFoliageActorForCurrentLevel(
|
|
45
|
-
World, bCreateIfNone);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Non-partitioned worlds: avoid ActorPartitionSubsystem ensures by finding or
|
|
51
|
-
// spawning a foliage actor manually.
|
|
52
|
-
TActorIterator<AInstancedFoliageActor> It(World);
|
|
53
|
-
if (It) {
|
|
54
|
-
return *It;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (!bCreateIfNone) {
|
|
58
|
-
return nullptr;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
FActorSpawnParameters SpawnParams;
|
|
62
|
-
SpawnParams.ObjectFlags |= RF_Transactional;
|
|
63
|
-
SpawnParams.OverrideLevel = World->PersistentLevel;
|
|
64
|
-
return World->SpawnActor<AInstancedFoliageActor>(SpawnParams);
|
|
65
|
-
}
|
|
66
|
-
#endif
|
|
67
|
-
|
|
68
|
-
bool UMcpAutomationBridgeSubsystem::HandlePaintFoliage(
|
|
69
|
-
const FString &RequestId, const FString &Action,
|
|
70
|
-
const TSharedPtr<FJsonObject> &Payload,
|
|
71
|
-
TSharedPtr<FMcpBridgeWebSocket> RequestingSocket) {
|
|
72
|
-
const FString Lower = Action.ToLower();
|
|
73
|
-
if (!Lower.Equals(TEXT("paint_foliage"), ESearchCase::IgnoreCase)) {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
#if WITH_EDITOR
|
|
78
|
-
if (!Payload.IsValid()) {
|
|
79
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
80
|
-
TEXT("paint_foliage payload missing"),
|
|
81
|
-
TEXT("INVALID_PAYLOAD"));
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
FString FoliageTypePath;
|
|
86
|
-
if (!Payload->TryGetStringField(TEXT("foliageTypePath"), FoliageTypePath)) {
|
|
87
|
-
// Accept alternate key used by some clients
|
|
88
|
-
Payload->TryGetStringField(TEXT("foliageType"), FoliageTypePath);
|
|
89
|
-
}
|
|
90
|
-
if (FoliageTypePath.IsEmpty()) {
|
|
91
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
92
|
-
TEXT("foliageTypePath (or foliageType) required"),
|
|
93
|
-
TEXT("INVALID_ARGUMENT"));
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Auto-resolve simple name
|
|
98
|
-
if (!FoliageTypePath.IsEmpty() &&
|
|
99
|
-
FPaths::GetPath(FoliageTypePath).IsEmpty()) {
|
|
100
|
-
FoliageTypePath =
|
|
101
|
-
FString::Printf(TEXT("/Game/Foliage/%s"), *FoliageTypePath);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Accept single 'position' or array of 'locations'
|
|
105
|
-
TArray<FVector> Locations;
|
|
106
|
-
const TArray<TSharedPtr<FJsonValue>> *LocationsArray = nullptr;
|
|
107
|
-
if ((Payload->TryGetArrayField(TEXT("locations"), LocationsArray) ||
|
|
108
|
-
Payload->TryGetArrayField(TEXT("location"), LocationsArray)) &&
|
|
109
|
-
LocationsArray && LocationsArray->Num() > 0) {
|
|
110
|
-
for (const TSharedPtr<FJsonValue> &Val : *LocationsArray) {
|
|
111
|
-
if (Val.IsValid() && Val->Type == EJson::Object) {
|
|
112
|
-
const TSharedPtr<FJsonObject> *Obj = nullptr;
|
|
113
|
-
if (Val->TryGetObject(Obj) && Obj) {
|
|
114
|
-
double X = 0, Y = 0, Z = 0;
|
|
115
|
-
(*Obj)->TryGetNumberField(TEXT("x"), X);
|
|
116
|
-
(*Obj)->TryGetNumberField(TEXT("y"), Y);
|
|
117
|
-
(*Obj)->TryGetNumberField(TEXT("z"), Z);
|
|
118
|
-
Locations.Add(FVector(X, Y, Z));
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
} else {
|
|
123
|
-
// Try a single 'position' object
|
|
124
|
-
const TSharedPtr<FJsonObject> *PosObj = nullptr;
|
|
125
|
-
if ((Payload->TryGetObjectField(TEXT("position"), PosObj) ||
|
|
126
|
-
Payload->TryGetObjectField(TEXT("location"), PosObj)) &&
|
|
127
|
-
PosObj) {
|
|
128
|
-
double X = 0, Y = 0, Z = 0;
|
|
129
|
-
(*PosObj)->TryGetNumberField(TEXT("x"), X);
|
|
130
|
-
(*PosObj)->TryGetNumberField(TEXT("y"), Y);
|
|
131
|
-
(*PosObj)->TryGetNumberField(TEXT("z"), Z);
|
|
132
|
-
Locations.Add(FVector(X, Y, Z));
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (Locations.Num() == 0) {
|
|
137
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
138
|
-
TEXT("locations array or position required"),
|
|
139
|
-
TEXT("INVALID_ARGUMENT"));
|
|
140
|
-
return true;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (!GEditor || !GEditor->GetEditorWorldContext().World()) {
|
|
144
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
145
|
-
TEXT("Editor world not available"),
|
|
146
|
-
TEXT("EDITOR_NOT_AVAILABLE"));
|
|
147
|
-
return true;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
UWorld *World = GEditor->GetEditorWorldContext().World();
|
|
151
|
-
|
|
152
|
-
if (!UEditorAssetLibrary::DoesAssetExist(FoliageTypePath)) {
|
|
153
|
-
SendAutomationError(
|
|
154
|
-
RequestingSocket, RequestId,
|
|
155
|
-
FString::Printf(TEXT("Foliage type asset not found: %s"),
|
|
156
|
-
*FoliageTypePath),
|
|
157
|
-
TEXT("ASSET_NOT_FOUND"));
|
|
158
|
-
return true;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
UFoliageType *FoliageType =
|
|
162
|
-
LoadObject<UFoliageType>(nullptr, *FoliageTypePath);
|
|
163
|
-
if (!FoliageType) {
|
|
164
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
165
|
-
TEXT("Failed to load foliage type"),
|
|
166
|
-
TEXT("LOAD_FAILED"));
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
AInstancedFoliageActor *IFA =
|
|
171
|
-
GetOrCreateFoliageActorForWorldSafe(World, true);
|
|
172
|
-
if (!IFA) {
|
|
173
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
174
|
-
TEXT("Failed to get foliage actor"),
|
|
175
|
-
TEXT("FOLIAGE_ACTOR_FAILED"));
|
|
176
|
-
return true;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
TArray<FVector> PlacedLocations;
|
|
180
|
-
for (const FVector &Location : Locations) {
|
|
181
|
-
FFoliageInstance Instance;
|
|
182
|
-
Instance.Location = Location;
|
|
183
|
-
Instance.Rotation = FRotator::ZeroRotator;
|
|
184
|
-
Instance.DrawScale3D = FVector3f(1.0f);
|
|
185
|
-
Instance.ZOffset = 0.0f;
|
|
186
|
-
|
|
187
|
-
if (FFoliageInfo *Info = IFA->FindInfo(FoliageType)) {
|
|
188
|
-
Info->AddInstance(FoliageType, Instance, /*InBaseComponent*/ nullptr);
|
|
189
|
-
} else {
|
|
190
|
-
IFA->AddFoliageType(FoliageType);
|
|
191
|
-
if (FFoliageInfo *NewInfo = IFA->FindInfo(FoliageType)) {
|
|
192
|
-
NewInfo->AddInstance(FoliageType, Instance,
|
|
193
|
-
/*InBaseComponent*/ nullptr);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
PlacedLocations.Add(Location);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
IFA->Modify();
|
|
200
|
-
|
|
201
|
-
TSharedPtr<FJsonObject> Resp = MakeShared<FJsonObject>();
|
|
202
|
-
Resp->SetBoolField(TEXT("success"), true);
|
|
203
|
-
Resp->SetStringField(TEXT("foliageTypePath"), FoliageTypePath);
|
|
204
|
-
Resp->SetNumberField(TEXT("instancesPlaced"), PlacedLocations.Num());
|
|
205
|
-
|
|
206
|
-
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
207
|
-
TEXT("Foliage painted successfully"), Resp, FString());
|
|
208
|
-
return true;
|
|
209
|
-
#else
|
|
210
|
-
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
211
|
-
TEXT("paint_foliage requires editor build."), nullptr,
|
|
212
|
-
TEXT("NOT_IMPLEMENTED"));
|
|
213
|
-
return true;
|
|
214
|
-
#endif
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
bool UMcpAutomationBridgeSubsystem::HandleRemoveFoliage(
|
|
218
|
-
const FString &RequestId, const FString &Action,
|
|
219
|
-
const TSharedPtr<FJsonObject> &Payload,
|
|
220
|
-
TSharedPtr<FMcpBridgeWebSocket> RequestingSocket) {
|
|
221
|
-
const FString Lower = Action.ToLower();
|
|
222
|
-
if (!Lower.Equals(TEXT("remove_foliage"), ESearchCase::IgnoreCase)) {
|
|
223
|
-
return false;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
#if WITH_EDITOR
|
|
227
|
-
if (!Payload.IsValid()) {
|
|
228
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
229
|
-
TEXT("remove_foliage payload missing"),
|
|
230
|
-
TEXT("INVALID_PAYLOAD"));
|
|
231
|
-
return true;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
FString FoliageTypePath;
|
|
235
|
-
Payload->TryGetStringField(TEXT("foliageTypePath"), FoliageTypePath);
|
|
236
|
-
|
|
237
|
-
// Auto-resolve simple name
|
|
238
|
-
if (!FoliageTypePath.IsEmpty() &&
|
|
239
|
-
FPaths::GetPath(FoliageTypePath).IsEmpty()) {
|
|
240
|
-
FoliageTypePath =
|
|
241
|
-
FString::Printf(TEXT("/Game/Foliage/%s"), *FoliageTypePath);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
bool bRemoveAll = false;
|
|
245
|
-
Payload->TryGetBoolField(TEXT("removeAll"), bRemoveAll);
|
|
246
|
-
|
|
247
|
-
if (!GEditor || !GEditor->GetEditorWorldContext().World()) {
|
|
248
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
249
|
-
TEXT("Editor world not available"),
|
|
250
|
-
TEXT("EDITOR_NOT_AVAILABLE"));
|
|
251
|
-
return true;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
UWorld *World = GEditor->GetEditorWorldContext().World();
|
|
255
|
-
AInstancedFoliageActor *IFA =
|
|
256
|
-
GetOrCreateFoliageActorForWorldSafe(World, false);
|
|
257
|
-
if (!IFA) {
|
|
258
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
259
|
-
TEXT("No foliage actor found"),
|
|
260
|
-
TEXT("FOLIAGE_ACTOR_NOT_FOUND"));
|
|
261
|
-
return true;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
int32 RemovedCount = 0;
|
|
265
|
-
|
|
266
|
-
if (bRemoveAll) {
|
|
267
|
-
IFA->ForEachFoliageInfo([&](UFoliageType *Type, FFoliageInfo &Info) {
|
|
268
|
-
RemovedCount += Info.Instances.Num();
|
|
269
|
-
Info.Instances.Empty();
|
|
270
|
-
return true;
|
|
271
|
-
});
|
|
272
|
-
IFA->Modify();
|
|
273
|
-
} else if (!FoliageTypePath.IsEmpty()) {
|
|
274
|
-
if (UEditorAssetLibrary::DoesAssetExist(FoliageTypePath)) {
|
|
275
|
-
UFoliageType *FoliageType =
|
|
276
|
-
LoadObject<UFoliageType>(nullptr, *FoliageTypePath);
|
|
277
|
-
if (FoliageType) {
|
|
278
|
-
FFoliageInfo *Info = IFA->FindInfo(FoliageType);
|
|
279
|
-
if (Info) {
|
|
280
|
-
RemovedCount = Info->Instances.Num();
|
|
281
|
-
Info->Instances.Empty();
|
|
282
|
-
IFA->Modify();
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
TSharedPtr<FJsonObject> Resp = MakeShared<FJsonObject>();
|
|
289
|
-
Resp->SetBoolField(TEXT("success"), true);
|
|
290
|
-
Resp->SetNumberField(TEXT("instancesRemoved"), RemovedCount);
|
|
291
|
-
|
|
292
|
-
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
293
|
-
TEXT("Foliage removed successfully"), Resp, FString());
|
|
294
|
-
return true;
|
|
295
|
-
#else
|
|
296
|
-
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
297
|
-
TEXT("remove_foliage requires editor build."), nullptr,
|
|
298
|
-
TEXT("NOT_IMPLEMENTED"));
|
|
299
|
-
return true;
|
|
300
|
-
#endif
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
bool UMcpAutomationBridgeSubsystem::HandleGetFoliageInstances(
|
|
304
|
-
const FString &RequestId, const FString &Action,
|
|
305
|
-
const TSharedPtr<FJsonObject> &Payload,
|
|
306
|
-
TSharedPtr<FMcpBridgeWebSocket> RequestingSocket) {
|
|
307
|
-
const FString Lower = Action.ToLower();
|
|
308
|
-
if (!Lower.Equals(TEXT("get_foliage_instances"), ESearchCase::IgnoreCase)) {
|
|
309
|
-
return false;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
#if WITH_EDITOR
|
|
313
|
-
if (!Payload.IsValid()) {
|
|
314
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
315
|
-
TEXT("get_foliage_instances payload missing"),
|
|
316
|
-
TEXT("INVALID_PAYLOAD"));
|
|
317
|
-
return true;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
FString FoliageTypePath;
|
|
321
|
-
Payload->TryGetStringField(TEXT("foliageTypePath"), FoliageTypePath);
|
|
322
|
-
|
|
323
|
-
// Auto-resolve simple name
|
|
324
|
-
if (!FoliageTypePath.IsEmpty() &&
|
|
325
|
-
FPaths::GetPath(FoliageTypePath).IsEmpty()) {
|
|
326
|
-
FoliageTypePath =
|
|
327
|
-
FString::Printf(TEXT("/Game/Foliage/%s"), *FoliageTypePath);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
if (!GEditor || !GEditor->GetEditorWorldContext().World()) {
|
|
331
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
332
|
-
TEXT("Editor world not available"),
|
|
333
|
-
TEXT("EDITOR_NOT_AVAILABLE"));
|
|
334
|
-
return true;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
UWorld *World = GEditor->GetEditorWorldContext().World();
|
|
338
|
-
AInstancedFoliageActor *IFA =
|
|
339
|
-
GetOrCreateFoliageActorForWorldSafe(World, false);
|
|
340
|
-
if (!IFA) {
|
|
341
|
-
TSharedPtr<FJsonObject> Resp = MakeShared<FJsonObject>();
|
|
342
|
-
Resp->SetBoolField(TEXT("success"), true);
|
|
343
|
-
Resp->SetArrayField(TEXT("instances"), TArray<TSharedPtr<FJsonValue>>());
|
|
344
|
-
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
345
|
-
TEXT("No foliage actor found"), Resp, FString());
|
|
346
|
-
return true;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
TArray<TSharedPtr<FJsonValue>> InstancesArray;
|
|
350
|
-
|
|
351
|
-
if (!FoliageTypePath.IsEmpty()) {
|
|
352
|
-
if (!UEditorAssetLibrary::DoesAssetExist(FoliageTypePath)) {
|
|
353
|
-
// If asked for a specific type that doesn't exist, return empty list
|
|
354
|
-
// gracefully (or could error, but empty list seems safer for 'get')
|
|
355
|
-
TSharedPtr<FJsonObject> Resp = MakeShared<FJsonObject>();
|
|
356
|
-
Resp->SetBoolField(TEXT("success"), true);
|
|
357
|
-
Resp->SetArrayField(TEXT("instances"), TArray<TSharedPtr<FJsonValue>>());
|
|
358
|
-
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
359
|
-
TEXT("Foliage type not found, 0 instances"), Resp,
|
|
360
|
-
FString());
|
|
361
|
-
return true;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
UFoliageType *FoliageType =
|
|
365
|
-
LoadObject<UFoliageType>(nullptr, *FoliageTypePath);
|
|
366
|
-
if (FoliageType) {
|
|
367
|
-
FFoliageInfo *Info = IFA->FindInfo(FoliageType);
|
|
368
|
-
if (Info) {
|
|
369
|
-
for (const FFoliageInstance &Inst : Info->Instances) {
|
|
370
|
-
TSharedPtr<FJsonObject> InstObj = MakeShared<FJsonObject>();
|
|
371
|
-
InstObj->SetNumberField(TEXT("x"), Inst.Location.X);
|
|
372
|
-
InstObj->SetNumberField(TEXT("y"), Inst.Location.Y);
|
|
373
|
-
InstObj->SetNumberField(TEXT("z"), Inst.Location.Z);
|
|
374
|
-
InstObj->SetNumberField(TEXT("pitch"), Inst.Rotation.Pitch);
|
|
375
|
-
InstObj->SetNumberField(TEXT("yaw"), Inst.Rotation.Yaw);
|
|
376
|
-
InstObj->SetNumberField(TEXT("roll"), Inst.Rotation.Roll);
|
|
377
|
-
InstancesArray.Add(MakeShared<FJsonValueObject>(InstObj));
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
} else {
|
|
382
|
-
IFA->ForEachFoliageInfo([&](UFoliageType *Type, FFoliageInfo &Info) {
|
|
383
|
-
for (const FFoliageInstance &Inst : Info.Instances) {
|
|
384
|
-
TSharedPtr<FJsonObject> InstObj = MakeShared<FJsonObject>();
|
|
385
|
-
InstObj->SetStringField(TEXT("foliageType"), Type->GetPathName());
|
|
386
|
-
InstObj->SetNumberField(TEXT("x"), Inst.Location.X);
|
|
387
|
-
InstObj->SetNumberField(TEXT("y"), Inst.Location.Y);
|
|
388
|
-
InstObj->SetNumberField(TEXT("z"), Inst.Location.Z);
|
|
389
|
-
InstancesArray.Add(MakeShared<FJsonValueObject>(InstObj));
|
|
390
|
-
}
|
|
391
|
-
return true;
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
TSharedPtr<FJsonObject> Resp = MakeShared<FJsonObject>();
|
|
396
|
-
Resp->SetBoolField(TEXT("success"), true);
|
|
397
|
-
Resp->SetArrayField(TEXT("instances"), InstancesArray);
|
|
398
|
-
Resp->SetNumberField(TEXT("count"), InstancesArray.Num());
|
|
399
|
-
|
|
400
|
-
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
401
|
-
TEXT("Foliage instances retrieved"), Resp, FString());
|
|
402
|
-
return true;
|
|
403
|
-
#else
|
|
404
|
-
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
405
|
-
TEXT("get_foliage_instances requires editor build."),
|
|
406
|
-
nullptr, TEXT("NOT_IMPLEMENTED"));
|
|
407
|
-
return true;
|
|
408
|
-
#endif
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
bool UMcpAutomationBridgeSubsystem::HandleAddFoliageType(
|
|
412
|
-
const FString &RequestId, const FString &Action,
|
|
413
|
-
const TSharedPtr<FJsonObject> &Payload,
|
|
414
|
-
TSharedPtr<FMcpBridgeWebSocket> RequestingSocket) {
|
|
415
|
-
const FString Lower = Action.ToLower();
|
|
416
|
-
if (!Lower.Equals(TEXT("add_foliage_type"), ESearchCase::IgnoreCase)) {
|
|
417
|
-
return false;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
#if WITH_EDITOR
|
|
421
|
-
if (!Payload.IsValid()) {
|
|
422
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
423
|
-
TEXT("add_foliage_type payload missing"),
|
|
424
|
-
TEXT("INVALID_PAYLOAD"));
|
|
425
|
-
return true;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
FString Name;
|
|
429
|
-
if (!Payload->TryGetStringField(TEXT("name"), Name) || Name.IsEmpty()) {
|
|
430
|
-
SendAutomationError(RequestingSocket, RequestId, TEXT("name required"),
|
|
431
|
-
TEXT("INVALID_ARGUMENT"));
|
|
432
|
-
return true;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
FString MeshPath;
|
|
436
|
-
if (!Payload->TryGetStringField(TEXT("meshPath"), MeshPath) ||
|
|
437
|
-
MeshPath.IsEmpty() ||
|
|
438
|
-
MeshPath.Equals(TEXT("undefined"), ESearchCase::IgnoreCase)) {
|
|
439
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
440
|
-
TEXT("valid meshPath required"),
|
|
441
|
-
TEXT("INVALID_ARGUMENT"));
|
|
442
|
-
return true;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
double Density = 100.0;
|
|
446
|
-
if (Payload->TryGetNumberField(TEXT("density"), Density)) {
|
|
447
|
-
if (Density < 0.0) {
|
|
448
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
449
|
-
TEXT("density must be non-negative"),
|
|
450
|
-
TEXT("INVALID_ARGUMENT"));
|
|
451
|
-
return true;
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
double MinScale = 1.0, MaxScale = 1.0;
|
|
456
|
-
Payload->TryGetNumberField(TEXT("minScale"), MinScale);
|
|
457
|
-
Payload->TryGetNumberField(TEXT("maxScale"), MaxScale);
|
|
458
|
-
|
|
459
|
-
if (MinScale <= 0.0 || MaxScale <= 0.0) {
|
|
460
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
461
|
-
TEXT("Scales must be positive"),
|
|
462
|
-
TEXT("INVALID_ARGUMENT"));
|
|
463
|
-
return true;
|
|
464
|
-
}
|
|
465
|
-
if (MinScale > MaxScale) {
|
|
466
|
-
SendAutomationError(
|
|
467
|
-
RequestingSocket, RequestId,
|
|
468
|
-
FString::Printf(
|
|
469
|
-
TEXT("minScale (%f) cannot be greater than maxScale (%f)"),
|
|
470
|
-
MinScale, MaxScale),
|
|
471
|
-
TEXT("INVALID_ARGUMENT"));
|
|
472
|
-
return true;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
bool AlignToNormal = true;
|
|
476
|
-
Payload->TryGetBoolField(TEXT("alignToNormal"), AlignToNormal);
|
|
477
|
-
|
|
478
|
-
bool RandomYaw = true;
|
|
479
|
-
Payload->TryGetBoolField(TEXT("randomYaw"), RandomYaw);
|
|
480
|
-
|
|
481
|
-
// Use Silent load to avoid engine warnings
|
|
482
|
-
UStaticMesh *StaticMesh = LoadObject<UStaticMesh>(nullptr, *MeshPath);
|
|
483
|
-
if (!StaticMesh) {
|
|
484
|
-
// Try finding it if it's just a short name or missing extension
|
|
485
|
-
if (FPackageName::IsValidLongPackageName(MeshPath)) {
|
|
486
|
-
StaticMesh = LoadObject<UStaticMesh>(nullptr, *MeshPath);
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
if (!StaticMesh) {
|
|
490
|
-
// Try assuming it's in /Game/ if not specified (naive fallback)
|
|
491
|
-
if (!MeshPath.StartsWith(TEXT("/"))) {
|
|
492
|
-
FString GamePath = FString::Printf(TEXT("/Game/%s"), *MeshPath);
|
|
493
|
-
StaticMesh = LoadObject<UStaticMesh>(nullptr, *GamePath);
|
|
494
|
-
if (!StaticMesh) {
|
|
495
|
-
// Try with inferred name: /Game/Path/Values.Values
|
|
496
|
-
FString BaseName = FPaths::GetBaseFilename(MeshPath);
|
|
497
|
-
GamePath = FString::Printf(TEXT("/Game/%s.%s"), *MeshPath, *BaseName);
|
|
498
|
-
StaticMesh = LoadObject<UStaticMesh>(nullptr, *GamePath);
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
if (!StaticMesh) {
|
|
505
|
-
if (!FPackageName::IsValidLongPackageName(MeshPath)) {
|
|
506
|
-
SendAutomationError(
|
|
507
|
-
RequestingSocket, RequestId,
|
|
508
|
-
FString::Printf(TEXT("Invalid package path: %s"), *MeshPath),
|
|
509
|
-
TEXT("INVALID_ARGUMENT"));
|
|
510
|
-
} else {
|
|
511
|
-
SendAutomationError(
|
|
512
|
-
RequestingSocket, RequestId,
|
|
513
|
-
FString::Printf(TEXT("Static mesh not found: %s"), *MeshPath),
|
|
514
|
-
TEXT("ASSET_NOT_FOUND"));
|
|
515
|
-
}
|
|
516
|
-
return true;
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
FString PackagePath = TEXT("/Game/Foliage");
|
|
520
|
-
FString AssetName = Name;
|
|
521
|
-
FString FullPackagePath =
|
|
522
|
-
FString::Printf(TEXT("%s/%s"), *PackagePath, *AssetName);
|
|
523
|
-
|
|
524
|
-
UPackage *Package = CreatePackage(*FullPackagePath);
|
|
525
|
-
if (!Package) {
|
|
526
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
527
|
-
TEXT("Failed to create package"),
|
|
528
|
-
TEXT("PACKAGE_CREATION_FAILED"));
|
|
529
|
-
return true;
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
UFoliageType_InstancedStaticMesh *FoliageType = nullptr;
|
|
533
|
-
if (UEditorAssetLibrary::DoesAssetExist(FullPackagePath)) {
|
|
534
|
-
FoliageType =
|
|
535
|
-
LoadObject<UFoliageType_InstancedStaticMesh>(Package, *AssetName);
|
|
536
|
-
}
|
|
537
|
-
if (!FoliageType) {
|
|
538
|
-
FoliageType = NewObject<UFoliageType_InstancedStaticMesh>(
|
|
539
|
-
Package, FName(*AssetName), RF_Public | RF_Standalone);
|
|
540
|
-
}
|
|
541
|
-
if (!FoliageType) {
|
|
542
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
543
|
-
TEXT("Failed to create foliage type"),
|
|
544
|
-
TEXT("CREATION_FAILED"));
|
|
545
|
-
return true;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
FoliageType->SetStaticMesh(StaticMesh);
|
|
549
|
-
FoliageType->Density = static_cast<float>(Density);
|
|
550
|
-
FoliageType->Scaling = EFoliageScaling::Uniform;
|
|
551
|
-
FoliageType->ScaleX.Min = static_cast<float>(MinScale);
|
|
552
|
-
FoliageType->ScaleX.Max = static_cast<float>(MaxScale);
|
|
553
|
-
FoliageType->ScaleY.Min = static_cast<float>(MinScale);
|
|
554
|
-
FoliageType->ScaleY.Max = static_cast<float>(MaxScale);
|
|
555
|
-
FoliageType->ScaleZ.Min = static_cast<float>(MinScale);
|
|
556
|
-
FoliageType->ScaleZ.Max = static_cast<float>(MaxScale);
|
|
557
|
-
FoliageType->AlignToNormal = AlignToNormal;
|
|
558
|
-
FoliageType->RandomYaw = RandomYaw;
|
|
559
|
-
FoliageType->ReapplyDensity = true;
|
|
560
|
-
|
|
561
|
-
Package->MarkPackageDirty();
|
|
562
|
-
FAssetRegistryModule::AssetCreated(FoliageType);
|
|
563
|
-
|
|
564
|
-
FString PackageFileName = FPackageName::LongPackageNameToFilename(
|
|
565
|
-
FullPackagePath, FPackageName::GetAssetPackageExtension());
|
|
566
|
-
FSavePackageArgs SaveArgs;
|
|
567
|
-
SaveArgs.TopLevelFlags = RF_Public | RF_Standalone;
|
|
568
|
-
SaveArgs.Error = GError;
|
|
569
|
-
SaveArgs.SaveFlags = SAVE_NoError;
|
|
570
|
-
bool bSaved =
|
|
571
|
-
UPackage::SavePackage(Package, FoliageType, *PackageFileName, SaveArgs);
|
|
572
|
-
|
|
573
|
-
if (!bSaved) {
|
|
574
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
575
|
-
TEXT("Failed to save foliage type asset"),
|
|
576
|
-
TEXT("SAVE_FAILED"));
|
|
577
|
-
return true;
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
TSharedPtr<FJsonObject> Resp = MakeShared<FJsonObject>();
|
|
581
|
-
Resp->SetBoolField(TEXT("success"), true);
|
|
582
|
-
Resp->SetBoolField(TEXT("created"), true);
|
|
583
|
-
Resp->SetBoolField(TEXT("exists_after"), true);
|
|
584
|
-
Resp->SetStringField(TEXT("asset_path"), FoliageType->GetPathName());
|
|
585
|
-
Resp->SetStringField(TEXT("used_mesh"), MeshPath);
|
|
586
|
-
Resp->SetStringField(TEXT("method"), TEXT("native_asset_creation"));
|
|
587
|
-
|
|
588
|
-
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
589
|
-
TEXT("Foliage type created successfully"), Resp,
|
|
590
|
-
FString());
|
|
591
|
-
|
|
592
|
-
return true;
|
|
593
|
-
#else
|
|
594
|
-
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
595
|
-
TEXT("add_foliage_type requires editor build."),
|
|
596
|
-
nullptr, TEXT("NOT_IMPLEMENTED"));
|
|
597
|
-
return true;
|
|
598
|
-
#endif
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
bool UMcpAutomationBridgeSubsystem::HandleAddFoliageInstances(
|
|
602
|
-
const FString &RequestId, const FString &Action,
|
|
603
|
-
const TSharedPtr<FJsonObject> &Payload,
|
|
604
|
-
TSharedPtr<FMcpBridgeWebSocket> RequestingSocket) {
|
|
605
|
-
const FString Lower = Action.ToLower();
|
|
606
|
-
if (!Lower.Equals(TEXT("add_foliage_instances"), ESearchCase::IgnoreCase)) {
|
|
607
|
-
return false;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
#if WITH_EDITOR
|
|
611
|
-
if (!Payload.IsValid()) {
|
|
612
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
613
|
-
TEXT("add_foliage_instances payload missing"),
|
|
614
|
-
TEXT("INVALID_PAYLOAD"));
|
|
615
|
-
return true;
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
FString FoliageTypePath;
|
|
619
|
-
if (!Payload->TryGetStringField(TEXT("foliageTypePath"), FoliageTypePath)) {
|
|
620
|
-
Payload->TryGetStringField(TEXT("foliageType"), FoliageTypePath);
|
|
621
|
-
}
|
|
622
|
-
if (FoliageTypePath.IsEmpty()) {
|
|
623
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
624
|
-
TEXT("foliageType or foliageTypePath required"),
|
|
625
|
-
TEXT("INVALID_ARGUMENT"));
|
|
626
|
-
return true;
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
// Auto-resolve simple name
|
|
630
|
-
if (!FoliageTypePath.IsEmpty() &&
|
|
631
|
-
FPaths::GetPath(FoliageTypePath).IsEmpty()) {
|
|
632
|
-
FoliageTypePath =
|
|
633
|
-
FString::Printf(TEXT("/Game/Foliage/%s"), *FoliageTypePath);
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
// Parse transforms -> locations (optional rotation/scale ignored for now)
|
|
637
|
-
TArray<FVector> Locations;
|
|
638
|
-
const TArray<TSharedPtr<FJsonValue>> *Transforms = nullptr;
|
|
639
|
-
if (Payload->TryGetArrayField(TEXT("transforms"), Transforms) && Transforms) {
|
|
640
|
-
for (const TSharedPtr<FJsonValue> &V : *Transforms) {
|
|
641
|
-
if (!V.IsValid() || V->Type != EJson::Object)
|
|
642
|
-
continue;
|
|
643
|
-
const TSharedPtr<FJsonObject> *TObj = nullptr;
|
|
644
|
-
if (!V->TryGetObject(TObj) || !TObj)
|
|
645
|
-
continue;
|
|
646
|
-
const TSharedPtr<FJsonObject> *LocObj = nullptr;
|
|
647
|
-
if ((*TObj)->TryGetObjectField(TEXT("location"), LocObj) && LocObj) {
|
|
648
|
-
double X = 0, Y = 0, Z = 0;
|
|
649
|
-
(*LocObj)->TryGetNumberField(TEXT("x"), X);
|
|
650
|
-
(*LocObj)->TryGetNumberField(TEXT("y"), Y);
|
|
651
|
-
(*LocObj)->TryGetNumberField(TEXT("z"), Z);
|
|
652
|
-
Locations.Add(FVector(X, Y, Z));
|
|
653
|
-
} else {
|
|
654
|
-
// Accept location as array [x,y,z]
|
|
655
|
-
const TArray<TSharedPtr<FJsonValue>> *LocArr = nullptr;
|
|
656
|
-
if ((*TObj)->TryGetArrayField(TEXT("location"), LocArr) && LocArr &&
|
|
657
|
-
LocArr->Num() >= 3) {
|
|
658
|
-
double X = (*LocArr)[0]->AsNumber();
|
|
659
|
-
double Y = (*LocArr)[1]->AsNumber();
|
|
660
|
-
double Z = (*LocArr)[2]->AsNumber();
|
|
661
|
-
Locations.Add(FVector(X, Y, Z));
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
if (Locations.Num() == 0) {
|
|
668
|
-
// Fallback to 'locations' if provided
|
|
669
|
-
const TArray<TSharedPtr<FJsonValue>> *LocationsArray = nullptr;
|
|
670
|
-
if (Payload->TryGetArrayField(TEXT("locations"), LocationsArray) &&
|
|
671
|
-
LocationsArray) {
|
|
672
|
-
for (const TSharedPtr<FJsonValue> &Val : *LocationsArray) {
|
|
673
|
-
if (Val.IsValid() && Val->Type == EJson::Object) {
|
|
674
|
-
const TSharedPtr<FJsonObject> *Obj = nullptr;
|
|
675
|
-
if (Val->TryGetObject(Obj) && Obj) {
|
|
676
|
-
double X = 0, Y = 0, Z = 0;
|
|
677
|
-
(*Obj)->TryGetNumberField(TEXT("x"), X);
|
|
678
|
-
(*Obj)->TryGetNumberField(TEXT("y"), Y);
|
|
679
|
-
(*Obj)->TryGetNumberField(TEXT("z"), Z);
|
|
680
|
-
Locations.Add(FVector(X, Y, Z));
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
if (!GEditor || !GEditor->GetEditorWorldContext().World()) {
|
|
688
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
689
|
-
TEXT("Editor world not available"),
|
|
690
|
-
TEXT("EDITOR_NOT_AVAILABLE"));
|
|
691
|
-
return true;
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
UWorld *World = GEditor->GetEditorWorldContext().World();
|
|
695
|
-
|
|
696
|
-
// Use Silent load to avoid engine warnings
|
|
697
|
-
UFoliageType *FoliageType = Cast<UFoliageType>(
|
|
698
|
-
StaticLoadObject(UFoliageType::StaticClass(), nullptr, *FoliageTypePath,
|
|
699
|
-
nullptr, LOAD_NoWarn));
|
|
700
|
-
if (!FoliageType) {
|
|
701
|
-
SendAutomationError(
|
|
702
|
-
RequestingSocket, RequestId,
|
|
703
|
-
FString::Printf(TEXT("Foliage type asset not found: %s"),
|
|
704
|
-
*FoliageTypePath),
|
|
705
|
-
TEXT("ASSET_NOT_FOUND"));
|
|
706
|
-
return true;
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
AInstancedFoliageActor *IFA =
|
|
710
|
-
GetOrCreateFoliageActorForWorldSafe(World, true);
|
|
711
|
-
if (!IFA) {
|
|
712
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
713
|
-
TEXT("Failed to get foliage actor"),
|
|
714
|
-
TEXT("FOLIAGE_ACTOR_FAILED"));
|
|
715
|
-
return true;
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
int32 Added = 0;
|
|
719
|
-
for (const FVector &Location : Locations) {
|
|
720
|
-
FFoliageInstance Instance;
|
|
721
|
-
Instance.Location = Location;
|
|
722
|
-
Instance.Rotation = FRotator::ZeroRotator;
|
|
723
|
-
Instance.DrawScale3D = FVector3f(1.0f);
|
|
724
|
-
|
|
725
|
-
if (FFoliageInfo *Info = IFA->FindInfo(FoliageType)) {
|
|
726
|
-
Info->AddInstance(FoliageType, Instance, nullptr);
|
|
727
|
-
} else {
|
|
728
|
-
IFA->AddFoliageType(FoliageType);
|
|
729
|
-
if (FFoliageInfo *NewInfo = IFA->FindInfo(FoliageType)) {
|
|
730
|
-
NewInfo->AddInstance(FoliageType, Instance, nullptr);
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
++Added;
|
|
734
|
-
}
|
|
735
|
-
IFA->Modify();
|
|
736
|
-
|
|
737
|
-
TSharedPtr<FJsonObject> Resp = MakeShared<FJsonObject>();
|
|
738
|
-
Resp->SetBoolField(TEXT("success"), true);
|
|
739
|
-
Resp->SetNumberField(TEXT("instances_count"), Added);
|
|
740
|
-
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
741
|
-
TEXT("Foliage instances added"), Resp, FString());
|
|
742
|
-
return true;
|
|
743
|
-
#else
|
|
744
|
-
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
745
|
-
TEXT("add_foliage_instances requires editor build."),
|
|
746
|
-
nullptr, TEXT("NOT_IMPLEMENTED"));
|
|
747
|
-
return true;
|
|
748
|
-
#endif
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
bool UMcpAutomationBridgeSubsystem::HandleCreateProceduralFoliage(
|
|
752
|
-
const FString &RequestId, const FString &Action,
|
|
753
|
-
const TSharedPtr<FJsonObject> &Payload,
|
|
754
|
-
TSharedPtr<FMcpBridgeWebSocket> RequestingSocket) {
|
|
755
|
-
const FString Lower = Action.ToLower();
|
|
756
|
-
if (!Lower.Equals(TEXT("create_procedural_foliage"),
|
|
757
|
-
ESearchCase::IgnoreCase)) {
|
|
758
|
-
return false;
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
#if WITH_EDITOR
|
|
762
|
-
if (!Payload.IsValid()) {
|
|
763
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
764
|
-
TEXT("create_procedural_foliage payload missing"),
|
|
765
|
-
TEXT("INVALID_PAYLOAD"));
|
|
766
|
-
return true;
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
FString Name;
|
|
770
|
-
if (!Payload->TryGetStringField(TEXT("name"), Name) || Name.IsEmpty()) {
|
|
771
|
-
SendAutomationError(RequestingSocket, RequestId, TEXT("name required"),
|
|
772
|
-
TEXT("INVALID_ARGUMENT"));
|
|
773
|
-
return true;
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
const TSharedPtr<FJsonObject> *BoundsObj = nullptr;
|
|
777
|
-
if (!Payload->TryGetObjectField(TEXT("bounds"), BoundsObj) || !BoundsObj) {
|
|
778
|
-
SendAutomationError(RequestingSocket, RequestId, TEXT("bounds required"),
|
|
779
|
-
TEXT("INVALID_ARGUMENT"));
|
|
780
|
-
return true;
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
FVector Location(0, 0, 0);
|
|
784
|
-
FVector Size(1000, 1000, 1000);
|
|
785
|
-
|
|
786
|
-
const TSharedPtr<FJsonObject> *LocObj = nullptr;
|
|
787
|
-
if ((*BoundsObj)->TryGetObjectField(TEXT("location"), LocObj) && LocObj) {
|
|
788
|
-
(*LocObj)->TryGetNumberField(TEXT("x"), Location.X);
|
|
789
|
-
(*LocObj)->TryGetNumberField(TEXT("y"), Location.Y);
|
|
790
|
-
(*LocObj)->TryGetNumberField(TEXT("z"), Location.Z);
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
const TSharedPtr<FJsonObject> *SizeObj = nullptr;
|
|
794
|
-
if ((*BoundsObj)->TryGetObjectField(TEXT("size"), SizeObj) && SizeObj) {
|
|
795
|
-
(*SizeObj)->TryGetNumberField(TEXT("x"), Size.X);
|
|
796
|
-
(*SizeObj)->TryGetNumberField(TEXT("y"), Size.Y);
|
|
797
|
-
(*SizeObj)->TryGetNumberField(TEXT("z"), Size.Z);
|
|
798
|
-
}
|
|
799
|
-
// If size is array
|
|
800
|
-
const TArray<TSharedPtr<FJsonValue>> *SizeArr = nullptr;
|
|
801
|
-
if ((*BoundsObj)->TryGetArrayField(TEXT("size"), SizeArr) && SizeArr &&
|
|
802
|
-
SizeArr->Num() >= 3) {
|
|
803
|
-
Size.X = (*SizeArr)[0]->AsNumber();
|
|
804
|
-
Size.Y = (*SizeArr)[1]->AsNumber();
|
|
805
|
-
Size.Z = (*SizeArr)[2]->AsNumber();
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
const TArray<TSharedPtr<FJsonValue>> *FoliageTypesArr = nullptr;
|
|
809
|
-
if (!Payload->TryGetArrayField(TEXT("foliageTypes"), FoliageTypesArr)) {
|
|
810
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
811
|
-
TEXT("foliageTypes array required"),
|
|
812
|
-
TEXT("INVALID_ARGUMENT"));
|
|
813
|
-
return true;
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
int32 Seed = 12345;
|
|
817
|
-
Payload->TryGetNumberField(TEXT("seed"), Seed);
|
|
818
|
-
|
|
819
|
-
if (!GEditor) {
|
|
820
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
821
|
-
TEXT("Editor not available"),
|
|
822
|
-
TEXT("EDITOR_NOT_AVAILABLE"));
|
|
823
|
-
return true;
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
// Create Spawner Asset
|
|
827
|
-
FString PackagePath = TEXT("/Game/ProceduralFoliage");
|
|
828
|
-
FString AssetName = Name + TEXT("_Spawner");
|
|
829
|
-
FString FullPackagePath =
|
|
830
|
-
FString::Printf(TEXT("%s/%s"), *PackagePath, *AssetName);
|
|
831
|
-
|
|
832
|
-
UPackage *Package = CreatePackage(*FullPackagePath);
|
|
833
|
-
UProceduralFoliageSpawner *Spawner = NewObject<UProceduralFoliageSpawner>(
|
|
834
|
-
Package, FName(*AssetName), RF_Public | RF_Standalone);
|
|
835
|
-
if (!Spawner) {
|
|
836
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
837
|
-
TEXT("Failed to create spawner asset"),
|
|
838
|
-
TEXT("CREATION_FAILED"));
|
|
839
|
-
return true;
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
Spawner->TileSize = 1000.0f; // Default tile size
|
|
843
|
-
Spawner->NumUniqueTiles = 10;
|
|
844
|
-
Spawner->RandomSeed = Seed;
|
|
845
|
-
|
|
846
|
-
// Add foliage types to spawner
|
|
847
|
-
int32 TypeIndex = 0;
|
|
848
|
-
for (const TSharedPtr<FJsonValue> &Val : *FoliageTypesArr) {
|
|
849
|
-
const TSharedPtr<FJsonObject> *TypeObj = nullptr;
|
|
850
|
-
if (Val->TryGetObject(TypeObj) && TypeObj) {
|
|
851
|
-
FString MeshPath;
|
|
852
|
-
(*TypeObj)->TryGetStringField(TEXT("meshPath"), MeshPath);
|
|
853
|
-
double Density = 10.0;
|
|
854
|
-
(*TypeObj)->TryGetNumberField(TEXT("density"), Density);
|
|
855
|
-
|
|
856
|
-
if (!MeshPath.IsEmpty()) {
|
|
857
|
-
UStaticMesh *Mesh = LoadObject<UStaticMesh>(nullptr, *MeshPath);
|
|
858
|
-
if (Mesh) {
|
|
859
|
-
// Create FoliageType asset
|
|
860
|
-
FString FTName =
|
|
861
|
-
FString::Printf(TEXT("%s_FT_%d"), *AssetName, TypeIndex++);
|
|
862
|
-
FString FTPackagePath =
|
|
863
|
-
FString::Printf(TEXT("%s/%s"), *PackagePath, *FTName);
|
|
864
|
-
UPackage *FTPackage = CreatePackage(*FTPackagePath);
|
|
865
|
-
UFoliageType_InstancedStaticMesh *FT =
|
|
866
|
-
NewObject<UFoliageType_InstancedStaticMesh>(
|
|
867
|
-
FTPackage, FName(*FTName), RF_Public | RF_Standalone);
|
|
868
|
-
FT->SetStaticMesh(Mesh);
|
|
869
|
-
FT->Density = (float)Density;
|
|
870
|
-
FT->ReapplyDensity = true;
|
|
871
|
-
|
|
872
|
-
FTPackage->MarkPackageDirty();
|
|
873
|
-
FAssetRegistryModule::AssetCreated(FT);
|
|
874
|
-
|
|
875
|
-
// Add to Spawner using Reflection (since FoliageTypes is private)
|
|
876
|
-
FArrayProperty *FoliageTypesProp = FindFProperty<FArrayProperty>(
|
|
877
|
-
Spawner->GetClass(), TEXT("FoliageTypes"));
|
|
878
|
-
if (FoliageTypesProp) {
|
|
879
|
-
FScriptArrayHelper Helper(
|
|
880
|
-
FoliageTypesProp,
|
|
881
|
-
FoliageTypesProp->ContainerPtrToValuePtr<void>(Spawner));
|
|
882
|
-
int32 Index = Helper.AddValue();
|
|
883
|
-
uint8 *RawData = Helper.GetRawPtr(Index);
|
|
884
|
-
|
|
885
|
-
UScriptStruct *Struct = FFoliageTypeObject::StaticStruct();
|
|
886
|
-
|
|
887
|
-
FObjectProperty *ObjProp = FindFProperty<FObjectProperty>(
|
|
888
|
-
Struct, TEXT("FoliageTypeObject"));
|
|
889
|
-
if (ObjProp) {
|
|
890
|
-
ObjProp->SetObjectPropertyValue(
|
|
891
|
-
ObjProp->ContainerPtrToValuePtr<void>(RawData), FT);
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
FBoolProperty *BoolProp =
|
|
895
|
-
FindFProperty<FBoolProperty>(Struct, TEXT("bIsAsset"));
|
|
896
|
-
if (BoolProp) {
|
|
897
|
-
BoolProp->SetPropertyValue(
|
|
898
|
-
BoolProp->ContainerPtrToValuePtr<void>(RawData), true);
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
Package->MarkPackageDirty();
|
|
907
|
-
FAssetRegistryModule::AssetCreated(Spawner);
|
|
908
|
-
|
|
909
|
-
// Spawn Volume
|
|
910
|
-
AProceduralFoliageVolume *Volume = Cast<AProceduralFoliageVolume>(
|
|
911
|
-
SpawnActorInActiveWorld<AActor>(AProceduralFoliageVolume::StaticClass(),
|
|
912
|
-
Location, FRotator::ZeroRotator, Name));
|
|
913
|
-
if (!Volume) {
|
|
914
|
-
SendAutomationError(RequestingSocket, RequestId,
|
|
915
|
-
TEXT("Failed to spawn volume"), TEXT("SPAWN_FAILED"));
|
|
916
|
-
return true;
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
Volume->SetActorLabel(Name);
|
|
920
|
-
Volume->SetActorScale3D(
|
|
921
|
-
Size / 200.0f); // Volume default size is 200x200x200? No, usually 100.
|
|
922
|
-
// BrushComponent default is 200.
|
|
923
|
-
// Let's assume standard brush size.
|
|
924
|
-
|
|
925
|
-
if (UProceduralFoliageComponent *ProcComp = Volume->ProceduralComponent) {
|
|
926
|
-
ProcComp->FoliageSpawner = Spawner;
|
|
927
|
-
ProcComp->TileOverlap = 0.0f;
|
|
928
|
-
|
|
929
|
-
// Resimulate
|
|
930
|
-
// Note: ResimulateProceduralFoliage might be async or require specific
|
|
931
|
-
// context. In 5.6 it might take a callback or be void. We'll try calling
|
|
932
|
-
// it.
|
|
933
|
-
bool bResult = ProcComp->ResimulateProceduralFoliage(
|
|
934
|
-
[](const TArray<FDesiredFoliageInstance> &) {});
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
TSharedPtr<FJsonObject> Resp = MakeShared<FJsonObject>();
|
|
938
|
-
Resp->SetBoolField(TEXT("success"), true);
|
|
939
|
-
Resp->SetStringField(TEXT("volume_actor"), Volume->GetActorLabel());
|
|
940
|
-
Resp->SetStringField(TEXT("spawner_path"), Spawner->GetPathName());
|
|
941
|
-
Resp->SetNumberField(TEXT("foliage_types_count"), TypeIndex);
|
|
942
|
-
Resp->SetBoolField(TEXT("resimulated"), true);
|
|
943
|
-
|
|
944
|
-
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
945
|
-
TEXT("Procedural foliage created"), Resp, FString());
|
|
946
|
-
return true;
|
|
947
|
-
#else
|
|
948
|
-
SendAutomationResponse(
|
|
949
|
-
RequestingSocket, RequestId, false,
|
|
950
|
-
TEXT("create_procedural_foliage requires editor build."), nullptr,
|
|
951
|
-
TEXT("NOT_IMPLEMENTED"));
|
|
952
|
-
return true;
|
|
953
|
-
#endif
|
|
954
|
-
}
|