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
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
BEHAVIOR_PARAM,
|
||||
BEHAVIOR_START,
|
||||
declaresPropertyPorts,
|
||||
declaresVariablePorts,
|
||||
type DeclaredPort,
|
||||
findNode,
|
||||
@@ -10,6 +11,8 @@ import {
|
||||
type GraphNode,
|
||||
isTerminalNode,
|
||||
isValidPortName,
|
||||
OBJECT_BEHAVIOR_PARAM,
|
||||
propertyTargetOf,
|
||||
RUN_BEHAVIOR,
|
||||
} from '../graph';
|
||||
import type { PropertyValue } from '../model/Properties';
|
||||
@@ -292,7 +295,7 @@ export class RenamePortCommand implements Command {
|
||||
/** Renames one declared port on one node, taking its edges and its typed-in value along. */
|
||||
function renamePortOn(graph: Graph, node: GraphNode, from: string, to: string): void {
|
||||
const ports = node.ports ?? [];
|
||||
if (from === to || !ports.some((p) => p.key === from)) return;
|
||||
if (from === to || !ports.some((p) => p.key === from) || ports.some((p) => p.key === to)) return;
|
||||
node.ports = ports.map((p) => (p.key === from ? { ...p, key: to } : p));
|
||||
for (const site of ownSites(graph, node)) carryPort(site, from, to);
|
||||
}
|
||||
@@ -339,11 +342,25 @@ export class RepointPortCommand implements Command {
|
||||
}
|
||||
|
||||
/**
|
||||
* Follows a renamed variable into the nodes that name it as a port. Their edges and typed-in
|
||||
* Follows a renamed variable into the nodes that name it as a port: the Variables nodes of its own
|
||||
* behavior, and Properties nodes anywhere that point at that behavior. Their edges and typed-in
|
||||
* values move with it – the port key *is* the variable name there.
|
||||
*/
|
||||
export function renameVariablePorts(graph: Graph, from: string, to: string): void {
|
||||
for (const node of graph.nodes) if (declaresVariablePorts(node.type)) renamePortOn(graph, node, from, to);
|
||||
export function renameVariablePorts(project: Project, behaviorId: string, from: string, to: string): void {
|
||||
for (const asset of project.assets) {
|
||||
if (asset.type !== 'behavior') continue;
|
||||
for (const node of asset.graph.nodes)
|
||||
if (namesVariablesOf(node, asset.id, behaviorId)) renamePortOn(asset.graph, node, from, to);
|
||||
}
|
||||
}
|
||||
|
||||
function namesVariablesOf(node: GraphNode, graphOwner: string, behaviorId: string): boolean {
|
||||
if (declaresVariablePorts(node.type)) return graphOwner === behaviorId;
|
||||
return (
|
||||
declaresPropertyPorts(node.type) &&
|
||||
propertyTargetOf(node.params) === 'behavior' &&
|
||||
node.params[OBJECT_BEHAVIOR_PARAM] === behaviorId
|
||||
);
|
||||
}
|
||||
|
||||
/** "in1", "in2", … – the first port name the terminal node does not use yet. */
|
||||
|
||||
@@ -138,7 +138,7 @@ export class RenameVariableCommand implements Command {
|
||||
bag[to] = bag[from]!;
|
||||
delete bag[from];
|
||||
}
|
||||
renameVariablePorts(asset.graph, from, to);
|
||||
renameVariablePorts(project, this.assetId, from, to);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user