A behavior run by another one had a single flow port at its Start and at its End, so it could not branch for its caller. And it could not be used as an event: a call needs a pulse at its flow input, and the events of a called graph never fire. An input like "Confirm" (Space or Enter) had to be built again in every graph. - A declared port of a Start or an End node can be of the kind Flow. It sits above the values and shares their names, exec stays reserved. Only these two nodes declare one, a struct does not. - Run behavior shows a flow port of the Start as a further flow input. A call arriving through it leaves the Start through the output of that name and not through exec. - Run behavior shows a flow port of the End as a further flow output. The call goes on through the one the End was reached by last, and then through exec. exec fires always, as before. - On behavior is a new event node without a flow input. The behavior it names runs at the node for as long as the behavior around it runs, with all of its own events and one set of variables per node. - Its outputs are those of the End. It fires once the inner pulse is through, by the output the End was reached by last, exec only for End.exec. A pulse that never reaches the End is not seen. - The value ports of the Start are its inputs, read anew for each inner pulse. The Start itself never fires there. - It nests to any depth. Under a Run behavior it stays silent. A behavior hearing itself, however far round, is not started and the node says "A behavior cannot listen to itself". - The palette offers every other behavior with an End once more as "On <name>". A node naming one without End says so. - An On node removed while the game runs ends its behavior with On disable and On destroy. The sounds of the entity end only with the behavior placed on it. - Renaming and deleting a declared port follows the edges at On behavior nodes as it does at Run behavior nodes. - The flow outputs of the Start of a behavior placed on an object never fire, like its exec. - The engine prompt of the benchmark names flow ports and On behavior. Tests: - Gate on melektaus-atx right before this commit: 215 files, 3319 tests (3278 + 41), exit 0. - e2e 19 on melektaus-atx: 39 checks (+4), all pass. e2e 1-6,17-24,26,36,51: 628 checks, all pass. - 19 unit tests in flow-ports.test.ts, 19 in on-behavior.test.ts on a real world, the rest in the node catalog. - Four new e2e checks in module 19: a flow port declared by mouse at the End, On Confirm in the graph, the call leaving through the further output while playing, Enter and Space on a real keyboard. - 19 unit counter-probes all fail their tests. One did not at first (a removed node kept its instance), a test was added. Two browser counter-probes fail their checks. - One screenshot looked at: On Confirm with exec and pressed, the second flow pin at the calling node. - The e2e sum of 1680 is counted (1676 + 4), the full suite and the smokes did not run. - Not seen in the browser: flow inputs at the Start, nesting, the ring, values through On behavior, the palette entry. No test holds that the sounds of the entity go on when a heard behavior ends. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
301 lines
8.3 KiB
TypeScript
301 lines
8.3 KiB
TypeScript
import { type NodeDef, registerNode } from '../NodeRegistry';
|
|
import { Destroy } from './action/Destroy';
|
|
import { PauseAnimation, PlayAnimation, StopAnimation } from './action/animationNodes';
|
|
import { Emit } from './action/Emit';
|
|
import { IsGamePaused, PauseGame, ResumeGame, SetTimeScale, TimeScale } from './action/gameTimeNodes';
|
|
import { LoadScene } from './action/LoadScene';
|
|
import { Log } from './action/Log';
|
|
import { IgnoreOneWay } from './action/IgnoreOneWay';
|
|
import { Move } from './action/Move';
|
|
import {
|
|
ApplyForce,
|
|
ApplyImpulse,
|
|
GetVelocity,
|
|
SetAngularVelocity,
|
|
SetGravity,
|
|
SetVelocity,
|
|
} from './action/physicsNodes';
|
|
import { PlaySound } from './action/PlaySound';
|
|
import { Raycast } from './action/Raycast';
|
|
import { RaycastAll } from './action/RaycastAll';
|
|
import { RestartGame } from './action/RestartGame';
|
|
import { SetPosition } from './action/SetPosition';
|
|
import { Spawn } from './action/Spawn';
|
|
import { StopGame } from './action/StopGame';
|
|
import { StopSound } from './action/StopSound';
|
|
import { CellToWorld, SetTile, TileAt, TileLiteral, WorldToCell } from './action/tileNodes';
|
|
import { Abs } from './data/Abs';
|
|
import { Add } from './data/Add';
|
|
import { AnimationLength } from './data/AnimationLength';
|
|
import { AnimationPlaying } from './data/AnimationPlaying';
|
|
import { And } from './data/And';
|
|
import { AxisInput } from './data/AxisInput';
|
|
import { Ceil } from './data/Ceil';
|
|
import { Clamp } from './data/Clamp';
|
|
import { Compare } from './data/Compare';
|
|
import { Distance } from './data/Distance';
|
|
import { Divide } from './data/Divide';
|
|
import { Equals } from './data/Equals';
|
|
import { FindText } from './data/FindText';
|
|
import { FirstNotEmpty } from './data/FirstNotEmpty';
|
|
import { Floor } from './data/Floor';
|
|
import { GetPosition } from './data/GetPosition';
|
|
import { ChildByName } from './data/ChildByName';
|
|
import { Children } from './data/Children';
|
|
import { ChildrenByName } from './data/ChildrenByName';
|
|
import { IsAsset } from './data/IsAsset';
|
|
import { IsEnabled } from './data/IsEnabled';
|
|
import { IsHovered } from './data/IsHovered';
|
|
import { IsInState } from './data/IsInState';
|
|
import { IsTouching } from './data/IsTouching';
|
|
import { Join } from './data/Join';
|
|
import { KeyIsDown } from './data/KeyIsDown';
|
|
import { KeyWasPressed } from './data/KeyWasPressed';
|
|
import { KeyWasReleased } from './data/KeyWasReleased';
|
|
import { LayerOf } from './data/LayerOf';
|
|
import { Length } from './data/Length';
|
|
import { Lerp } from './data/Lerp';
|
|
import {
|
|
AnimationLiteral,
|
|
AssetLiteral,
|
|
BooleanLiteral,
|
|
ListLiteral,
|
|
NumberLiteral,
|
|
SceneLiteral,
|
|
SoundLiteral,
|
|
StateMachineLiteral,
|
|
StringLiteral,
|
|
TextureLiteral,
|
|
} from './data/literals';
|
|
import { Max } from './data/Max';
|
|
import { Min } from './data/Min';
|
|
import { Modulo } from './data/Modulo';
|
|
import { MouseButton } from './data/MouseButton';
|
|
import { MousePosition } from './data/MousePosition';
|
|
import { Multiply } from './data/Multiply';
|
|
import { NameOf } from './data/NameOf';
|
|
import { Normalize } from './data/Normalize';
|
|
import { Not } from './data/Not';
|
|
import { ObjectByName } from './data/ObjectByName';
|
|
import { ObjectsByName } from './data/ObjectsByName';
|
|
import { ObjectsOfAsset } from './data/ObjectsOfAsset';
|
|
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';
|
|
import { Select } from './data/Select';
|
|
import { Self } from './data/Self';
|
|
import { Sqrt } from './data/Sqrt';
|
|
import { Substring } from './data/Substring';
|
|
import { Subtract } from './data/Subtract';
|
|
import { Time } from './data/Time';
|
|
import { ToNumber } from './data/ToNumber';
|
|
import { ToText } from './data/ToText';
|
|
import { AddItem } from './data/AddItem';
|
|
import { Concat } from './data/Concat';
|
|
import { Count } from './data/Count';
|
|
import { CurrentState } from './data/CurrentState';
|
|
import { ExpandStruct } from './data/ExpandStruct';
|
|
import { Fill } from './data/Fill';
|
|
import { IndexOf } from './data/IndexOf';
|
|
import { ItemAt } from './data/ItemAt';
|
|
import { SetItem } from './data/SetItem';
|
|
import { SubList } from './data/SubList';
|
|
import { TextureSize } from './data/TextureSize';
|
|
import { OnAnimationFinished } from './events/OnAnimationFinished';
|
|
import { OnBehavior } from './events/OnBehavior';
|
|
import { OnClick } from './events/OnClick';
|
|
import { OnMouseWheel } from './events/OnMouseWheel';
|
|
import { OnCollisionEnter } from './events/OnCollisionEnter';
|
|
import { OnCollisionExit } from './events/OnCollisionExit';
|
|
import { OnCollisionStay } from './events/OnCollisionStay';
|
|
import { OnDestroy } from './events/OnDestroy';
|
|
import { OnDisable } from './events/OnDisable';
|
|
import { OnEnable } from './events/OnEnable';
|
|
import { OnKeyDown } from './events/OnKeyDown';
|
|
import { OnKeyHeld } from './events/OnKeyHeld';
|
|
import { OnKeyUp } from './events/OnKeyUp';
|
|
import { OnStart } from './events/OnStart';
|
|
import { OnStateEntered } from './events/OnStateEntered';
|
|
import { OnStateExited } from './events/OnStateExited';
|
|
import { OnTimer } from './events/OnTimer';
|
|
import { OnUpdate } from './events/OnUpdate';
|
|
import { BehaviorEnd } from './flow/BehaviorEnd';
|
|
import { BehaviorStart } from './flow/BehaviorStart';
|
|
import { Branch } from './flow/Branch';
|
|
import { Find } from './flow/Find';
|
|
import { ForEach } from './flow/ForEach';
|
|
import { Match } from './flow/Match';
|
|
import { Repeat } from './flow/Repeat';
|
|
import { RunBehavior } from './flow/RunBehavior';
|
|
import { Sequence } from './flow/Sequence';
|
|
import { SetState } from './flow/SetState';
|
|
import { SetStateByName } from './flow/SetStateByName';
|
|
import { StateBranch } from './flow/StateBranch';
|
|
import { StateTransition } from './flow/StateTransition';
|
|
import { PARTICLE_NODES } from '../../particles/nodes';
|
|
import { SHADER_NODES } from '../../shader/nodes';
|
|
import { State } from '../stateMachine';
|
|
import { Variables } from './variable/Variables';
|
|
|
|
/**
|
|
* Importing this module registers the built-in nodes. The palette sorts by category and label, so
|
|
* the order here is documentation only.
|
|
*/
|
|
export const BUILT_IN_NODES: readonly NodeDef[] = [
|
|
OnStart,
|
|
OnEnable,
|
|
OnUpdate,
|
|
OnDisable,
|
|
OnDestroy,
|
|
OnKeyDown,
|
|
OnKeyUp,
|
|
OnKeyHeld,
|
|
OnTimer,
|
|
OnCollisionEnter,
|
|
OnCollisionStay,
|
|
OnCollisionExit,
|
|
OnClick,
|
|
OnMouseWheel,
|
|
OnAnimationFinished,
|
|
OnBehavior,
|
|
OnStateEntered,
|
|
OnStateExited,
|
|
BehaviorStart,
|
|
Branch,
|
|
Sequence,
|
|
Repeat,
|
|
ForEach,
|
|
Find,
|
|
Match,
|
|
RunBehavior,
|
|
StateBranch,
|
|
SetState,
|
|
SetStateByName,
|
|
StateTransition,
|
|
CurrentState,
|
|
IsInState,
|
|
BehaviorEnd,
|
|
Variables,
|
|
Self,
|
|
Owner,
|
|
Parent,
|
|
ObjectByName,
|
|
ObjectsByName,
|
|
ChildByName,
|
|
ChildrenByName,
|
|
Children,
|
|
NameOf,
|
|
IsAsset,
|
|
ObjectsOfAsset,
|
|
IsEnabled,
|
|
Properties,
|
|
GetPosition,
|
|
TextureSize,
|
|
AnimationPlaying,
|
|
AnimationLength,
|
|
NumberLiteral,
|
|
BooleanLiteral,
|
|
StringLiteral,
|
|
TextureLiteral,
|
|
StateMachineLiteral,
|
|
SoundLiteral,
|
|
SceneLiteral,
|
|
AnimationLiteral,
|
|
AssetLiteral,
|
|
Add,
|
|
Subtract,
|
|
Multiply,
|
|
Divide,
|
|
Min,
|
|
Max,
|
|
Abs,
|
|
Sqrt,
|
|
Clamp,
|
|
Lerp,
|
|
Floor,
|
|
Ceil,
|
|
Round,
|
|
Modulo,
|
|
Random,
|
|
Time,
|
|
ToText,
|
|
ToNumber,
|
|
Join,
|
|
Substring,
|
|
FindText,
|
|
Equals,
|
|
Compare,
|
|
FirstNotEmpty,
|
|
Select,
|
|
And,
|
|
Or,
|
|
Not,
|
|
ListLiteral,
|
|
Fill,
|
|
Count,
|
|
ItemAt,
|
|
SetItem,
|
|
AddItem,
|
|
SubList,
|
|
Concat,
|
|
IndexOf,
|
|
PackStruct,
|
|
ExpandStruct,
|
|
Length,
|
|
Distance,
|
|
Normalize,
|
|
AxisInput,
|
|
KeyIsDown,
|
|
KeyWasPressed,
|
|
KeyWasReleased,
|
|
MousePosition,
|
|
MouseButton,
|
|
IsHovered,
|
|
IsTouching,
|
|
LayerOf,
|
|
Move,
|
|
SetPosition,
|
|
GetVelocity,
|
|
ApplyForce,
|
|
ApplyImpulse,
|
|
SetVelocity,
|
|
SetAngularVelocity,
|
|
SetGravity,
|
|
Raycast,
|
|
RaycastAll,
|
|
IgnoreOneWay,
|
|
TileAt,
|
|
SetTile,
|
|
WorldToCell,
|
|
CellToWorld,
|
|
TileLiteral,
|
|
Spawn,
|
|
Destroy,
|
|
Emit,
|
|
PlayAnimation,
|
|
PauseAnimation,
|
|
StopAnimation,
|
|
PlaySound,
|
|
StopSound,
|
|
LoadScene,
|
|
Log,
|
|
StopGame,
|
|
RestartGame,
|
|
PauseGame,
|
|
ResumeGame,
|
|
IsGamePaused,
|
|
SetTimeScale,
|
|
TimeScale,
|
|
];
|
|
|
|
for (const def of BUILT_IN_NODES) registerNode(def);
|
|
// Registered so a machine's, a shader's or a particle graph loads and draws, but not built in: no
|
|
// behavior graph offers them.
|
|
registerNode(State);
|
|
for (const def of SHADER_NODES) registerNode(def);
|
|
for (const def of PARTICLE_NODES) registerNode(def);
|