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:
rootandClaude Opus 5 committed 2026-09-11 18:40:47 +02:00
1 parent 7c63c884ef
commit 58f19a3451
36 files changed
+1040 -719

No files matched your search

-20
View File
@@ -1,20 +0,0 @@
import type { NodeDef } from '../../NodeRegistry';
import { asBoolean, asEntity } from '../../values';
import { bool, exec, obj, withDefault } from '../shared';
export const SetEnabled: NodeDef = {
type: 'SetEnabled',
label: 'Set enabled',
category: 'action',
description:
'Switches an object on or off. A disabled object is not drawn, does not collide and its behavior stops – ' +
'and so does everything parented below it. This is how screens (title, win, lose) are shown and hidden.',
inputs: [exec(), obj('object'), withDefault(bool('enabled'), true)],
outputs: [exec()],
params: [],
run: (_ctx, inputs) => {
const target = asEntity(inputs.object);
if (target) target.props.enabled = asBoolean(inputs.enabled);
return { next: 'exec' };
},
};
@@ -1,28 +0,0 @@
import { SET_PROPERTIES } from '../../nested';
import type { NodeDef } from '../../NodeRegistry';
import { propertyPort } from '../../propertyPorts';
import { asEntity, writeTyped } from '../../values';
import { exec, obj } from '../shared';
/**
* The plural of Set property: one input per property picked. Like Set variables it writes every
* property it lists each time it runs – an unconnected input writes the value typed on the node.
*/
export const SetProperties: NodeDef = {
type: SET_PROPERTIES,
label: 'Set properties',
category: 'action',
description: 'Writes several properties (width, color, …) of an object at once, one input per property.',
inputs: [exec(), obj('object')],
outputs: [exec()],
params: [],
declaresPorts: 'inputs',
declaredPort: propertyPort,
run: (_ctx, inputs, _params, def) => {
const target = asEntity(inputs.object);
if (target)
for (const port of def.inputs.slice(SetProperties.inputs.length))
writeTyped(target.props, port.key, inputs[port.key]);
return { next: 'exec' };
},
};
@@ -1,20 +0,0 @@
import { textOf } from '../../../model/Properties';
import type { NodeDef } from '../../NodeRegistry';
import { asEntity, writeTyped } from '../../values';
import { any, exec, obj, PROPERTY_PARAM } from '../shared';
export const SetProperty: NodeDef = {
type: 'SetProperty',
label: 'Set property',
category: 'action',
description: 'Writes a property (width, color, …) of an object.',
inputs: [exec(), obj('object'), any('value')],
outputs: [exec()],
params: [PROPERTY_PARAM],
run: (_ctx, inputs, params) => {
const target = asEntity(inputs.object);
const key = textOf(params.property ?? '');
if (target && key) writeTyped(target.props, key, inputs.value);
return { next: 'exec' };
},
};
-18
View File
@@ -1,18 +0,0 @@
import type { NodeDef } from '../../NodeRegistry';
import { asEntity, asString } from '../../values';
import { any, exec, obj } from '../shared';
export const SetText: NodeDef = {
type: 'SetText',
label: 'Set text',
category: 'action',
description: 'Writes the content of a text object (same as Set property "text").',
inputs: [exec(), obj('object'), any('text')],
outputs: [exec()],
params: [],
run: (_ctx, inputs) => {
const target = asEntity(inputs.object);
if (target) target.props.text = asString(inputs.text);
return { next: 'exec' };
},
};
@@ -1,24 +0,0 @@
import { GET_PROPERTIES } from '../../nested';
import type { NodeDef } from '../../NodeRegistry';
import { propertyPort } from '../../propertyPorts';
import { asEntity, type Value } from '../../values';
import { obj } from '../shared';
/** The plural of Get property: one output per property picked, the way Get variables reads. */
export const GetProperties: NodeDef = {
type: GET_PROPERTIES,
label: 'Get properties',
category: 'data',
description: 'Reads several properties (width, color, …) of an object at once, one output per property.',
inputs: [obj('object')],
outputs: [],
params: [],
declaresPorts: 'outputs',
declaredPort: propertyPort,
run: (_ctx, inputs, _params, def) => {
const target = asEntity(inputs.object);
const outputs: Record<string, Value> = {};
for (const port of def.outputs) outputs[port.key] = target?.props[port.key] ?? null;
return { outputs };
},
};
-17
View File
@@ -1,17 +0,0 @@
import { textOf } from '../../../model/Properties';
import type { NodeDef } from '../../NodeRegistry';
import { asEntity } from '../../values';
import { any, obj, PROPERTY_PARAM } from '../shared';
export const GetProperty: NodeDef = {
type: 'GetProperty',
label: 'Get property',
category: 'data',
description: 'Reads a property (width, color, …) of an object.',
inputs: [obj('object')],
outputs: [any('value')],
params: [PROPERTY_PARAM],
run: (_ctx, inputs, params) => ({
outputs: { value: asEntity(inputs.object)?.props[textOf(params.property ?? '')] ?? null },
}),
};
+38
View File
@@ -0,0 +1,38 @@
import { PROPERTIES } from '../../nested';
import type { NodeDef } from '../../NodeRegistry';
import {
OBJECT_BEHAVIOR_SETTING,
OBJECT_TYPE_SETTING,
propertiesTitle,
propertyPort,
} from '../../propertyPorts';
import { asEntity, writeTyped } from '../../values';
import { exec, obj } from '../shared';
export const Properties: NodeDef = {
type: PROPERTIES,
label: 'Properties',
category: 'data',
description:
'Reads properties (width, color, a variable, …) of the object it is handed, at any time. Those ' +
'switched to Set are written together when the flow arrives.',
inputs: [obj('object')],
outputs: [],
params: [OBJECT_TYPE_SETTING, OBJECT_BEHAVIOR_SETTING],
// The title names both ("Sprite properties", "Game properties").
hiddenParams: () => [OBJECT_TYPE_SETTING.key, OBJECT_BEHAVIOR_SETTING.key],
declaresPorts: 'both',
declaredPort: (port, node) => propertyPort(port, node.params),
derivePorts: ({ node, behaviors }) => {
const label = propertiesTitle(node, behaviors);
return (node.ports ?? []).some((p) => p.write) ? { label, inputs: [exec()], outputs: [exec()] } : { label };
},
read: (_ctx, _params, input) => asEntity(input('object'))?.props ?? {},
run: (_ctx, inputs, _params, def) => {
const target = asEntity(inputs.object);
if (target)
for (const port of def.inputs)
if (port.type !== 'exec' && port.key !== 'object') writeTyped(target.props, port.key, inputs[port.key]);
return { next: 'exec' };
},
};
+2 -12
View File
@@ -3,11 +3,7 @@ import { Destroy } from './action/Destroy';
import { Log } from './action/Log';
import { Move } from './action/Move';
import { RestartGame } from './action/RestartGame';
import { SetEnabled } from './action/SetEnabled';
import { SetPosition } from './action/SetPosition';
import { SetProperties } from './action/SetProperties';
import { SetProperty } from './action/SetProperty';
import { SetText } from './action/SetText';
import { Spawn } from './action/Spawn';
import { StopGame } from './action/StopGame';
import { Abs } from './data/Abs';
@@ -24,8 +20,6 @@ import { Equals } from './data/Equals';
import { FindText } from './data/FindText';
import { Floor } from './data/Floor';
import { GetPosition } from './data/GetPosition';
import { GetProperties } from './data/GetProperties';
import { GetProperty } from './data/GetProperty';
import { IsAsset } from './data/IsAsset';
import { IsEnabled } from './data/IsEnabled';
import { IsHovered } from './data/IsHovered';
@@ -47,6 +41,7 @@ import { ObjectByName } from './data/ObjectByName';
import { Or } from './data/Or';
import { Owner } from './data/Owner';
import { PackStruct } from './data/PackStruct';
import { Properties } from './data/Properties';
import { Parent } from './data/Parent';
import { Random } from './data/Random';
import { Round } from './data/Round';
@@ -118,8 +113,7 @@ export const BUILT_IN_NODES: readonly NodeDef[] = [
NameOf,
IsAsset,
IsEnabled,
GetProperty,
GetProperties,
Properties,
GetPosition,
// data: literals and math
NumberLiteral,
@@ -176,10 +170,6 @@ export const BUILT_IN_NODES: readonly NodeDef[] = [
// actions
Move,
SetPosition,
SetProperty,
SetProperties,
SetEnabled,
SetText,
Spawn,
Destroy,
Log,
+1 -10
View File
@@ -1,17 +1,8 @@
import type { PropertyValue } from '../../model/Properties';
import { OBJECT_PROPERTY_SUGGESTIONS, type PropertyDef } from '../../properties/PropertySchema';
import type { PropertyDef } from '../../properties/PropertySchema';
import type { NodeDef, PortDef } from '../NodeRegistry';
import { asBoolean, asNumber } from '../values';
/** The property a Get/Set property node names: typed freely, or picked from the built-in ones. */
export const PROPERTY_PARAM: PropertyDef = {
key: 'property',
label: 'Property',
kind: 'text',
default: 'width',
suggestions: OBJECT_PROPERTY_SUGGESTIONS,
};
export const exec = (key = 'exec', label = ''): PortDef => ({ key, label, type: 'exec' });
export const num = (key: string, label = key): PortDef => ({ key, label, type: 'number' });
export const bool = (key: string, label = key): PortDef => ({ key, label, type: 'boolean' });