Replace the property nodes with one Properties node
Get/Set property, Get/Set properties, Set enabled and Set text are gone. A single Properties node takes a fixed "object" input; every chosen property is an output that reads the current value, and one switched to Set is also an input written when the flow arrives. Exec pins only exist while at least one entry writes. The node carries a type (Sprite, Text, Collider, Camera, Container, Behavior, Any) that decides what "+ Property" offers: the fields of that type, the variables of the chosen behavior, or for Any a kind to pick and a name to type. Each port takes the default and field of its type, so a Camera width starts at 640. Switching the type keeps the ports and marks those the new type lacks. At runtime the type is only an editor aid; the node writes to whatever object it gets. Old project files are converted on load. The type is inferred from the keys: the first object type that has them all, else the one behavior that declares them all, else Any. enabled belongs to every object, so a converted Set enabled lands on Any. The jump-run and tetris seeders use Properties throughout; draw-piece switches its cell on in the same node that sets the colour. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7c63c884ef
commit
58f19a3451
36 files changed
+1040
-719
No files matched your search
+19
-107
@@ -125,6 +125,25 @@ const CASES: Record<string, Case[]> = {
|
||||
after: (ctx) => expect(ctx.variables).toEqual({ speed: 100 }),
|
||||
},
|
||||
],
|
||||
Properties: [
|
||||
{
|
||||
name: 'writes the properties switched to Set, each keeping the type it already had',
|
||||
ports: [
|
||||
{ key: 'width', kind: 'number', write: true },
|
||||
{ key: 'text', kind: 'text', write: true },
|
||||
{ key: 'height', kind: 'number' },
|
||||
],
|
||||
inputs: { object: painted, width: '250', text: 7 },
|
||||
next: 'exec',
|
||||
after: () => expect(painted.props).toEqual({ width: 250, text: '7' }),
|
||||
},
|
||||
{
|
||||
name: 'no object is a no-op',
|
||||
ports: [{ key: 'width', kind: 'number', write: true }],
|
||||
inputs: { object: null, width: 5 },
|
||||
next: 'exec',
|
||||
},
|
||||
],
|
||||
|
||||
// references and properties
|
||||
|
||||
@@ -180,43 +199,6 @@ const CASES: Record<string, Case[]> = {
|
||||
},
|
||||
{ name: 'no object is off', inputs: { object: null }, outputs: { result: false, own: false } },
|
||||
],
|
||||
GetProperties: [
|
||||
{
|
||||
name: 'reads one output per property it names',
|
||||
ports: [
|
||||
{ key: 'width', kind: 'number' },
|
||||
{ key: 'speed', kind: 'number' },
|
||||
],
|
||||
inputs: { object: fakeHandle({ width: 42, speed: 3 }) },
|
||||
outputs: { width: 42, speed: 3 },
|
||||
},
|
||||
{
|
||||
name: 'an absent property reads as null',
|
||||
ports: [{ key: 'radius', kind: 'number' }],
|
||||
inputs: { object: fakeHandle({}) },
|
||||
outputs: { radius: null },
|
||||
},
|
||||
{
|
||||
name: 'no object reads null for every port',
|
||||
ports: [{ key: 'width', kind: 'number' }],
|
||||
inputs: { object: null },
|
||||
outputs: { width: null },
|
||||
},
|
||||
],
|
||||
GetProperty: [
|
||||
{
|
||||
name: 'reads a property',
|
||||
inputs: { object: fakeHandle({ width: 42 }) },
|
||||
params: { property: 'width' },
|
||||
outputs: { value: 42 },
|
||||
},
|
||||
{
|
||||
name: 'an absent property is null',
|
||||
inputs: { object: fakeHandle({}) },
|
||||
params: { property: 'width' },
|
||||
outputs: { value: null },
|
||||
},
|
||||
],
|
||||
GetPosition: [
|
||||
{
|
||||
name: 'local and world position of a top-level object are the same',
|
||||
@@ -599,24 +581,6 @@ const CASES: Record<string, Case[]> = {
|
||||
outputs: { blockedX: false, blockedY: false },
|
||||
},
|
||||
],
|
||||
SetProperties: [
|
||||
{
|
||||
name: 'writes every property it names, each keeping the type it already had',
|
||||
ports: [
|
||||
{ key: 'width', kind: 'number' },
|
||||
{ key: 'text', kind: 'text' },
|
||||
],
|
||||
inputs: { object: painted, width: '250', text: 7 },
|
||||
next: 'exec',
|
||||
after: () => expect(painted.props).toEqual({ width: 250, text: '7' }),
|
||||
},
|
||||
{
|
||||
name: 'no object is a no-op',
|
||||
ports: [{ key: 'width', kind: 'number' }],
|
||||
inputs: { object: null, width: 5 },
|
||||
next: 'exec',
|
||||
},
|
||||
],
|
||||
SetPosition: [
|
||||
{
|
||||
name: 'places the object and continues',
|
||||
@@ -625,34 +589,6 @@ const CASES: Record<string, Case[]> = {
|
||||
},
|
||||
{ name: 'no object is a no-op', inputs: { object: null, x: 1, y: 1 }, next: 'exec' },
|
||||
],
|
||||
SetProperty: [
|
||||
{
|
||||
name: 'writes a property, keeping the existing type',
|
||||
inputs: { object: fakeHandle({ width: 100 }), value: '250' },
|
||||
params: { property: 'width' },
|
||||
next: 'exec',
|
||||
},
|
||||
{
|
||||
name: 'no property name chosen writes nothing',
|
||||
inputs: { object: fakeHandle({ width: 100 }), value: 5 },
|
||||
next: 'exec',
|
||||
},
|
||||
],
|
||||
SetEnabled: [
|
||||
{
|
||||
name: 'switches an object off',
|
||||
inputs: { object: fakeHandle({ enabled: true }), enabled: false },
|
||||
next: 'exec',
|
||||
},
|
||||
{ name: 'no object is a no-op', inputs: { object: null, enabled: false }, next: 'exec' },
|
||||
],
|
||||
SetText: [
|
||||
{
|
||||
name: 'writes the content of a text object',
|
||||
inputs: { object: fakeHandle({ text: 'a' }), text: 12 },
|
||||
next: 'exec',
|
||||
},
|
||||
],
|
||||
Spawn: [
|
||||
{
|
||||
name: 'no asset chosen logs a hint and continues with no object',
|
||||
@@ -773,30 +709,6 @@ describe('action nodes write through to the object they are given', () => {
|
||||
expect({ x: target.x, y: target.y }).toEqual({ x: 30, y: -40 });
|
||||
});
|
||||
|
||||
it('SetProperty keeps the type the property already had', () => {
|
||||
const target = fakeHandle({ width: 100 });
|
||||
runDef('SetProperty', fakeContext(), { object: target, value: '250' }, { property: 'width' });
|
||||
expect(target.props.width).toBe(250);
|
||||
});
|
||||
|
||||
it('SetProperty without a property name writes nothing', () => {
|
||||
const target = fakeHandle({ width: 100 });
|
||||
runDef('SetProperty', fakeContext(), { object: target, value: 5 }, {});
|
||||
expect(target.props).toEqual({ width: 100 });
|
||||
});
|
||||
|
||||
it('SetEnabled switches the object off', () => {
|
||||
const target = fakeHandle({ enabled: true });
|
||||
runDef('SetEnabled', fakeContext(), { object: target, enabled: false }, {});
|
||||
expect(target.props.enabled).toBe(false);
|
||||
});
|
||||
|
||||
it('SetText writes the text property, stringifying numbers', () => {
|
||||
const target = fakeHandle({ text: 'a' });
|
||||
runDef('SetText', fakeContext(), { object: target, text: 12 }, {});
|
||||
expect(target.props.text).toBe('12');
|
||||
});
|
||||
|
||||
it('Destroy hands the object to the context', () => {
|
||||
const removed: string[] = [];
|
||||
const ctx = fakeContext({ destroy: (target) => removed.push(target.name) });
|
||||
|
||||
Reference in new issue
Block a user