Commit Graph

8 Commits

Author SHA1 Message Date
hypercross 968672da06 fix(blackjack): update payout function signature 2026-06-02 18:08:01 +08:00
hypercross a97488e8d6 refactor(examples): reorganized code
Move code to avoid big main.ts and changed the bt to match the pattern
2026-06-02 10:39:27 +08:00
hypercross 2469cdc7cb feat(examples): add blackjack game example 2026-06-02 00:57:22 +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 ccd0e3afb4 feat(world): add singleton component support
Introduce a mechanism to manage components on a shared, lazily-created
singleton entity. This simplifies access to global state by providing
dedicated methods for adding, removing, getting, and checking for
singleton components.

Refactor the Tetris example to utilize this new singleton pattern for
game state components like Board, Score, and Piece.
2026-06-01 23:52:47 +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 c3c24d2350 feat(examples): add Tetris game example 2026-06-01 23:18:07 +08:00