diff --git a/README.md b/README.md index 006c114a4c8f702ce48c0cada2a4289d9c89311a..b50ad4ec5a9612f421b19db30a27fdcebf19d8a8 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ First, you define actions and considerations, which are just plain old `Bevy` ```rust use bevy::prelude::*; -use big_brain::*; +use big_brain::prelude::*; #[derive(Debug, Clone)] pub struct Thirsty; @@ -59,7 +59,7 @@ pub fn thirsty_scorer_system( ```rust use bevy::prelude::*; -use big_brain::*; +use big_brain::prelude::*; #[derive(Debug, Clone)] pub struct Drink; diff --git a/examples/thirst.rs b/examples/thirst.rs index f24fe48c229b0416404dcd05906536b109754ede..6225cadc81ce5956fb1e51c7def9d673b5638957 100644 --- a/examples/thirst.rs +++ b/examples/thirst.rs @@ -1,5 +1,5 @@ use bevy::prelude::*; -use big_brain::*; +use big_brain::prelude::*; // First, we define a "Thirst" component and associated system. This is NOT // THE AI. It's a plain old system that just makes an entity "thirstier" over @@ -156,7 +156,7 @@ pub fn init_entities(mut cmd: Commands) { Thinker::build() .picker(FirstToScore { threshold: 80.0 }) // Note that what we pass in are _builders_, not components! - .when(Thirsty::build(), Drink::build()) + .when(Thirsty::build(), Drink::build()), ); } diff --git a/src/actions.rs b/src/actions.rs index 849752f7a149b192593d4198bae815e6198fdbbf..e2093a584af86dab2bf280e1a472845993bbe276 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use bevy::prelude::*; -use crate::{ActionEnt, Actor}; +use crate::thinker::{ActionEnt, Actor}; #[derive(Debug, Clone, Eq, PartialEq)] pub enum ActionState { diff --git a/src/lib.rs b/src/lib.rs index d184f7a6bfdcc75264fceac0b981e12e2f2fbb59..4893c46b53af000f7672695b839f8a5260d71b5e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,18 +1,20 @@ -pub use bevy; +pub mod evaluators; +pub mod pickers; -pub use actions::*; -pub use choices::*; -pub use scorers::*; -pub use thinker::*; -pub use pickers::*; +pub mod actions; +pub mod choices; +pub mod scorers; +pub mod thinker; -pub mod evaluators; -mod pickers; +pub mod prelude { + use super::*; -mod actions; -mod choices; -mod scorers; -mod thinker; + pub use super::BigBrainPlugin; + pub use actions::{ActionBuilder, ActionState}; + pub use pickers::{FirstToScore, Picker}; + pub use scorers::{AllOrNothing, FixedScore, Score, ScorerBuilder, SumOfScorers}; + pub use thinker::{Actor, Thinker}; +} use bevy::prelude::*; @@ -20,12 +22,12 @@ pub struct BigBrainPlugin; impl Plugin for BigBrainPlugin { fn build(&self, app: &mut AppBuilder) { - app.add_system(thinker_system.system()); - app.add_system(thinker_component_attach_system.system()); - app.add_system(thinker_component_detach_system.system()); - app.add_system(steps_system.system()); - app.add_system(fixed_score_system.system()); - app.add_system(all_or_nothing_system.system()); - app.add_system(sum_of_scorers_system.system()); + app.add_system(thinker::thinker_system.system()); + app.add_system(thinker::thinker_component_attach_system.system()); + app.add_system(thinker::thinker_component_detach_system.system()); + app.add_system(actions::steps_system.system()); + app.add_system(scorers::fixed_score_system.system()); + app.add_system(scorers::all_or_nothing_system.system()); + app.add_system(scorers::sum_of_scorers_system.system()); } } diff --git a/src/scorers.rs b/src/scorers.rs index 4ed43106601963c5199d3c52cd81417e9fb933e6..5bdc42446f8b822801c6732de63956ffe1f68cab 100644 --- a/src/scorers.rs +++ b/src/scorers.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use bevy::prelude::*; -use crate::{Actor, ScorerEnt}; +use crate::thinker::{Actor, ScorerEnt}; #[derive(Debug, Clone, Default)] pub struct Score(pub(crate) f32); @@ -116,7 +116,7 @@ impl ScorerBuilder for AllOrNothingBuilder { cmd.entity(scorer) .insert(Score::default()) .push_children(&scorers[..]) - .insert(super::AllOrNothing { + .insert(AllOrNothing { threshold: self.threshold, scorers: scorers.into_iter().map(ScorerEnt).collect(), });