Skip to content

Commit

Permalink
rename App/World observe to add_observer, and EntityWorldMut observe_…
Browse files Browse the repository at this point in the history
…entity to observe
  • Loading branch information
ItsDoot committed Oct 8, 2024
1 parent 0837ade commit 6561fcf
Show file tree
Hide file tree
Showing 15 changed files with 141 additions and 86 deletions.
6 changes: 3 additions & 3 deletions benches/benches/bevy_ecs/observers/propagation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ fn add_listeners_to_hierarchy<const DENSITY: usize, const N: usize>(
world: &mut World,
) {
for e in roots.iter() {
world.entity_mut(*e).observe_entity(empty_listener::<N>);
world.entity_mut(*e).observe(empty_listener::<N>);
}
for e in leaves.iter() {
world.entity_mut(*e).observe_entity(empty_listener::<N>);
world.entity_mut(*e).observe(empty_listener::<N>);
}
let mut rng = deterministic_rand();
for e in nodes.iter() {
if rng.gen_bool(DENSITY as f64 / 100.0) {
world.entity_mut(*e).observe_entity(empty_listener::<N>);
world.entity_mut(*e).observe(empty_listener::<N>);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions benches/benches/bevy_ecs/observers/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn observe_simple(criterion: &mut Criterion) {

group.bench_function("trigger_simple", |bencher| {
let mut world = World::new();
world.observe(empty_listener_base);
world.add_observer(empty_listener_base);
bencher.iter(|| {
for _ in 0..10000 {
world.trigger(EventBase)
Expand All @@ -29,7 +29,7 @@ pub fn observe_simple(criterion: &mut Criterion) {
let mut world = World::new();
let mut entities = vec![];
for _ in 0..10000 {
entities.push(world.spawn_empty().observe_entity(empty_listener_base).id());
entities.push(world.spawn_empty().observe(empty_listener_base).id());
}
entities.shuffle(&mut deterministic_rand());
bencher.iter(|| {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1275,11 +1275,11 @@ impl App {
/// }
/// });
/// ```
pub fn observe<E: Event, B: Bundle, M>(
pub fn add_observer<E: Event, B: Bundle, M>(
&mut self,
observer: impl IntoObserverSystem<E, B, M>,
) -> &mut Self {
self.world_mut().observe(observer);
self.world_mut().add_observer(observer);
self
}
}
Expand Down
Loading

0 comments on commit 6561fcf

Please sign in to comment.