Skip to content
Snippets Groups Projects
Commit 6c64df4f authored by Kat Marchán's avatar Kat Marchán
Browse files

feat(api): rename attach and hide it from docs

parent 8bed75b5
No related branches found
No related tags found
No related merge requests found
......@@ -87,10 +87,9 @@ pub trait ActionBuilder: std::fmt::Debug + Send + Sync {
*/
fn build(&self, cmd: &mut Commands, action: Entity, actor: Entity);
/**
Don't implement this yourself unless you know what you're doing.
*/
fn attach(&self, cmd: &mut Commands, actor: Entity) -> Entity {
#[doc(hidden)]
// Don't implement this yourself unless you know what you're doing.
fn spawn_action(&self, cmd: &mut Commands, actor: Entity) -> Entity {
let action_ent = ActionEnt(cmd.spawn().id());
cmd.entity(action_ent.0)
.insert(Name::new("Action"))
......@@ -131,7 +130,7 @@ impl StepsBuilder {
impl ActionBuilder for StepsBuilder {
fn build(&self, cmd: &mut Commands, action: Entity, actor: Entity) {
if let Some(step) = self.steps.get(0) {
let child_action = step.attach(cmd, actor);
let child_action = step.spawn_action(cmd, actor);
cmd.entity(action)
.insert(Name::new("Steps Action"))
.insert(Steps {
......@@ -223,7 +222,7 @@ pub fn steps_system(
steps_action.active_step += 1;
let step_builder = steps_action.steps[steps_action.active_step].clone();
let step_ent = step_builder.attach(&mut cmd, *actor);
let step_ent = step_builder.spawn_action(&mut cmd, *actor);
cmd.entity(seq_ent).push_children(&[step_ent]);
steps_action.active_ent.0 = step_ent;
}
......@@ -268,7 +267,7 @@ impl ActionBuilder for ConcurrentlyBuilder {
let children: Vec<Entity> = self
.actions
.iter()
.map(|action| action.attach(cmd, actor))
.map(|action| action.spawn_action(cmd, actor))
.collect();
cmd.entity(action)
.insert(Name::new("Concurrent Action"))
......
......@@ -37,7 +37,7 @@ impl ChoiceBuilder {
}
pub fn build(&self, cmd: &mut Commands, actor: Entity, parent: Entity) -> Choice {
let scorer_ent = self.when.attach(cmd, actor);
let scorer_ent = self.when.spawn_scorer(cmd, actor);
cmd.entity(parent).push_children(&[scorer_ent]);
Choice {
scorer: ScorerEnt(scorer_ent),
......
......@@ -63,10 +63,9 @@ pub trait ScorerBuilder: std::fmt::Debug + Sync + Send {
*/
fn build(&self, cmd: &mut Commands, scorer: Entity, actor: Entity);
/**
Don't implement this yourself unless you know what you're doing.
*/
fn attach(&self, cmd: &mut Commands, actor: Entity) -> Entity {
// Don't implement this yourself unless you know what you're doing.
#[doc(hidden)]
fn spawn_scorer(&self, cmd: &mut Commands, actor: Entity) -> Entity {
let scorer_ent = cmd.spawn().id();
cmd.entity(scorer_ent)
.insert(Name::new("Scorer"))
......@@ -186,7 +185,7 @@ impl ScorerBuilder for AllOrNothingBuilder {
let scorers: Vec<_> = self
.scorers
.iter()
.map(|scorer| scorer.attach(cmd, actor))
.map(|scorer| scorer.spawn_scorer(cmd, actor))
.collect();
cmd.entity(scorer)
.insert(Score::default())
......@@ -269,7 +268,7 @@ impl ScorerBuilder for SumOfScorersBuilder {
let scorers: Vec<_> = self
.scorers
.iter()
.map(|scorer| scorer.attach(cmd, actor))
.map(|scorer| scorer.spawn_scorer(cmd, actor))
.collect();
cmd.entity(scorer)
.insert(Transform::default())
......@@ -360,7 +359,7 @@ impl ScorerBuilder for WinningScorerBuilder {
let scorers: Vec<_> = self
.scorers
.iter()
.map(|scorer| scorer.attach(cmd, actor))
.map(|scorer| scorer.spawn_scorer(cmd, actor))
.collect();
cmd.entity(scorer)
.insert(Transform::default())
......@@ -431,7 +430,7 @@ pub struct EvaluatingScorerBuilder {
impl ScorerBuilder for EvaluatingScorerBuilder {
fn build(&self, cmd: &mut Commands, scorer: Entity, actor: Entity) {
let inner_scorer = self.scorer.attach(cmd, actor);
let inner_scorer = self.scorer.spawn_scorer(cmd, actor);
cmd.entity(scorer)
.insert(Transform::default())
.insert(GlobalTransform::default())
......
......@@ -144,7 +144,7 @@ pub fn thinker_component_attach_system(
q: Query<(Entity, &ThinkerBuilder), Without<HasThinker>>,
) {
for (entity, thinker_builder) in q.iter() {
let thinker = thinker_builder.attach(&mut cmd, entity);
let thinker = thinker_builder.spawn_action(&mut cmd, entity);
cmd.entity(entity).insert(HasThinker(thinker));
}
}
......@@ -305,7 +305,7 @@ fn exec_picked_action(
// Despawn the action itself.
cmd.entity(action_ent.0).despawn_recursive();
thinker.current_action = Some((
ActionEnt(picked_action.1.attach(cmd, actor)),
ActionEnt(picked_action.1.spawn_action(cmd, actor)),
picked_action.clone(),
));
}
......@@ -326,7 +326,7 @@ fn exec_picked_action(
// current_action in the thinker. The logic here is pretty
// straightforward -- we set the action, Request it, and
// that's it.
let new_action = picked_action.1.attach(cmd, actor);
let new_action = picked_action.1.spawn_action(cmd, actor);
thinker.current_action = Some((ActionEnt(new_action), picked_action.clone()));
}
}
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