Expand description
Provides utilities for stringly-typed data storage in bevy.
§Features
This crate includes:
- Key-value properties for entities and the world. See
props. - Unique entity names and classes. See
registry. - Arbitrary unidirectional links between entities. See
links.
fn setup(mut commands: Commands) {
let mut gandalf = commands.spawn_empty()
.set_name("gandalf")
.set_class("wizard")
.set_prop("likes_elves", true)
.id();
let mut bilbo = commands.spawn_empty()
.set_name("bilbo")
.set_class("hobbit")
.set_link("talking_to", gandalf)
.set_prop("has_ring", true)
.set_prop("wearing_ring", false)
.set_prop("health", 100.0)
.set_prop("wearing", "elven_cloak");
}
fn system(world: &mut World) -> Result {
let bilbo = world.entity_mut_named("bilbo")?;
if bilbo.get_prop::<Estr>("wearing") == "elven_cloak" {
if let Some(entity_talked_to) = bilbo.follow_link("talking_to")
&& entity_talked_to.get_prop("likes_elves")
{
// have the npc say something about bilbo's cloak here
}
}
Ok(())
}