From 008696e2c36c12ea59fc9c1f3aad8fd896a10a1f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kat=20March=C3=A1n?= <kzm@zkat.tech>
Date: Tue, 13 Apr 2021 11:59:14 -0700
Subject: [PATCH] stop bothering with the indirection;

---
 README.md          |  3 +--
 examples/thirst.rs |  1 -
 src/thinker.rs     | 15 ++++-----------
 3 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/README.md b/README.md
index 90b5ab2..2b0e6dd 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 0f3b5d7..f24fe48 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 e00918b..45df9aa 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();
-- 
GitLab