From a045c4a1869a03759cf8c5abe32751e50d56c310 Mon Sep 17 00:00:00 2001 From: meleki Date: Tue, 29 Sep 2026 09:21:42 +0200 Subject: [PATCH] Describe the event order and the Order field (#264) - Behaviors: new section Event order. A frame runs event kind by event kind, Order sorts within a kind, ties go by hierarchy and then creation order. The lifecycle sentence on destroying is fixed. - Architecture: names core/graph/eventOrder.ts. - Development: the e2e total is 1551, measured. Co-Authored-By: Claude Opus 5.5 --- Architecture.md | 1 + Behaviors.md | 17 ++++++++++++++--- Development.md | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Architecture.md b/Architecture.md index 707bedc..bb1f11d 100644 --- a/Architecture.md +++ b/Architecture.md @@ -81,6 +81,7 @@ src/core/graph/ graph model, NodeRegistry/NodeContext/values (a travellin narrows one down to what a PropertyBag may hold, #157), interpreter, dropTarget, nested (behaviors as nodes), emitGraph (the walk both graph compilers share: each node once, in dependency order; cycles and property names reported), sharedState (what a run shares: a bag per Variables asset, the state of a global machine; what a scene change carries forward and what it starts afresh, #164), + eventOrder (#264: the Order setting of event nodes and how the pulses of one event kind are sorted), portTypes (#207: ports of one node that carry the same value, and the type their inputs agree on), savedValues (#166: the SaveArea a run reads persistent Variables assets from and writes them to, and restoring a save through today's declaration), stateMachine (the State node, a machine's states, the ports they become), variablePorts, propertyPorts, diff --git a/Behaviors.md b/Behaviors.md index 6ad51d0..6ad8199 100644 --- a/Behaviors.md +++ b/Behaviors.md @@ -516,9 +516,20 @@ playing use the same two words. states survive, and switching it on again is `On enable`, not `On start`. `On destroy` runs when the object leaves the world — through `Destroy`, as a child of a destroyed object, and when the game stops or restarts; a restart is therefore `On disable` → `On destroy` → (new world) `On start` - → `On enable`. The frame that destroys an object still runs to its end, the two farewell events - follow at the end of it; an object destroyed while off gets `On destroy` alone. Off and on again - within one frame is no edge: neither event fires. + → `On enable`. An object destroyed during a frame gets no further events of that frame, the two + farewell events follow at the end of it; an object destroyed while off gets `On destroy` alone. + Off and on again within one frame is no edge: neither event fires. +- **Event order**: a frame goes event kind by event kind, each across every behavior: `On disable`, + `On enable`, `On key down`, `On key up`, `On key held`, `On timer`, `On collision enter`, + `On collision stay`, `On collision exit`, `On animation finished`, `On click`, `On mouse wheel` + and last `On update`. So a key event of any behavior runs before the first `On update`. The state + events a kind caused follow right after it. New instances get all their `On start` and then all + their `On enable`, a finished world all `On disable` and then all `On destroy`. Within one kind + every event node has the setting *Order*, a whole number, 0 by default: a lower order runs first, + whatever behavior it sits in, so `-10` runs before everything left at 0. Equal orders run in + hierarchy order, top to bottom as the hierarchy shows it right now (a spawned object stands where + it was put), and within one graph in the order the nodes were made. The node shows `Order: 5` + only when the order is not 0. - **Runtime**: `BehaviorSystem` creates one `GraphInterpreter` per behavior entity; graphs only touch world entities. A runaway pulse throws (see *Loops* for the two limits) and stops play with a notice. diff --git a/Development.md b/Development.md index 692ba4d..bab985d 100644 --- a/Development.md +++ b/Development.md @@ -15,7 +15,7 @@ npm run build # writes dist/ and regenerates index.html php tools/make-user.php [admin|user] # an account; every tool signs in (see Accounts) php tests/php/accounts.test.php # the API's account rules, no server needed (CI's gate job) php tests/php/snapshots.test.php # the snapshot store (#231), the same way -node tools/seed-e2e.mjs && node tools/e2e.mjs # 1549 editor checks, screenshots in /tmp/gm-e2e-*.png +node tools/seed-e2e.mjs && node tools/e2e.mjs # 1551 editor checks, screenshots in /tmp/gm-e2e-*.png GM_STEPS=20 node tools/e2e.mjs # or 1-12, or 6,20 — a subset while working on one step ./e2e.sh start [GM_STEPS] # the same run detached, see below ./e2e.sh status # live progress, or the last run's result