Struct hecs_hierarchy::DeferredTreeBuilder
source ·
[−]pub struct DeferredTreeBuilder<T> { /* fields omitted */ }
Expand description
Ergonomically construct trees without knowledge of world.
This struct builds the world using EntityBuilderClone
Example
use hecs_hierarchy::*;
use hecs::*;
struct Tree;
let mut world = World::default();
let mut builder = DeferredTreeBuilder::<Tree>::from_bundle(("root",));
builder.attach_bundle(("child 1",));
builder.attach({
let mut builder = DeferredTreeBuilder::new();
builder.add("child 2");
builder
});
let root = builder.build(&mut world);
assert_eq!(*world.get::<&'static str>(root).unwrap(), "root");
for (a, b) in world
.descendants_depth_first::<Tree>(root)
.zip(["child 1", "child 2"])
{
assert_eq!(*world.get::<&str>(a).unwrap(), b)
}
Implementations
Add a component to the root
Add a bundle to the root
Atttach a new subtree
Attach a new leaf as an entity builder
Attach a new leaf as a bundle
Get a reference to the deferred tree builder’s builder.
Get a reference to the deferred tree builder’s children.
Trait Implementations
Performs the conversion.
Auto Trait Implementations
impl<T> RefUnwindSafe for DeferredTreeBuilder<T> where
T: RefUnwindSafe,
impl<T> Send for DeferredTreeBuilder<T> where
T: Send,
impl<T> Sync for DeferredTreeBuilder<T> where
T: Sync,
impl<T> Unpin for DeferredTreeBuilder<T> where
T: Unpin,
impl<T> UnwindSafe for DeferredTreeBuilder<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more