diff --git a/README.md b/README.md index 90b5ab24246a6ea3572f8c8442e6d92caf8fb584..2b0e6dd1e46ac5f9a2e92f130458cd6a5b13258b 100644 --- a/README.md +++ b/README.md @@ -111,8 +111,7 @@ regular Component: cmd.spawn().insert(Thirst::new(70.0, 2.0)).insert( Thinker::build() .picker(FirstToScore { threshold: 80.0 }) - .when(Thirsty::build(), Drink::build()) - .component(), + .when(Thirsty::build(), Drink::build()), ); ``` diff --git a/examples/thirst.rs b/examples/thirst.rs index 0f3b5d792a4789dd17913c212e62fc2b34936572..f24fe48c229b0416404dcd05906536b109754ede 100644 --- a/examples/thirst.rs +++ b/examples/thirst.rs @@ -157,7 +157,6 @@ pub fn init_entities(mut cmd: Commands) { .picker(FirstToScore { threshold: 80.0 }) // Note that what we pass in are _builders_, not components! .when(Thirsty::build(), Drink::build()) - .component(), ); } diff --git a/src/thinker.rs b/src/thinker.rs index e00918bcd0e70e6d52908381ed675cb599f2e5b1..45df9aa2f4f11d696283ffc4afd7ca33fc7f4a4e 100644 --- a/src/thinker.rs +++ b/src/thinker.rs @@ -70,10 +70,6 @@ impl ThinkerBuilder { self.otherwise = Some(ActionBuilderWrapper::new(Arc::new(otherwise))); self } - - pub fn component(self) -> ThinkerComponent { - ThinkerComponent(self) - } } impl ActionBuilder for ThinkerBuilder { @@ -100,15 +96,12 @@ impl ActionBuilder for ThinkerBuilder { } } -#[derive(Debug)] -pub struct ThinkerComponent(ThinkerBuilder); - pub fn thinker_component_attach_system( mut cmd: Commands, - q: Query<(Entity, &ThinkerComponent), Without<HasThinker>>, + q: Query<(Entity, &ThinkerBuilder), Without<HasThinker>>, ) { - for (entity, thinker_comp) in q.iter() { - let thinker = thinker_comp.0.attach(&mut cmd, entity); + for (entity, thinker_builder) in q.iter() { + let thinker = thinker_builder.attach(&mut cmd, entity); cmd.entity(entity) .insert(HasThinker(thinker)) .push_children(&[thinker]); @@ -117,7 +110,7 @@ pub fn thinker_component_attach_system( pub fn thinker_component_detach_system( mut cmd: Commands, - q: Query<(Entity, &HasThinker), Without<ThinkerComponent>>, + q: Query<(Entity, &HasThinker), Without<ThinkerBuilder>>, ) { for (actor, HasThinker(thinker)) in q.iter() { cmd.entity(*thinker).despawn_recursive();