Skip to content
Snippets Groups Projects
Unverified Commit 64f38ce8 authored by Kat Marchán's avatar Kat Marchán
Browse files

name things and fix steps

parent 06cc03e1
No related branches found
No related tags found
No related merge requests found
......@@ -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]);
}
}
}
......
......@@ -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};
......
......@@ -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(),
......
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment