ue-mcp 1.4.13 → 1.4.14-beta.2
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/README.md +5 -5
- package/dist/bridge/bridge-timeouts.js +4 -0
- package/dist/bridge/bridge-timeouts.js.map +1 -1
- package/dist/cli/cli-commands.js +1 -0
- package/dist/cli/cli-commands.js.map +1 -1
- package/dist/cli/doctor.js +2 -1
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/init.js +1 -1
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/projects-cli.d.ts +3 -0
- package/dist/cli/projects-cli.js +72 -0
- package/dist/cli/projects-cli.js.map +1 -0
- package/dist/config/user-state.d.ts +10 -0
- package/dist/config/user-state.js +21 -0
- package/dist/config/user-state.js.map +1 -1
- package/dist/core/env.d.ts +2 -0
- package/dist/core/env.js +2 -0
- package/dist/core/env.js.map +1 -1
- package/dist/core/types.d.ts +27 -0
- package/dist/daemon/daemon.js +44 -5
- package/dist/daemon/daemon.js.map +1 -1
- package/dist/daemon/extension-api.d.ts +8 -5
- package/dist/daemon-api.d.ts +2 -1
- package/dist/daemon-api.js +1 -0
- package/dist/daemon-api.js.map +1 -1
- package/dist/dispatch/offline.js +1 -0
- package/dist/dispatch/offline.js.map +1 -1
- package/dist/editor/dialog-guard.d.ts +12 -2
- package/dist/editor/dialog-guard.js +68 -2
- package/dist/editor/dialog-guard.js.map +1 -1
- package/dist/editor/editor-control.js +1 -1
- package/dist/editor/editor-control.js.map +1 -1
- package/dist/flow/write-methods.js +1 -1
- package/dist/flow/write-methods.js.map +1 -1
- package/dist/machine/projects.d.ts +85 -0
- package/dist/machine/projects.js +286 -0
- package/dist/machine/projects.js.map +1 -0
- package/dist/pie/script-events.d.ts +4 -1
- package/dist/pie/script-events.js.map +1 -1
- package/dist/surface/context/instructions.js +20 -0
- package/dist/surface/context/instructions.js.map +1 -1
- package/dist/tool-counts.json +12 -12
- package/dist/tools/asset.js +2 -1
- package/dist/tools/asset.js.map +1 -1
- package/dist/tools/editor.js +1 -1
- package/dist/tools/editor.js.map +1 -1
- package/dist/tools/epic/effects.js +11 -0
- package/dist/tools/epic/effects.js.map +1 -1
- package/dist/tools/epic/fab.generated.d.ts +6 -0
- package/dist/tools/epic/fab.generated.js +67 -0
- package/dist/tools/epic/fab.generated.js.map +1 -0
- package/dist/tools/epic/index.d.ts +2 -0
- package/dist/tools/epic/index.js +2 -0
- package/dist/tools/epic/index.js.map +1 -1
- package/dist/tools/epic/toolset-routes.js +2 -0
- package/dist/tools/epic/toolset-routes.js.map +1 -1
- package/dist/tools/epic.js +4 -4
- package/dist/tools/epic.js.map +1 -1
- package/dist/tools/fab-epic.d.ts +23 -0
- package/dist/tools/fab-epic.js +109 -0
- package/dist/tools/fab-epic.js.map +1 -0
- package/dist/tools/fab.js +27 -18
- package/dist/tools/fab.js.map +1 -1
- package/dist/tools/level.js +9 -2
- package/dist/tools/level.js.map +1 -1
- package/dist/tools/material.js +1 -1
- package/dist/tools/material.js.map +1 -1
- package/dist/tools/pie.js +1 -1
- package/dist/tools/pie.js.map +1 -1
- package/dist/tools/specs/asset.generated.js +92 -3
- package/dist/tools/specs/asset.generated.js.map +1 -1
- package/dist/tools/specs/fab.generated.js +143 -3
- package/dist/tools/specs/fab.generated.js.map +1 -1
- package/dist/tools/specs/level.generated.js +183 -9
- package/dist/tools/specs/level.generated.js.map +1 -1
- package/dist/tools/specs/pie.generated.js +28 -8
- package/dist/tools/specs/pie.generated.js.map +1 -1
- package/dist/tools/specs/widget.generated.js +8 -1
- package/dist/tools/specs/widget.generated.js.map +1 -1
- package/dist/ue-mcp.default.yml +522 -76
- package/package.json +2 -2
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/BridgeServer.cpp +26 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers.cpp +24 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers.h +7 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers_Mesh.cpp +483 -10
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Dialog/DialogHandlers.cpp +345 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Epic/EpicHandlers_AIAssistant.cpp +34 -6
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabDownloads.cpp +766 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabDownloads.h +26 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabHandlers.cpp +159 -55
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabHandlers.h +23 -12
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabLibrary.cpp +306 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabLibrary.h +55 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers.cpp +34 -2
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers.h +9 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_Blockout.cpp +12 -8
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_PerfAudit.cpp +3 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_Refresh.cpp +479 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_ReplaceActors.cpp +2 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_WorldPartition.cpp +824 -12
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Material/MaterialHandlers.cpp +95 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PCG/PCGHandlers.cpp +13 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/MCPPIETestScript.h +8 -3
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEHandlers.cpp +2 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEHandlers_Record.cpp +6 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEHandlers_Replay.cpp +1 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEHandlers_Script.cpp +2 -2
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEInputRecorder.cpp +52 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEInputRecorder.h +16 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEInputReplayer.cpp +65 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEInputReplayer.h +15 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEReplayInputLock.cpp +146 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEReplayInputLock.h +53 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEScriptRunner.cpp +351 -14
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEScriptRunner.h +55 -6
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEScriptValidation.cpp +8 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIESequenceFormat.cpp +59 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIESequenceFormat.h +15 -2
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEUIPointer.cpp +567 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEUIPointer.h +173 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/SMCPPIEStudioPanel.cpp +41 -6
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Widget/WidgetHandlers.cpp +92 -32
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/FabDownloadTests.cpp +140 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/FabEndToEndTests.cpp +365 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/FabLibraryTests.cpp +52 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/PCGGraphAuthoringTests.cpp +5 -2
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/PIEReplayInputLockTests.cpp +77 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/PIEScriptTests.cpp +256 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/PIEScriptValidationTests.cpp +18 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/PIEUIPointerTests.cpp +246 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/UE_MCP_Bridge.cpp +4 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/UE_MCP_Bridge.Build.cs +85 -13
- package/plugin/ue_mcp_bridge/Source/UE_MCP_BridgeRuntime/Private/MCPPIEActionTrigger.cpp +48 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_BridgeRuntime/Private/MCPPIERemoteControl.cpp +93 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_BridgeRuntime/Public/MCPPIEActionTrigger.h +52 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_BridgeRuntime/Public/MCPPIERemoteControl.h +54 -0
- package/plugin/ue_mcp_bridge/UE_MCP_Bridge.uplugin +2 -2
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
#include "Handlers/PIE/PIEStepActions.h"
|
|
10
10
|
#include "Handlers/PIE/PIERemotePlayers.h"
|
|
11
11
|
#include "Handlers/PIE/PIELog.h"
|
|
12
|
+
#include "Handlers/PIE/PIEWorldResolver.h"
|
|
12
13
|
#include "MCPPIERemoteControl.h"
|
|
14
|
+
#include "MCPPIEActionTrigger.h"
|
|
15
|
+
#include "InputAction.h"
|
|
13
16
|
#include "HandlerWorld.h"
|
|
14
17
|
#include "Editor.h"
|
|
15
18
|
#include "HandlerPlaySession.h"
|
|
@@ -35,7 +38,7 @@ namespace MCPPIE
|
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
const TCHAR* ScriptOpNames[] = {
|
|
38
|
-
TEXT("decreasing"), TEXT("increasing"), TEXT("eq"), TEXT("gt"), TEXT("lt"), TEXT("visible"), TEXT("exists")
|
|
41
|
+
TEXT("decreasing"), TEXT("increasing"), TEXT("eq"), TEXT("gt"), TEXT("lt"), TEXT("visible"), TEXT("exists"), TEXT("triggered")
|
|
39
42
|
};
|
|
40
43
|
|
|
41
44
|
const TCHAR* ScriptStatusNames[] = {
|
|
@@ -69,6 +72,33 @@ namespace MCPPIE
|
|
|
69
72
|
return !E.Note.IsEmpty() || E.Captures.Num() > 0;
|
|
70
73
|
}
|
|
71
74
|
|
|
75
|
+
// An Input Action value as its type reads: a boolean, a number, or [x, y] / [x, y, z].
|
|
76
|
+
TSharedRef<FJsonValue> ScriptActionValueToJson(const FVector& V, const FString& Type)
|
|
77
|
+
{
|
|
78
|
+
if (Type == TEXT("bool")) return MakeShared<FJsonValueBoolean>(V.X != 0.0);
|
|
79
|
+
if (Type == TEXT("axis1d")) return MakeShared<FJsonValueNumber>(V.X);
|
|
80
|
+
TArray<TSharedPtr<FJsonValue>> A = { MakeShared<FJsonValueNumber>(V.X), MakeShared<FJsonValueNumber>(V.Y) };
|
|
81
|
+
if (Type != TEXT("axis2d")) A.Add(MakeShared<FJsonValueNumber>(V.Z));
|
|
82
|
+
return MakeShared<FJsonValueArray>(A);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
FVector ScriptActionValueFromJson(const TSharedPtr<FJsonValue>& J)
|
|
86
|
+
{
|
|
87
|
+
if (!J.IsValid()) return FVector::ZeroVector;
|
|
88
|
+
if (J->Type == EJson::Boolean) return FVector(J->AsBool() ? 1.0 : 0.0, 0.0, 0.0);
|
|
89
|
+
if (J->Type == EJson::Number) return FVector(J->AsNumber(), 0.0, 0.0);
|
|
90
|
+
FVector V = FVector::ZeroVector;
|
|
91
|
+
if (J->Type == EJson::Array)
|
|
92
|
+
{
|
|
93
|
+
const TArray<TSharedPtr<FJsonValue>>& A = J->AsArray();
|
|
94
|
+
for (int32 I = 0; I < FMath::Min(3, A.Num()); ++I)
|
|
95
|
+
{
|
|
96
|
+
if (A[I].IsValid() && A[I]->Type == EJson::Number) V[I] = A[I]->AsNumber();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return V;
|
|
100
|
+
}
|
|
101
|
+
|
|
72
102
|
TSharedRef<FJsonObject> ScriptEvidenceToJson(const FScriptEvidence& E)
|
|
73
103
|
{
|
|
74
104
|
TSharedRef<FJsonObject> O = MakeShared<FJsonObject>();
|
|
@@ -82,6 +112,12 @@ namespace MCPPIE
|
|
|
82
112
|
if (E.VerdictFrame >= 0) O->SetNumberField(TEXT("verdict_frame"), static_cast<double>(E.VerdictFrame));
|
|
83
113
|
if (E.VerdictAtMs >= 0.0) O->SetNumberField(TEXT("verdict_at_ms"), E.VerdictAtMs);
|
|
84
114
|
if (!E.Reason.IsEmpty()) O->SetStringField(TEXT("reason"), E.Reason);
|
|
115
|
+
if (E.bTriggered)
|
|
116
|
+
{
|
|
117
|
+
O->SetNumberField(TEXT("triggered_at_ms"), E.TriggeredAtMs);
|
|
118
|
+
O->SetField(TEXT("action_value"), ScriptActionValueToJson(E.TriggerValue, E.TriggerValueType));
|
|
119
|
+
if (!E.TriggerValueType.IsEmpty()) O->SetStringField(TEXT("value_type"), E.TriggerValueType);
|
|
120
|
+
}
|
|
85
121
|
ScriptVerdictEvidenceToJson(E, O);
|
|
86
122
|
return O;
|
|
87
123
|
}
|
|
@@ -98,6 +134,12 @@ namespace MCPPIE
|
|
|
98
134
|
if (O->TryGetNumberField(TEXT("verdict_frame"), Frame)) E.VerdictFrame = static_cast<int64>(Frame);
|
|
99
135
|
O->TryGetNumberField(TEXT("verdict_at_ms"), E.VerdictAtMs);
|
|
100
136
|
O->TryGetStringField(TEXT("reason"), E.Reason);
|
|
137
|
+
E.bTriggered = O->TryGetNumberField(TEXT("triggered_at_ms"), E.TriggeredAtMs);
|
|
138
|
+
if (E.bTriggered)
|
|
139
|
+
{
|
|
140
|
+
O->TryGetStringField(TEXT("value_type"), E.TriggerValueType);
|
|
141
|
+
E.TriggerValue = ScriptActionValueFromJson(O->TryGetField(TEXT("action_value")));
|
|
142
|
+
}
|
|
101
143
|
O->TryGetStringField(TEXT("note"), E.Note);
|
|
102
144
|
const TArray<TSharedPtr<FJsonValue>>* Captures = nullptr;
|
|
103
145
|
if (O->TryGetArrayField(TEXT("captures"), Captures) && Captures)
|
|
@@ -112,6 +154,8 @@ namespace MCPPIE
|
|
|
112
154
|
|
|
113
155
|
int32 ScriptEffectiveWithinMs(const FScriptStepDef& Def, int32 DefaultWithinMs)
|
|
114
156
|
{
|
|
157
|
+
// A person may take as long as they like: triggered without within_ms waits with no timeout (0).
|
|
158
|
+
if (Def.bHasExpect && IsScriptTriggerOp(Def.Expect.Op)) return FMath::Max(0, Def.Expect.WithinMs);
|
|
115
159
|
if (Def.bHasExpect && Def.Expect.WithinMs > 0) return Def.Expect.WithinMs;
|
|
116
160
|
return DefaultWithinMs > 0 ? DefaultWithinMs : 5000;
|
|
117
161
|
}
|
|
@@ -183,7 +227,7 @@ namespace MCPPIE
|
|
|
183
227
|
if (St.WindowStartMs >= 0.0)
|
|
184
228
|
{
|
|
185
229
|
D->SetNumberField(TEXT("window_start_ms"), St.WindowStartMs);
|
|
186
|
-
D->SetNumberField(TEXT("window_end_ms"), St.WindowEndMs);
|
|
230
|
+
if (St.WindowEndMs >= 0.0) D->SetNumberField(TEXT("window_end_ms"), St.WindowEndMs);
|
|
187
231
|
}
|
|
188
232
|
AddScriptEvent(Run, TEXT("step_started"), Index, D);
|
|
189
233
|
|
|
@@ -286,10 +330,60 @@ namespace MCPPIE
|
|
|
286
330
|
return Out.Num() > 0;
|
|
287
331
|
}
|
|
288
332
|
|
|
289
|
-
|
|
333
|
+
// A triggered step: passes on the first fresh trigger inside its window, fails once within_ms runs out
|
|
334
|
+
// (never, with within_ms 0). Triggers before the window opened, at the end of act, do not count.
|
|
335
|
+
void ScriptEvaluateTriggeredStep(FScriptRun& Run, int32 Index, IScriptTriggerSource* Triggers)
|
|
336
|
+
{
|
|
337
|
+
FScriptStepRun& St = Run.Steps[Index];
|
|
338
|
+
const FScriptExpect& E = St.Def.Expect;
|
|
339
|
+
const double FromMs = St.ExpectFromMs();
|
|
340
|
+
FScriptTrigger Trigger;
|
|
341
|
+
FString Why;
|
|
342
|
+
const EScriptTriggerRead Read = Triggers
|
|
343
|
+
? Triggers->ReadTrigger(Index, E, FromMs, Trigger, Why)
|
|
344
|
+
: EScriptTriggerRead::Unwatched;
|
|
345
|
+
if (!Triggers) Why = TEXT("nothing watches input in this run");
|
|
346
|
+
if (Read != EScriptTriggerRead::Unwatched)
|
|
347
|
+
{
|
|
348
|
+
St.Evidence.Samples++;
|
|
349
|
+
St.Evidence.bObserved = true;
|
|
350
|
+
}
|
|
351
|
+
else if (!Why.IsEmpty())
|
|
352
|
+
{
|
|
353
|
+
St.Evidence.Reason = Why;
|
|
354
|
+
}
|
|
355
|
+
const bool bInWindow = Read == EScriptTriggerRead::Triggered && Trigger.AtMs >= FromMs
|
|
356
|
+
&& (St.WithinMs <= 0 || Trigger.AtMs - FromMs <= St.WithinMs);
|
|
357
|
+
if (bInWindow)
|
|
358
|
+
{
|
|
359
|
+
St.Evidence.bTriggered = true;
|
|
360
|
+
St.Evidence.TriggeredAtMs = Trigger.AtMs;
|
|
361
|
+
St.Evidence.TriggerValue = Trigger.Value;
|
|
362
|
+
St.Evidence.TriggerValueType = Trigger.ValueType;
|
|
363
|
+
ScriptSettleStep(Run, Index, EScriptStepStatus::Passed, FString());
|
|
364
|
+
if (Triggers) Triggers->EndWatch(Index);
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
if (St.WithinMs > 0 && Run.NowMs - FromMs >= St.WithinMs)
|
|
368
|
+
{
|
|
369
|
+
const FString Reason = St.Evidence.bObserved
|
|
370
|
+
? FString::Printf(TEXT("%s was not triggered by client %d within %d ms"), *E.Value, E.Client, St.WithinMs)
|
|
371
|
+
: FString::Printf(TEXT("%s on client %d could not be watched within %d ms: %s"), *E.Value, E.Client, St.WithinMs,
|
|
372
|
+
Why.IsEmpty() ? TEXT("no player to watch") : *Why);
|
|
373
|
+
ScriptSettleStep(Run, Index, EScriptStepStatus::Failed, Reason);
|
|
374
|
+
if (Triggers) Triggers->EndWatch(Index);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
void ScriptEvaluateRunningStep(FScriptRun& Run, int32 Index, FScriptValueReader Reader, IScriptTriggerSource* Triggers)
|
|
290
379
|
{
|
|
291
380
|
FScriptStepRun& St = Run.Steps[Index];
|
|
292
381
|
const FScriptExpect& E = St.Def.Expect;
|
|
382
|
+
if (IsScriptTriggerOp(E.Op))
|
|
383
|
+
{
|
|
384
|
+
ScriptEvaluateTriggeredStep(Run, Index, Triggers);
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
293
387
|
double Current = 0.0;
|
|
294
388
|
const bool bObserved = Reader(E, Current);
|
|
295
389
|
if (bObserved)
|
|
@@ -457,6 +551,22 @@ namespace MCPPIE
|
|
|
457
551
|
return Op == EScriptExpectOp::Eq || Op == EScriptExpectOp::Gt || Op == EScriptExpectOp::Lt;
|
|
458
552
|
}
|
|
459
553
|
|
|
554
|
+
bool IsScriptTriggerOp(EScriptExpectOp Op)
|
|
555
|
+
{
|
|
556
|
+
return Op == EScriptExpectOp::Triggered;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
FString NormalizeScriptInputActionPath(const FString& Path)
|
|
560
|
+
{
|
|
561
|
+
const FString Trimmed = Path.TrimStartAndEnd();
|
|
562
|
+
if (!Trimmed.StartsWith(TEXT("/"))) return Trimmed;
|
|
563
|
+
int32 LastSlash = INDEX_NONE;
|
|
564
|
+
Trimmed.FindLastChar(TEXT('/'), LastSlash);
|
|
565
|
+
const FString Leaf = Trimmed.Mid(LastSlash + 1);
|
|
566
|
+
if (Leaf.IsEmpty() || Leaf.Contains(TEXT("."))) return Trimmed;
|
|
567
|
+
return Trimmed + TEXT(".") + Leaf;
|
|
568
|
+
}
|
|
569
|
+
|
|
460
570
|
bool IsScriptStepSettled(EScriptStepStatus Status)
|
|
461
571
|
{
|
|
462
572
|
return Status == EScriptStepStatus::Passed
|
|
@@ -605,27 +715,55 @@ namespace MCPPIE
|
|
|
605
715
|
if (!Exp->TryGetStringField(TEXT("op"), Op) || Op.IsEmpty())
|
|
606
716
|
{
|
|
607
717
|
Field = TEXT("expect.op");
|
|
608
|
-
OutError = FString::Printf(TEXT("%s.expect.op is required (decreasing, increasing, eq, gt, lt, visible, exists)"), *Where);
|
|
718
|
+
OutError = FString::Printf(TEXT("%s.expect.op is required (decreasing, increasing, eq, gt, lt, visible, exists, triggered)"), *Where);
|
|
609
719
|
return false;
|
|
610
720
|
}
|
|
611
721
|
if (!ParseScriptExpectOp(Op, Out.Expect.Op))
|
|
612
722
|
{
|
|
613
723
|
Field = TEXT("expect.op");
|
|
614
|
-
OutError = FString::Printf(TEXT("%s.expect.op '%s' is unknown (decreasing, increasing, eq, gt, lt, visible, exists)"), *Where, *Op);
|
|
724
|
+
OutError = FString::Printf(TEXT("%s.expect.op '%s' is unknown (decreasing, increasing, eq, gt, lt, visible, exists, triggered)"), *Where, *Op);
|
|
615
725
|
return false;
|
|
616
726
|
}
|
|
727
|
+
const bool bTriggerOp = IsScriptTriggerOp(Out.Expect.Op);
|
|
617
728
|
if (!Exp->TryGetStringField(TEXT("value"), Out.Expect.Value) || Out.Expect.Value.TrimStartAndEnd().IsEmpty())
|
|
618
729
|
{
|
|
619
730
|
Field = TEXT("expect.value");
|
|
620
731
|
OutError = FString::Printf(TEXT("%s.expect.value is required for op '%s' (%s)"), *Where, *Op,
|
|
621
732
|
Out.Expect.Op == EScriptExpectOp::Visible ? TEXT("a widget class or name")
|
|
622
733
|
: Out.Expect.Op == EScriptExpectOp::Exists ? TEXT("an actor id")
|
|
734
|
+
: bTriggerOp ? TEXT("an Input Action asset path, such as /Game/Input/IA_Interact")
|
|
623
735
|
: TEXT("a tracked value path"));
|
|
624
736
|
return false;
|
|
625
737
|
}
|
|
626
738
|
Out.Expect.Value.TrimStartAndEndInline();
|
|
739
|
+
if (bTriggerOp) Out.Expect.Value = NormalizeScriptInputActionPath(Out.Expect.Value);
|
|
740
|
+
|
|
741
|
+
const TSharedPtr<FJsonValue> ClientValue = Exp->TryGetField(TEXT("client"));
|
|
742
|
+
if (ClientValue.IsValid() && !ClientValue->IsNull())
|
|
743
|
+
{
|
|
744
|
+
if (!bTriggerOp)
|
|
745
|
+
{
|
|
746
|
+
Field = TEXT("expect.client");
|
|
747
|
+
OutError = FString::Printf(TEXT("%s.expect.client applies to op 'triggered', the player whose input is watched"), *Where);
|
|
748
|
+
return false;
|
|
749
|
+
}
|
|
750
|
+
if (ClientValue->Type != EJson::Number || ClientValue->AsNumber() < 0.0
|
|
751
|
+
|| ClientValue->AsNumber() != FMath::RoundToDouble(ClientValue->AsNumber()))
|
|
752
|
+
{
|
|
753
|
+
Field = TEXT("expect.client");
|
|
754
|
+
OutError = FString::Printf(TEXT("%s.expect.client must be a non-negative integer (0 the editor's own player, 1..N a remote player)"), *Where);
|
|
755
|
+
return false;
|
|
756
|
+
}
|
|
757
|
+
Out.Expect.Client = static_cast<int32>(FMath::Min(ClientValue->AsNumber(), 1024.0));
|
|
758
|
+
}
|
|
627
759
|
|
|
628
760
|
const TSharedPtr<FJsonValue> TargetValue = Exp->TryGetField(TEXT("target"));
|
|
761
|
+
if (TargetValue.IsValid() && !TargetValue->IsNull() && bTriggerOp)
|
|
762
|
+
{
|
|
763
|
+
Field = TEXT("expect.target");
|
|
764
|
+
OutError = FString::Printf(TEXT("%s.expect.target does not apply to op 'triggered'; the step passes when the action fires"), *Where);
|
|
765
|
+
return false;
|
|
766
|
+
}
|
|
629
767
|
if (TargetValue.IsValid() && !TargetValue->IsNull())
|
|
630
768
|
{
|
|
631
769
|
// On decreasing and increasing, target is the least change from
|
|
@@ -704,6 +842,7 @@ namespace MCPPIE
|
|
|
704
842
|
else E->SetNumberField(TEXT("target"), Expect.Target);
|
|
705
843
|
}
|
|
706
844
|
if (Expect.WithinMs > 0) E->SetNumberField(TEXT("within_ms"), Expect.WithinMs);
|
|
845
|
+
if (IsScriptTriggerOp(Expect.Op) && Expect.Client > 0) E->SetNumberField(TEXT("client"), Expect.Client);
|
|
707
846
|
return E;
|
|
708
847
|
}
|
|
709
848
|
|
|
@@ -742,6 +881,7 @@ namespace MCPPIE
|
|
|
742
881
|
D.Expect.bHasTarget = S.Expect.bHasTarget;
|
|
743
882
|
D.Expect.Target = S.Expect.Target;
|
|
744
883
|
D.Expect.WithinMs = FMath::Max(0, S.Expect.WithinMs);
|
|
884
|
+
D.Expect.Client = IsScriptTriggerOp(D.Expect.Op) ? FMath::Max(0, S.Expect.Client) : 0;
|
|
745
885
|
D.bAgentJudgeable = D.Judge != EScriptJudge::Manual || S.bAgentJudgeable;
|
|
746
886
|
D.Arrange = ScriptJsonArrayFromString(S.ArrangeJson);
|
|
747
887
|
D.Act = ScriptJsonArrayFromString(S.ActJson);
|
|
@@ -765,6 +905,7 @@ namespace MCPPIE
|
|
|
765
905
|
S.Expect.bHasTarget = D.Expect.bHasTarget;
|
|
766
906
|
S.Expect.Target = D.Expect.Target;
|
|
767
907
|
S.Expect.WithinMs = D.Expect.WithinMs;
|
|
908
|
+
S.Expect.Client = D.Expect.Client;
|
|
768
909
|
S.bAgentJudgeable = D.bAgentJudgeable;
|
|
769
910
|
S.bResolveInPIE = D.bResolveInPIE;
|
|
770
911
|
S.ArrangeJson = ScriptJsonArrayToString(D.Arrange);
|
|
@@ -802,6 +943,9 @@ namespace MCPPIE
|
|
|
802
943
|
case EScriptExpectOp::Exists:
|
|
803
944
|
OutActors.AddUnique(S.Expect.Value);
|
|
804
945
|
break;
|
|
946
|
+
case EScriptExpectOp::Triggered:
|
|
947
|
+
// The trigger source watches the player's input; the observer reads nothing for it.
|
|
948
|
+
break;
|
|
805
949
|
default:
|
|
806
950
|
{
|
|
807
951
|
// A pawn channel is read off the sampled pawn state, not tracked.
|
|
@@ -840,6 +984,9 @@ namespace MCPPIE
|
|
|
840
984
|
case EScriptExpectOp::Visible:
|
|
841
985
|
case EScriptExpectOp::Exists:
|
|
842
986
|
return (Current != 0.0) == ScriptExpectTargetBool(Expect);
|
|
987
|
+
case EScriptExpectOp::Triggered:
|
|
988
|
+
// Judged from the trigger source, not a value.
|
|
989
|
+
return false;
|
|
843
990
|
}
|
|
844
991
|
return false;
|
|
845
992
|
}
|
|
@@ -927,7 +1074,8 @@ namespace MCPPIE
|
|
|
927
1074
|
return true;
|
|
928
1075
|
}
|
|
929
1076
|
|
|
930
|
-
void AdvanceScriptRun(FScriptRun& Run, double NowMs, int64 Frame, FScriptValueReader Reader, IScriptStepDriver* Driver
|
|
1077
|
+
void AdvanceScriptRun(FScriptRun& Run, double NowMs, int64 Frame, FScriptValueReader Reader, IScriptStepDriver* Driver,
|
|
1078
|
+
IScriptTriggerSource* Triggers)
|
|
931
1079
|
{
|
|
932
1080
|
if (Run.State != EScriptRunState::Running && Run.State != EScriptRunState::AwaitingVerdict) return;
|
|
933
1081
|
Run.NowMs = NowMs;
|
|
@@ -992,7 +1140,7 @@ namespace MCPPIE
|
|
|
992
1140
|
Run.State = EScriptRunState::Running;
|
|
993
1141
|
return;
|
|
994
1142
|
}
|
|
995
|
-
if (Run.Steps[I].Status == EScriptStepStatus::Running) ScriptEvaluateRunningStep(Run, I, Reader);
|
|
1143
|
+
if (Run.Steps[I].Status == EScriptStepStatus::Running) ScriptEvaluateRunningStep(Run, I, Reader, Triggers);
|
|
996
1144
|
if (Run.Steps[I].Status == EScriptStepStatus::Running)
|
|
997
1145
|
{
|
|
998
1146
|
Run.State = EScriptRunState::Running;
|
|
@@ -1003,7 +1151,7 @@ namespace MCPPIE
|
|
|
1003
1151
|
Run.State = ScriptAwaitingSteps(Run).Num() > 0 ? EScriptRunState::AwaitingVerdict : EScriptRunState::Running;
|
|
1004
1152
|
}
|
|
1005
1153
|
|
|
1006
|
-
void AdvanceScriptReplay(FScriptRun& Run, double NowMs, int64 Frame, FScriptValueReader Reader)
|
|
1154
|
+
void AdvanceScriptReplay(FScriptRun& Run, double NowMs, int64 Frame, FScriptValueReader Reader, IScriptTriggerSource* Triggers)
|
|
1007
1155
|
{
|
|
1008
1156
|
if (Run.State != EScriptRunState::Running) return;
|
|
1009
1157
|
Run.NowMs = NowMs;
|
|
@@ -1024,7 +1172,7 @@ namespace MCPPIE
|
|
|
1024
1172
|
}
|
|
1025
1173
|
if (Run.Steps[I].Status == EScriptStepStatus::Running)
|
|
1026
1174
|
{
|
|
1027
|
-
ScriptEvaluateRunningStep(Run, I, Reader);
|
|
1175
|
+
ScriptEvaluateRunningStep(Run, I, Reader, Triggers);
|
|
1028
1176
|
}
|
|
1029
1177
|
if (!IsScriptStepSettled(Run.Steps[I].Status)) FirstUnsettled = FMath::Min(FirstUnsettled, I);
|
|
1030
1178
|
}
|
|
@@ -1140,7 +1288,14 @@ namespace MCPPIE
|
|
|
1140
1288
|
St.Act.EndedAtMs = Run.NowMs;
|
|
1141
1289
|
St.Act.Reason = Reason;
|
|
1142
1290
|
}
|
|
1143
|
-
if (St.Status == EScriptStepStatus::Running)
|
|
1291
|
+
if (St.Status == EScriptStepStatus::Running && St.Def.bHasExpect && IsScriptTriggerOp(St.Def.Expect.Op))
|
|
1292
|
+
{
|
|
1293
|
+
ScriptSettleStep(Run, I, EScriptStepStatus::Failed, St.Evidence.bObserved
|
|
1294
|
+
? FString::Printf(TEXT("%s; %s was not triggered"), *Reason, *St.Def.Expect.Value)
|
|
1295
|
+
: FString::Printf(TEXT("%s; %s was never watched%s%s"), *Reason, *St.Def.Expect.Value,
|
|
1296
|
+
St.Evidence.Reason.IsEmpty() ? TEXT("") : TEXT(": "), *St.Evidence.Reason));
|
|
1297
|
+
}
|
|
1298
|
+
else if (St.Status == EScriptStepStatus::Running)
|
|
1144
1299
|
{
|
|
1145
1300
|
ScriptSettleStep(Run, I, EScriptStepStatus::Failed, St.Evidence.bObserved || !St.Def.bHasExpect
|
|
1146
1301
|
? Reason
|
|
@@ -1240,7 +1395,7 @@ namespace MCPPIE
|
|
|
1240
1395
|
if (St.WindowStartMs >= 0.0)
|
|
1241
1396
|
{
|
|
1242
1397
|
O->SetNumberField(TEXT("window_start_ms"), St.WindowStartMs);
|
|
1243
|
-
O->SetNumberField(TEXT("window_end_ms"), St.WindowEndMs);
|
|
1398
|
+
if (St.WindowEndMs >= 0.0) O->SetNumberField(TEXT("window_end_ms"), St.WindowEndMs);
|
|
1244
1399
|
}
|
|
1245
1400
|
if (St.Act.State != EScriptActState::None) O->SetObjectField(TEXT("act_result"), ScriptActReportToJson(St.Act));
|
|
1246
1401
|
return O;
|
|
@@ -1466,7 +1621,8 @@ namespace MCPPIE
|
|
|
1466
1621
|
}
|
|
1467
1622
|
// The window opened when the source step's act ended.
|
|
1468
1623
|
St.WindowStartMs = Src.ExpectFromMs() + OffsetMs;
|
|
1469
|
-
|
|
1624
|
+
// A triggered step with no timeout has an open window.
|
|
1625
|
+
St.WindowEndMs = St.WithinMs > 0 ? St.WindowStartMs + St.WithinMs : -1.0;
|
|
1470
1626
|
}
|
|
1471
1627
|
}
|
|
1472
1628
|
|
|
@@ -1630,6 +1786,177 @@ namespace MCPPIE
|
|
|
1630
1786
|
};
|
|
1631
1787
|
}
|
|
1632
1788
|
|
|
1789
|
+
// ── Input Action triggers in the editor ─────────────────────────────
|
|
1790
|
+
|
|
1791
|
+
/**
|
|
1792
|
+
* Watches the Input Actions triggered steps name. Client 0, the editor's own player, is read here once per
|
|
1793
|
+
* frame; a remote player (client 1..N) reads its own player through its UMCPPIERemoteControl and reports the
|
|
1794
|
+
* trigger, which is timed when the editor hears of it. Either way a trigger counts only after a frame without
|
|
1795
|
+
* one (FActionTriggerGate), so input still down when the window opens does not pass the step.
|
|
1796
|
+
*/
|
|
1797
|
+
class FEditorScriptTriggerSource : public IScriptTriggerSource
|
|
1798
|
+
{
|
|
1799
|
+
public:
|
|
1800
|
+
virtual EScriptTriggerRead ReadTrigger(int32 Index, const FScriptExpect& Expect, double FromMs,
|
|
1801
|
+
FScriptTrigger& OutTrigger, FString& OutWhy) override
|
|
1802
|
+
{
|
|
1803
|
+
FWatch* W = Watches.Find(Index);
|
|
1804
|
+
if (!W)
|
|
1805
|
+
{
|
|
1806
|
+
W = &Watches.Add(Index);
|
|
1807
|
+
W->Expect = Expect;
|
|
1808
|
+
W->Path = FSoftObjectPath(Expect.Value);
|
|
1809
|
+
W->FromMs = FromMs;
|
|
1810
|
+
}
|
|
1811
|
+
if (W->bTriggered)
|
|
1812
|
+
{
|
|
1813
|
+
OutTrigger = W->Trigger;
|
|
1814
|
+
return EScriptTriggerRead::Triggered;
|
|
1815
|
+
}
|
|
1816
|
+
OutWhy = W->Why;
|
|
1817
|
+
return W->bWatching ? EScriptTriggerRead::Watching : EScriptTriggerRead::Unwatched;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
virtual void EndWatch(int32 Index) override
|
|
1821
|
+
{
|
|
1822
|
+
if (FWatch* W = Watches.Find(Index))
|
|
1823
|
+
{
|
|
1824
|
+
StopRemote(*W);
|
|
1825
|
+
Watches.Remove(Index);
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
virtual void Cancel() override
|
|
1830
|
+
{
|
|
1831
|
+
for (TPair<int32, FWatch>& P : Watches) StopRemote(P.Value);
|
|
1832
|
+
Watches.Reset();
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
// Once per engine frame while the run observes. NowMs is the run clock on this frame.
|
|
1836
|
+
void Poll(double NowMs)
|
|
1837
|
+
{
|
|
1838
|
+
for (TPair<int32, FWatch>& P : Watches)
|
|
1839
|
+
{
|
|
1840
|
+
FWatch& W = P.Value;
|
|
1841
|
+
if (W.bTriggered) continue;
|
|
1842
|
+
if (W.Expect.Client > 0) PollRemote(W, NowMs);
|
|
1843
|
+
else PollLocal(W, NowMs);
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
private:
|
|
1848
|
+
struct FWatch
|
|
1849
|
+
{
|
|
1850
|
+
FScriptExpect Expect;
|
|
1851
|
+
FSoftObjectPath Path;
|
|
1852
|
+
double FromMs = 0.0;
|
|
1853
|
+
TWeakObjectPtr<const UInputAction> Action;
|
|
1854
|
+
FActionTriggerGate Gate;
|
|
1855
|
+
bool bWatching = false;
|
|
1856
|
+
bool bTriggered = false;
|
|
1857
|
+
FScriptTrigger Trigger;
|
|
1858
|
+
FString Why;
|
|
1859
|
+
FString RemoteId;
|
|
1860
|
+
TWeakObjectPtr<UMCPPIERemoteControl> Remote;
|
|
1861
|
+
};
|
|
1862
|
+
|
|
1863
|
+
static const UInputAction* LoadWatchedAction(FWatch& W)
|
|
1864
|
+
{
|
|
1865
|
+
const UInputAction* Action = W.Action.Get();
|
|
1866
|
+
if (!Action)
|
|
1867
|
+
{
|
|
1868
|
+
Action = Cast<UInputAction>(W.Path.TryLoad());
|
|
1869
|
+
W.Action = Action;
|
|
1870
|
+
}
|
|
1871
|
+
if (!Action) W.Why = FString::Printf(TEXT("no Input Action loads from %s"), *W.Path.ToString());
|
|
1872
|
+
return Action;
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
// The editor's own player: the first local player of the server world (a listen server's host), else of the play world.
|
|
1876
|
+
static ULocalPlayer* ResolveOwnPlayer(FString& OutError)
|
|
1877
|
+
{
|
|
1878
|
+
PIEWorldResolver::FPlayerTarget Target;
|
|
1879
|
+
if (UWorld* World = PIERemotePlayers::FindLocalPlayerWorld())
|
|
1880
|
+
{
|
|
1881
|
+
if (PIEWorldResolver::ResolvePlayerInWorld(World, 0, Target, OutError) && Target.LocalPlayer) return Target.LocalPlayer;
|
|
1882
|
+
}
|
|
1883
|
+
return PIEWorldResolver::ResolvePlayer(INDEX_NONE, 0, Target, OutError) ? Target.LocalPlayer : nullptr;
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
void PollLocal(FWatch& W, double NowMs)
|
|
1887
|
+
{
|
|
1888
|
+
const UInputAction* Action = LoadWatchedAction(W);
|
|
1889
|
+
FString Err;
|
|
1890
|
+
ULocalPlayer* LocalPlayer = Action ? ResolveOwnPlayer(Err) : nullptr;
|
|
1891
|
+
bool bTriggered = false;
|
|
1892
|
+
FVector Value = FVector::ZeroVector;
|
|
1893
|
+
if (!Action) { W.bWatching = false; return; }
|
|
1894
|
+
if (!LocalPlayer || !ReadActionTriggerState(LocalPlayer, Action, bTriggered, Value, Err))
|
|
1895
|
+
{
|
|
1896
|
+
W.bWatching = false;
|
|
1897
|
+
W.Why = Err.IsEmpty() ? FString(TEXT("the editor's own player is not in PIE")) : Err;
|
|
1898
|
+
return;
|
|
1899
|
+
}
|
|
1900
|
+
W.bWatching = true;
|
|
1901
|
+
W.Why.Reset();
|
|
1902
|
+
if (W.Gate.Feed(bTriggered)) Fire(W, NowMs, Value, Action);
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
void PollRemote(FWatch& W, double NowMs)
|
|
1906
|
+
{
|
|
1907
|
+
const UInputAction* Action = LoadWatchedAction(W);
|
|
1908
|
+
if (!Action) { W.bWatching = false; return; }
|
|
1909
|
+
UMCPPIERemoteControl* Remote = W.Remote.Get();
|
|
1910
|
+
if (!Remote || W.RemoteId.IsEmpty())
|
|
1911
|
+
{
|
|
1912
|
+
// Not sent yet, or the player left: (re)send once the remote player is ready.
|
|
1913
|
+
FString Err;
|
|
1914
|
+
Remote = PIERemotePlayers::Find(W.Expect.Client, Err);
|
|
1915
|
+
if (!Remote)
|
|
1916
|
+
{
|
|
1917
|
+
W.bWatching = false;
|
|
1918
|
+
W.Why = Err;
|
|
1919
|
+
return;
|
|
1920
|
+
}
|
|
1921
|
+
W.Remote = Remote;
|
|
1922
|
+
W.RemoteId = PIERemotePlayers::NewId(TEXT("watch"));
|
|
1923
|
+
Remote->SendWatchTrigger(W.RemoteId, FSoftObjectPath(Action));
|
|
1924
|
+
W.Why = FString::Printf(TEXT("waiting for client %d to start watching"), W.Expect.Client);
|
|
1925
|
+
return;
|
|
1926
|
+
}
|
|
1927
|
+
if (const FMCPPIERemoteTrigger* T = Remote->FindTrigger(W.RemoteId))
|
|
1928
|
+
{
|
|
1929
|
+
W.bWatching = true;
|
|
1930
|
+
Fire(W, NowMs, T->Value, Action);
|
|
1931
|
+
return;
|
|
1932
|
+
}
|
|
1933
|
+
if (const FMCPPIERemoteResult* R = Remote->FindResult(W.RemoteId))
|
|
1934
|
+
{
|
|
1935
|
+
W.bWatching = R->bOk;
|
|
1936
|
+
W.Why = R->bOk ? FString() : FString::Printf(TEXT("client %d could not watch it: %s"), W.Expect.Client, *R->Error);
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
static void Fire(FWatch& W, double NowMs, const FVector& Value, const UInputAction* Action)
|
|
1941
|
+
{
|
|
1942
|
+
W.bTriggered = true;
|
|
1943
|
+
W.Trigger.AtMs = FMath::Max(NowMs, W.FromMs);
|
|
1944
|
+
W.Trigger.Value = Value;
|
|
1945
|
+
W.Trigger.ValueType = ActionValueTypeName(Action);
|
|
1946
|
+
UE_LOG(LogMCPPIE, Log, TEXT("[PIE-SCRIPT] %s triggered on client %d at %.0f ms"), *W.Path.ToString(), W.Expect.Client, W.Trigger.AtMs);
|
|
1947
|
+
}
|
|
1948
|
+
|
|
1949
|
+
static void StopRemote(FWatch& W)
|
|
1950
|
+
{
|
|
1951
|
+
if (UMCPPIERemoteControl* Remote = W.Remote.Get())
|
|
1952
|
+
{
|
|
1953
|
+
if (!W.RemoteId.IsEmpty() && !W.bTriggered) Remote->SendStopWatch(W.RemoteId);
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
TMap<int32, FWatch> Watches;
|
|
1958
|
+
};
|
|
1959
|
+
|
|
1633
1960
|
// ── Runner ──────────────────────────────────────────────────────────
|
|
1634
1961
|
|
|
1635
1962
|
FPIEScriptRunner& FPIEScriptRunner::Get()
|
|
@@ -1704,8 +2031,8 @@ namespace MCPPIE
|
|
|
1704
2031
|
void FPIEScriptRunner::AdvanceNow()
|
|
1705
2032
|
{
|
|
1706
2033
|
auto Reader = [this](const FScriptExpect& E, double& V) { return ReadLive(E, V); };
|
|
1707
|
-
if (Run.bReplay) AdvanceScriptReplay(Run, Run.NowMs, Run.Frame, Reader);
|
|
1708
|
-
else AdvanceScriptRun(Run, Run.NowMs, Run.Frame, Reader, StepDriver.Get());
|
|
2034
|
+
if (Run.bReplay) AdvanceScriptReplay(Run, Run.NowMs, Run.Frame, Reader, TriggerSource.Get());
|
|
2035
|
+
else AdvanceScriptRun(Run, Run.NowMs, Run.Frame, Reader, StepDriver.Get(), TriggerSource.Get());
|
|
1709
2036
|
if (IsScriptRunSettled(Run))
|
|
1710
2037
|
{
|
|
1711
2038
|
Finish(EScriptRunState::Finished, TEXT("all steps settled"));
|
|
@@ -1824,6 +2151,7 @@ namespace MCPPIE
|
|
|
1824
2151
|
|
|
1825
2152
|
NewRun.State = EScriptRunState::Armed;
|
|
1826
2153
|
StepDriver = MakeShared<FEditorScriptStepDriver>(NewRun.OutputDir);
|
|
2154
|
+
TriggerSource = MakeShared<FEditorScriptTriggerSource>();
|
|
1827
2155
|
Run = MoveTemp(NewRun);
|
|
1828
2156
|
bHasRun = true;
|
|
1829
2157
|
|
|
@@ -1960,6 +2288,7 @@ namespace MCPPIE
|
|
|
1960
2288
|
NewRun.bOwnsReplayer = true;
|
|
1961
2289
|
NewRun.bEndPIEWhenSettled = Cfg.bAutoStopPIE;
|
|
1962
2290
|
NewRun.State = EScriptRunState::Armed;
|
|
2291
|
+
TriggerSource = MakeShared<FEditorScriptTriggerSource>();
|
|
1963
2292
|
Run = MoveTemp(NewRun);
|
|
1964
2293
|
bHasRun = true;
|
|
1965
2294
|
|
|
@@ -2048,6 +2377,9 @@ namespace MCPPIE
|
|
|
2048
2377
|
Run.WaitingFor = Clock.WaitingFor;
|
|
2049
2378
|
if (Clock.State != EObserverState::Observing || Clock.FramesSampled == 0) return;
|
|
2050
2379
|
|
|
2380
|
+
// Every frame, sampled or not, so a trigger that lasts one frame is not missed.
|
|
2381
|
+
if (TriggerSource.IsValid()) TriggerSource->Poll(Clock.ElapsedSeconds * 1000.0);
|
|
2382
|
+
|
|
2051
2383
|
const int64 Frame = static_cast<int64>(Clock.LastFrame);
|
|
2052
2384
|
if (Run.bClockStarted && Frame == Run.Frame) return;
|
|
2053
2385
|
Run.NowMs = Clock.ElapsedSeconds * 1000.0;
|
|
@@ -2078,6 +2410,11 @@ namespace MCPPIE
|
|
|
2078
2410
|
StepDriver->Cancel();
|
|
2079
2411
|
StepDriver.Reset();
|
|
2080
2412
|
}
|
|
2413
|
+
if (TriggerSource.IsValid())
|
|
2414
|
+
{
|
|
2415
|
+
TriggerSource->Cancel();
|
|
2416
|
+
TriggerSource.Reset();
|
|
2417
|
+
}
|
|
2081
2418
|
SettleUnfinishedScriptSteps(Run, FString::Printf(TEXT("run ended before the step settled (%s)"), *Reason));
|
|
2082
2419
|
|
|
2083
2420
|
if (Run.bManualMode)
|
|
@@ -23,7 +23,8 @@ class UMCPPIETestScript;
|
|
|
23
23
|
namespace MCPPIE
|
|
24
24
|
{
|
|
25
25
|
enum class EScriptJudge : uint8 { Auto, Manual };
|
|
26
|
-
|
|
26
|
+
// Triggered waits for a person to fire an Input Action; the others read an observed value.
|
|
27
|
+
enum class EScriptExpectOp : uint8 { Decreasing, Increasing, Eq, Gt, Lt, Visible, Exists, Triggered };
|
|
27
28
|
enum class EScriptStepStatus : uint8 { Pending, Running, Passed, Failed, AwaitingVerdict, Skipped };
|
|
28
29
|
enum class EScriptRunState : uint8 { Idle, Armed, Running, AwaitingVerdict, Finished, Stopped };
|
|
29
30
|
enum class EScriptExpectOutcome : uint8 { Pending, Passed, Failed };
|
|
@@ -48,6 +49,10 @@ namespace MCPPIE
|
|
|
48
49
|
bool IsScriptRelativeOp(EScriptExpectOp Op);
|
|
49
50
|
// eq / gt / lt need a target.
|
|
50
51
|
bool ScriptOpNeedsTarget(EScriptExpectOp Op);
|
|
52
|
+
// triggered watches an Input Action on a player rather than reading a value.
|
|
53
|
+
bool IsScriptTriggerOp(EScriptExpectOp Op);
|
|
54
|
+
// An Input Action given as a package path (/Game/Input/IA_Jump) as its object path (/Game/Input/IA_Jump.IA_Jump).
|
|
55
|
+
FString NormalizeScriptInputActionPath(const FString& Path);
|
|
51
56
|
// passed, failed, skipped.
|
|
52
57
|
bool IsScriptStepSettled(EScriptStepStatus Status);
|
|
53
58
|
|
|
@@ -59,8 +64,10 @@ namespace MCPPIE
|
|
|
59
64
|
double Target = 0.0;
|
|
60
65
|
// The target was given as true or false rather than a number. Draft-time checks only.
|
|
61
66
|
bool bTargetIsBool = false;
|
|
62
|
-
// 0 = the run's default.
|
|
67
|
+
// 0 = the run's default; on triggered, 0 waits with no timeout.
|
|
63
68
|
int32 WithinMs = 0;
|
|
69
|
+
// triggered only: the player whose input is watched, as act's client counts them (0 the editor's own player, 1..N remote players).
|
|
70
|
+
int32 Client = 0;
|
|
64
71
|
};
|
|
65
72
|
|
|
66
73
|
struct FScriptStepDef
|
|
@@ -116,7 +123,7 @@ namespace MCPPIE
|
|
|
116
123
|
|
|
117
124
|
// ── Step definitions: JSON and asset ────────────────────────────────
|
|
118
125
|
|
|
119
|
-
// {instruction, judge, agent_judgeable, resolve_in_pie, arrange:[...], act:[...], expect:{value, op, target (number or boolean), within_ms}}.
|
|
126
|
+
// {instruction, judge, agent_judgeable, resolve_in_pie, arrange:[...], act:[...], expect:{value, op, target (number or boolean), within_ms, client}}.
|
|
120
127
|
// OutField, when given, names the field the error is about, such as instruction or expect.op.
|
|
121
128
|
bool ParseScriptStepJson(const TSharedPtr<FJsonValue>& Value, int32 Index, FScriptStepDef& Out, FString& OutError, FString* OutField = nullptr);
|
|
122
129
|
bool ParseScriptStepsJson(const TArray<TSharedPtr<FJsonValue>>& Values, TArray<FScriptStepDef>& Out, FString& OutError);
|
|
@@ -162,6 +169,45 @@ namespace MCPPIE
|
|
|
162
169
|
// Manual steps: what the verdict's author cites. Required for an agent verdict.
|
|
163
170
|
FString Note;
|
|
164
171
|
TArray<FString> Captures;
|
|
172
|
+
// triggered: when the Input Action fired (run ms) and its value on that frame.
|
|
173
|
+
bool bTriggered = false;
|
|
174
|
+
double TriggeredAtMs = -1.0;
|
|
175
|
+
FVector TriggerValue = FVector::ZeroVector;
|
|
176
|
+
// bool, axis1d, axis2d or axis3d; empty when the type is not known.
|
|
177
|
+
FString TriggerValueType;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// A trigger a triggered expectation saw: when (run ms) and the action's value on that frame.
|
|
181
|
+
struct FScriptTrigger
|
|
182
|
+
{
|
|
183
|
+
double AtMs = -1.0;
|
|
184
|
+
FVector Value = FVector::ZeroVector;
|
|
185
|
+
// bool, axis1d, axis2d or axis3d.
|
|
186
|
+
FString ValueType;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
enum class EScriptTriggerRead : uint8
|
|
190
|
+
{
|
|
191
|
+
// The player or the action cannot be watched yet; OutWhy says why.
|
|
192
|
+
Unwatched,
|
|
193
|
+
// Watching; nothing fresh has triggered.
|
|
194
|
+
Watching,
|
|
195
|
+
// A fresh trigger, in OutTrigger.
|
|
196
|
+
Triggered
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// Watches Input Actions for triggered expectations. The run model asks it, so tests drive the model with a fake.
|
|
200
|
+
class IScriptTriggerSource
|
|
201
|
+
{
|
|
202
|
+
public:
|
|
203
|
+
virtual ~IScriptTriggerSource() = default;
|
|
204
|
+
// Step Index's watch, begun on the first call. FromMs opens its window: a trigger counts only after it.
|
|
205
|
+
virtual EScriptTriggerRead ReadTrigger(int32 Index, const FScriptExpect& Expect, double FromMs,
|
|
206
|
+
FScriptTrigger& OutTrigger, FString& OutWhy) = 0;
|
|
207
|
+
// Step Index settled: stop its watch.
|
|
208
|
+
virtual void EndWatch(int32 Index) {}
|
|
209
|
+
// The run ended: stop every watch.
|
|
210
|
+
virtual void Cancel() {}
|
|
165
211
|
};
|
|
166
212
|
|
|
167
213
|
// The evidence a verdict carries: a note plus capture file paths.
|
|
@@ -294,10 +340,12 @@ namespace MCPPIE
|
|
|
294
340
|
bool AreScriptManualStepsSettled(const FScriptRun& Run);
|
|
295
341
|
void AddScriptEvent(FScriptRun& Run, const FString& Type, int32 Step, const TSharedPtr<FJsonObject>& Data);
|
|
296
342
|
// Sequential mode: steps start in order; a running auto step holds the run, and so does a step's act.
|
|
297
|
-
// Without a driver a step's arrange and act are skipped.
|
|
298
|
-
|
|
343
|
+
// Without a driver a step's arrange and act are skipped. Without a trigger source a triggered step is never
|
|
344
|
+
// watched, so it fails at its timeout (or waits for the run to stop when it has none).
|
|
345
|
+
void AdvanceScriptRun(FScriptRun& Run, double NowMs, int64 Frame, FScriptValueReader Reader, IScriptStepDriver* Driver = nullptr,
|
|
346
|
+
IScriptTriggerSource* Triggers = nullptr);
|
|
299
347
|
// Replay mode: every auto step is judged in its own recorded window.
|
|
300
|
-
void AdvanceScriptReplay(FScriptRun& Run, double NowMs, int64 Frame, FScriptValueReader Reader);
|
|
348
|
+
void AdvanceScriptReplay(FScriptRun& Run, double NowMs, int64 Frame, FScriptValueReader Reader, IScriptTriggerSource* Triggers = nullptr);
|
|
301
349
|
// Manual steps only. Source is human (recorded as action), elicitation or agent; an agent
|
|
302
350
|
// verdict needs an evidence note and is refused on a step with agent_judgeable false.
|
|
303
351
|
// A repeated identical verdict succeeds with bOutUnchanged.
|
|
@@ -377,6 +425,7 @@ namespace MCPPIE
|
|
|
377
425
|
FScriptRun Run;
|
|
378
426
|
bool bHasRun = false;
|
|
379
427
|
TSharedPtr<IScriptStepDriver> StepDriver;
|
|
428
|
+
TSharedPtr<class FEditorScriptTriggerSource> TriggerSource;
|
|
380
429
|
|
|
381
430
|
FDelegateHandle EndPIEHandle;
|
|
382
431
|
FDelegateHandle EndFrameHandle;
|