Let each variable of a behavior choose whether calls keep it (#229)
The first version of #229 put a Keep state switch on the Run behavior node. The user wanted it where the variable is declared instead. Whether a value lives on belongs to the variable, not to every call site. - The node switch keepState is gone again. RunBehavior, CallResult and nested.ts are back to what they were before #229. - BehaviorAsset.keptVariables lists the kept names. It lives on the asset and not in PropertyDef, because that is the schema of every inspector row. - A variable added from now on starts with Keep on. Variables in existing projects start with Keep off, so old projects run unchanged. - SetVariableKeptCommand flips the switch as one undo step. Add, remove and rename carry the list along. Loading drops names that are not declared. - The interpreter keeps only the listed variables, per Run behavior node and per object as before. The others start at their defaults. - Local state machines in a called behavior start empty on every call again, as before #229. Global and scene machines are unchanged. - The inspector shows a Keep button in each variable row of a behavior. Its state is part of the asset signature, so a click redraws the row. Without that the button kept its old look until the inspector was reopened. Found: the project Garden of Sacrifices still has keepState = true on the call Player -> Character Movement. It is ignored now. Direction there predates the switch, so Keep is off until set by hand. Tests: - ./check.sh: 163 files, 2392 tests, CHECK EXIT 0 (before 2388) - tests/core/keep-state.test.ts rewritten, 15 tests - e2e 19: ALL PASSED, 35 checks. 19c-ii now clicks the Keep button of a new variable: on when added, off by a click, on again, off after undo. - Counter-checks, each fails its own test: keep list ignored (2), states kept (1), new variable not kept (8), rename drops the list (1), no Keep button (e2e 19c-ii). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7c70245c79
commit
454d202109
14 files changed
+333
-149
No files matched your search
@@ -137,18 +137,12 @@ const CASES: Record<string, Case[]> = {
|
||||
name: 'asks for the named behavior to run, passing its inputs on',
|
||||
inputs: { power: 3 },
|
||||
params: { behavior: 'b1' },
|
||||
call: { behaviorId: 'b1', inputs: { power: 3 }, keep: false },
|
||||
next: 'exec',
|
||||
},
|
||||
{
|
||||
name: 'asks for the call to keep its state when Keep state is on',
|
||||
params: { behavior: 'b1', keepState: true },
|
||||
call: { behaviorId: 'b1', inputs: {}, keep: true },
|
||||
call: { behaviorId: 'b1', inputs: { power: 3 } },
|
||||
next: 'exec',
|
||||
},
|
||||
{
|
||||
name: 'without a behavior chosen it still continues, calling nothing that exists',
|
||||
call: { behaviorId: '', inputs: {}, keep: false },
|
||||
call: { behaviorId: '', inputs: {} },
|
||||
next: 'exec',
|
||||
},
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user