diff options
| author | HampusM <hampus@hampusmat.com> | 2026-05-21 17:55:20 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-05-21 17:55:20 +0200 |
| commit | 8022e8998290b067b8aa0cb9cba8ba410826bdab (patch) | |
| tree | 7171e79ce530e03079046ee8fd12167160c45480 /ecs/examples/component_relationship.rs | |
| parent | 412cee02c252f91bcf0b70a3f5cc5fca6d2b4c62 (diff) | |
chore: rename ecs* crates to engine-ecs*
Diffstat (limited to 'ecs/examples/component_relationship.rs')
| -rw-r--r-- | ecs/examples/component_relationship.rs | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/ecs/examples/component_relationship.rs b/ecs/examples/component_relationship.rs deleted file mode 100644 index e07b214..0000000 --- a/ecs/examples/component_relationship.rs +++ /dev/null @@ -1,65 +0,0 @@ -use ecs::pair::Pair; -use ecs::phase::START as START_PHASE; -use ecs::{Component, Query, World}; - -#[derive(Component)] -struct Person -{ - name: String, -} - -fn print_dog_likers(query: Query<(&Person, Pair<Likes, &Dogs>)>) -{ - for (person, liked_dogs) in &query { - println!( - "{} likes {} dogs!", - person.name, - if liked_dogs.large { "large" } else { "small" }, - ); - } -} - -#[derive(Component)] -struct Likes; - -#[derive(Component)] -struct Cats; - -#[derive(Component)] -struct Dogs -{ - large: bool, -} - -fn main() -{ - let mut world = World::new(); - - world.register_system(*START_PHASE, print_dog_likers); - - world.create_entity(( - Person { name: "Irving".to_string() }, - Pair::builder() - .relation::<Likes>() - .target_as_data(Dogs { large: true }) - .build(), - )); - - world.create_entity(( - Person { name: "Mark".to_string() }, - Pair::builder() - .relation::<Likes>() - .target_as_data(Cats) - .build(), - )); - - world.create_entity(( - Person { name: "Helena".to_string() }, - Pair::builder() - .relation::<Likes>() - .target_as_data(Dogs { large: false }) - .build(), - )); - - world.step(); -} |
