Commit Graph

9 Commits

Author SHA1 Message Date
hyper 204b9100e6 feat(bt): Rename repeat to cycle and refactor runner
Rework task execution to be synchronous within a single tick.
Scheduling boundaries are now defined by `cycle` nodes, which
replace the previous `repeat` decorator.  All tasks are executed
immediately when scheduled, and parent/child propagation is
handled inline.
2026-06-28 14:51:52 +08:00
hyper 1253bf82d2 feat(bt)!: Remove legacy tree definition format
The `LegacyTreeDef` type and its normalization path have been removed.
All tree definitions must now use the factory functions (`leaf`,
`sequential`, `parallel`, `selector`, `random`, `repeat`). The
`TreeDef` type is now simply `TaskEntityDef`.
2026-06-28 10:19:40 +08:00
hyper ddde3f7597 feat(bt): Add entity-based task factories
Add `leaf`, `sequential`, `parallel`, `selector`, `random`, and `repeat`
functions that return `EntityDef` trees. Legacy object definitions are
still
accepted for backward compatibility. Non-task child entities are ignored
by
the runner, and `buildTree` now stores the root entity on
`TaskRunner.root`.
2026-06-28 10:15:38 +08:00
hypercross 5d125167cc refactor: make getRelatedTo return an iterator
Convert `getRelatedTo` from returning an array to returning an
`IterableIterator`. This improves memory efficiency by yielding
entities lazily instead of allocating a new array on every call.
2026-06-02 06:39:07 +08:00
hypercross 4182bc1578 feat(bt): support generator leaves and delta time
Introduce support for generator functions in leaf tasks, allowing
them to yield for multi-frame execution. The `TaskRunner` now accepts
a delta time (`dt`) parameter, which is passed through to leaf
handlers.

Additionally, a `Cancel` symbol is introduced to allow leaf tasks to
explicitly cancel their subtree via a thrown error.
2026-06-02 00:10:18 +08:00
hypercross ec8f668392 feat(bt): add declarative tree builder
Introduce `buildTree` to allow defining behaviour trees using a
declarative `TreeDef` object instead of manual entity spawning and
relationship wiring. This simplifies tree construction and manages
leaf handlers internally.
2026-06-01 23:57:19 +08:00
hypercross efa92be5ab feat(bt): implement subtree status clearing in TaskRunner
Introduce `clearSubtree` to recursively reset status for an entity and
all its descendants. This ensures that when a task reaches a terminal
state, its entire branch is properly reset.

Also refactor the Tetris example to use a sequential task node within
the behavior tree.
2026-06-01 23:24:43 +08:00
hypercross 3620e80807 feat(bt): add repeat and selector task kinds 2026-06-01 22:57:14 +08:00
hypercross 4e37e03d3f feat: add behavior tree implementation
Introduces a `TaskRunner` for executing behavior trees within the
ECS world. Supports leaf, sequential, parallel, and random task
kinds, along with status propagation (succeeded, failed, cancelled).
2026-06-01 22:52:10 +08:00