i-cant-believe-its-not-bsn

Crates.ioi-cant-believe-its-not-bsn
lib.rsi-cant-believe-its-not-bsn
version
sourcesrc
created_at2024-10-06 18:56:23.415329
updated_at2024-12-18 00:59:30.284624
descriptionTools for spawning entity hierarchies in Bevy
homepage
repositoryhttps://github.com/Leafwing-Studios/i-cant-believe-its-not-bsn
max_upload_size
id1399287
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Alice Cecile (alice-i-cecile)

documentation

README

i-cant-believe-its-not-bsn

Ergonomic ways to spawn Bevy entity hierarchies.

Eagerly waiting for BSN? Really wish you could spawn hierarchies with less boilerplate? Just want to define some reusable widget types for bevy_ui in code?

This crate is here to help!

Helper Components

You can use the helper component WithChild, and its iterator sibling, WithChildren, to embed hierarchy information in normal bundles.

Just add it as a component holding the bundle you want to use to spawn the child, and you're off to the races. A component hook will see that this component has been added, extract the data from your WithChild component, and then move it into a child, cleaning itself up as it goes.

These helper components are extremely useful when you just want to insert a tree of entities declaratively.

The Template Macro

Alternatively you can use the template!() macro, which is very similar to the proposed bsn syntax. Arbitrary data can be passed into the macro using normal rust blocks. The macro returns portable Template values, which can be spliced into other templates using @{ ... }.

Not only is the macro declarative and composable, it also supports basic incrementalization (doing partial updates to the ecs rather than rebuilding from scratch). Building the same macro multiple times with commands.build(template) does only the work necessary to bring the ecs into alignment with the template.

Commit count: 47

cargo fmt