diff --git a/src/actions.rs b/src/actions.rs index c799eb12ee92d25212a13ebd61bd3236574551d0..2dd5f82804fc4870db8b260ce4f958255fa1b303 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -92,8 +92,7 @@ pub trait ActionBuilder: std::fmt::Debug + Send + Sync { fn attach(&self, cmd: &mut Commands, actor: Entity) -> Entity { let action_ent = ActionEnt(cmd.spawn().id()); cmd.entity(action_ent.0) - .insert(Transform::default()) - .insert(GlobalTransform::default()) + .insert(Name::new("Action")) .insert(ActionState::new()) .insert(Actor(actor)); self.build(cmd, action_ent.0, actor); @@ -121,16 +120,17 @@ impl StepsBuilder { impl ActionBuilder for StepsBuilder { fn build(&self, cmd: &mut Commands, action: Entity, actor: Entity) { - let child_action = self.steps[0].attach(cmd, actor); - cmd.entity(action) - .insert(Transform::default()) - .insert(GlobalTransform::default()) - .insert(Steps { - active_step: 0, - active_ent: ActionEnt(child_action), - steps: self.steps.clone(), - }) - .push_children(&[child_action]); + if let Some(step) = self.steps.get(0) { + let child_action = step.attach(cmd, actor); + cmd.entity(action) + .insert(Name::new("Steps Action")) + .insert(Steps { + active_step: 0, + active_ent: ActionEnt(child_action), + steps: self.steps.clone(), + }) + .push_children(&[child_action]); + } } } diff --git a/src/lib.rs b/src/lib.rs index 3d64358bd243bdacc46ee01820168a4708306a39..17e7c3f614cbcedd2aad0f7201670a04364ac12e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -163,7 +163,7 @@ pub mod prelude { use super::*; pub use super::BigBrainPlugin; - pub use actions::{ActionBuilder, ActionState}; + pub use actions::{ActionBuilder, ActionState, Steps}; pub use pickers::{FirstToScore, Picker}; pub use scorers::{AllOrNothing, FixedScore, Score, ScorerBuilder, SumOfScorers}; pub use thinker::{Actor, Thinker, ThinkerBuilder}; diff --git a/src/scorers.rs b/src/scorers.rs index 3993ec969c28219ecd7fc10dfc5f39beadb3142b..ba098f80dfb7cc4f7aaae3a4c1b11909b5c72364 100644 --- a/src/scorers.rs +++ b/src/scorers.rs @@ -66,8 +66,7 @@ pub trait ScorerBuilder: std::fmt::Debug + Sync + Send { fn attach(&self, cmd: &mut Commands, actor: Entity) -> Entity { let scorer_ent = cmd.spawn().id(); cmd.entity(scorer_ent) - .insert(Transform::default()) - .insert(GlobalTransform::default()) + .insert(Name::new("Scorer")) .insert(Score::default()) .insert(Actor(actor)); self.build(cmd, scorer_ent, actor); @@ -178,10 +177,9 @@ impl ScorerBuilder for AllOrNothingBuilder { .map(|scorer| scorer.attach(cmd, actor)) .collect(); cmd.entity(scorer) - .insert(Transform::default()) - .insert(GlobalTransform::default()) .insert(Score::default()) .push_children(&scorers[..]) + .insert(Name::new("Scorer")) .insert(AllOrNothing { threshold: self.threshold, scorers: scorers.into_iter().map(ScorerEnt).collect(), diff --git a/src/thinker.rs b/src/thinker.rs index 68faa4baf17edb2b80a7bf97f193246efb4de167..b60286b4e6de32149821efc701ea67b05edcb7cd 100644 --- a/src/thinker.rs +++ b/src/thinker.rs @@ -124,8 +124,6 @@ impl ActionBuilder for ThinkerBuilder { .map(|choice| choice.build(cmd, actor, action_ent)) .collect(); cmd.entity(action_ent) - .insert(Transform::default()) - .insert(GlobalTransform::default()) .insert(Thinker { // TODO: reasonable default?... picker: self @@ -136,6 +134,7 @@ impl ActionBuilder for ThinkerBuilder { otherwise: self.otherwise.clone(), current_action: None, }) + .insert(Name::new("Thinker")) .insert(ActiveThinker(false)) .insert(ActionState::Requested); }