Let Destroy keep the children and hand them back as a list
game-maker / gate (push) Successful in 3m15s
game-maker / suite (push) Successful in 9m41s

Destroying a container used to take everything below it along. Now
Destroy can remove just the object itself and pass its direct children
on, so a behavior can keep working with what was inside.

- New input keep children (bool, default off). When on, only the
  object goes. Its direct children move up to the object's parent, or
  to the top level if there is none. Grandchildren stay where they are.
- New output children (object list) with the direct children that were
  kept. It is empty when keep children is off.
- The children keep their place on screen. carriedTransform folds the
  destroyed object's position, rotation and scale into their own, the
  same as reparenting in the editor.
- Behaviors and the rigidbody of the object are always destroyed with
  it and are not in the list. Moved up they would steer or simulate
  the parent.
- World remembers which children it reparented, and syncToModel writes
  their new parent into the scene. A reload of the model keeps it.
- Limit, read from the code only: in the editor run the contents of a
  placed container are not baked. Moved children there last for the
  run only.

Tests:
- ./check.sh: 170 files, 2478 tests, CHECK EXIT 0
- e2e 34 (the module with a Destroy node): ALL PASSED, 21 checks
- world-sync: world matrix of child and grandchild unchanged under a
  rotated and scaled parent, parent survives syncFromModel, top level
  case, already destroyed object gives []
- destroy-keep-children: real graph Destroy(Owner) -> Log(children)
  logs Lid, Label without the grandchild Nail
- 3 counter-probes, all caught: no world transform (1 test fails), no
  parent in the scene (1), behaviors and rigidbody moved up (2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-09-26 21:45:27 +02:00
1 parent 7979b8ff19
commit 483c34bb5c
8 files changed
+196 -17

No files matched your search

+12 -4
View File
@@ -1642,11 +1642,19 @@ describe('action nodes write through to the object they are given', () => {
expect({ x: target.x, y: target.y }).toEqual({ x: 30, y: -40 });
});
it('Destroy hands the object to the context', () => {
it('Destroy hands the object to the context, children and all unless told to keep them', () => {
const removed: string[] = [];
const ctx = fakeContext({ destroy: (target) => removed.push(target.name) });
runDef('Destroy', ctx, { object: fakeEntity('Coin') }, {});
expect(removed).toEqual(['Coin']);
const moved = [fakeEntity('Lid'), fakeEntity('Nail')];
const ctx = fakeContext({
destroy: (target, keepChildren) => {
removed.push(`${target.name} ${keepChildren}`);
return keepChildren ? moved : [];
},
});
expect(runDef('Destroy', ctx, { object: fakeEntity('Coin') }, {}).outputs).toEqual({ children: [] });
const kept = runDef('Destroy', ctx, { object: fakeEntity('Crate'), keepChildren: true }, {});
expect(kept.outputs).toEqual({ children: moved });
expect(removed).toEqual(['Coin false', 'Crate true']);
});
it('RestartGame asks the context for a restart', () => {