New node types:
- GameData: reads runtime state (structure health, deliveries, resources, etc.)
- Flag: read/write persistent flags by name
- Compare: A [op] B → boolean (>, <, ==, !=, >=, <=)
- Math: A [op] B → number (+, -, *, /)
- Format: template string with {0}, {1} placeholders → string
- Logic: A [op] B → boolean (AND, OR, XOR)
- NOT: boolean → inverted boolean
- Branch: flow in + boolean condition → true/false flow out
- Sequence: flow in → 3 flow outs (executes in order)
Toolbar updated with categorized buttons (Story, Data, Logic).
MiniMap color-coded for all 18 node types.
NodeEditDialog handles all new types with operator/field selectors.
25 lines
808 B
TypeScript
25 lines
808 B
TypeScript
"use client";
|
|
|
|
import { type NodeProps } from "@xyflow/react";
|
|
import { BinaryIcon } from "lucide-react";
|
|
import { NodeHandles } from "./NodeHandles";
|
|
|
|
export function LogicNode({ data }: NodeProps) {
|
|
const d = data as { operator?: string };
|
|
const op = d.operator ?? "AND";
|
|
|
|
return (
|
|
<div className="bg-lime-950/80 border border-lime-500/50 rounded-lg shadow-md min-w-32">
|
|
<NodeHandles nodeType="logic" />
|
|
<div className="flex items-center gap-2 px-3 py-2 border-b border-lime-500/30">
|
|
<BinaryIcon className="size-4 text-lime-400 shrink-0" />
|
|
<span className="text-sm font-medium text-lime-200 flex-1">
|
|
Logic
|
|
</span>
|
|
</div>
|
|
<div className="px-3 py-2 text-center text-sm font-mono text-lime-300">
|
|
{op}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|