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
+15
-13
@@ -8,8 +8,7 @@ export const BEHAVIOR_START = 'BehaviorStart';
|
||||
export const BEHAVIOR_END = 'BehaviorEnd';
|
||||
export const RUN_BEHAVIOR = 'RunBehavior';
|
||||
export const VARIABLES = 'Variables';
|
||||
export const GET_PROPERTIES = 'GetProperties';
|
||||
export const SET_PROPERTIES = 'SetProperties';
|
||||
export const PROPERTIES = 'Properties';
|
||||
|
||||
export const BEHAVIOR_PARAM = 'behavior';
|
||||
|
||||
@@ -24,7 +23,7 @@ export function declaresVariablePorts(type: string): boolean {
|
||||
|
||||
/** Nodes whose declared ports are properties of the object they are handed. */
|
||||
export function declaresPropertyPorts(type: string): boolean {
|
||||
return type === GET_PROPERTIES || type === SET_PROPERTIES;
|
||||
return type === PROPERTIES;
|
||||
}
|
||||
|
||||
/** Identifier-like, and not `exec`: that key belongs to the fixed flow port of every terminal node. */
|
||||
@@ -32,12 +31,15 @@ export function isValidPortName(name: string): boolean {
|
||||
return isValidFieldName(name) && name !== 'exec';
|
||||
}
|
||||
|
||||
/** Keys a declared port cannot take: the node's fixed ports on the side it declares (`object`). */
|
||||
/**
|
||||
* Keys a declared port cannot take: the node's fixed ports on the side it declares (`object`), and
|
||||
* its settings, which share the params bag with the typed-in values of its inputs.
|
||||
*/
|
||||
export function fixedPortKeys(def: NodeDef): string[] {
|
||||
const side = def.declaresPorts;
|
||||
const fixed =
|
||||
side === 'inputs' ? def.inputs : side === 'outputs' ? def.outputs : [...def.inputs, ...def.outputs];
|
||||
return fixed.map((p) => p.key);
|
||||
return [...fixed.map((p) => p.key), ...def.params.map((p) => p.key)];
|
||||
}
|
||||
|
||||
export function declaredOn(
|
||||
@@ -81,16 +83,16 @@ export function resolveDef(node: GraphNode, graph: Graph, lookup: BehaviorLookup
|
||||
if (!def || (!def.declaresPorts && !def.derivePorts)) return def;
|
||||
const own = (side: 'inputs' | 'outputs') =>
|
||||
declaredOn(def, node.ports ?? [], side).map((p) =>
|
||||
def.declaredPort ? def.declaredPort(p) : portDefOf(p),
|
||||
def.declaredPort ? def.declaredPort(p, node) : portDefOf(p),
|
||||
);
|
||||
const grown = def.derivePorts?.({ node, graph, behaviors: lookup }) ?? {};
|
||||
// Derived before declared: a derived exec pin belongs at the top.
|
||||
return {
|
||||
...def,
|
||||
label: grown.label ?? def.label,
|
||||
inputs: [...def.inputs, ...(grown.inputs ?? []), ...own('inputs')],
|
||||
outputs: [...def.outputs, ...(grown.outputs ?? []), ...own('outputs')],
|
||||
};
|
||||
const side = (key: 'inputs' | 'outputs') => execFirst([...def[key], ...(grown[key] ?? []), ...own(key)]);
|
||||
return { ...def, label: grown.label ?? def.label, inputs: side('inputs'), outputs: side('outputs') };
|
||||
}
|
||||
|
||||
/** A derived exec pin belongs at the top, above the fixed data ports too. */
|
||||
function execFirst(ports: PortDef[]): PortDef[] {
|
||||
return [...ports.filter((p) => p.type === 'exec'), ...ports.filter((p) => p.type !== 'exec')];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user