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_removed_event.rs | |
| parent | 412cee02c252f91bcf0b70a3f5cc5fca6d2b4c62 (diff) | |
chore: rename ecs* crates to engine-ecs*
Diffstat (limited to 'ecs/examples/component_removed_event.rs')
| -rw-r--r-- | ecs/examples/component_removed_event.rs | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/ecs/examples/component_removed_event.rs b/ecs/examples/component_removed_event.rs deleted file mode 100644 index 9b73b1a..0000000 --- a/ecs/examples/component_removed_event.rs +++ /dev/null @@ -1,46 +0,0 @@ -use ecs::actions::Actions; -use ecs::component::Component; -use ecs::event::component::{EventMatchExt, Removed}; -use ecs::pair::Pair; -use ecs::phase::UPDATE; -use ecs::system::observer::Observe; -use ecs::{Component, Query, World}; - -#[derive(Debug, Component)] -struct Cheese -{ - name: &'static str, -} - -fn eat_cheese(query: Query<(&Cheese,)>, mut actions: Actions) -{ - for (cheese_ent_id, (_,)) in query.iter_with_euids() { - println!("Eating cheese!"); - - actions.remove_components(cheese_ent_id, [Cheese::id()]); - } -} - -fn on_cheese_removed(observe: Observe<Pair<Removed, Cheese>>) -{ - for evt_match in &observe { - let cheese = evt_match.get_ent_target_comp(); - - println!("{} cheese was eaten", cheese.name); - } -} - -fn main() -{ - let mut world = World::new(); - - world.register_system(*UPDATE, eat_cheese); - world.register_observer(on_cheese_removed); - - world.create_entity((Cheese { name: "Brie" },)); - world.create_entity((Cheese { name: "Parmesan" },)); - world.create_entity((Cheese { name: "Gouda" },)); - - world.step(); - world.step(); -} |
