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

feat(builders): Blanket impls for ActionBuilder and ScorerBuilder when Clone

This will make a lot of simpler actions and scorers much less boilerplatey
parent 65ca646e
No related branches found
No related tags found
No related merge requests found
......@@ -101,6 +101,15 @@ pub trait ActionBuilder: std::fmt::Debug + Send + Sync {
}
}
impl<T> ActionBuilder for T
where
T: Component + Clone + std::fmt::Debug + Send + Sync,
{
fn build(&self, cmd: &mut Commands, action: Entity, _actor: Entity) {
cmd.entity(action).insert(T::clone(self));
}
}
/**
[`ActionBuilder`] for the [`Steps`] component. Constructed through `Steps::build()`.
*/
......
......@@ -77,6 +77,15 @@ pub trait ScorerBuilder: std::fmt::Debug + Sync + Send {
}
}
impl<T> ScorerBuilder for T
where
T: Component + Clone + std::fmt::Debug + Send + Sync,
{
fn build(&self, cmd: &mut Commands, action: Entity, _actor: Entity) {
cmd.entity(action).insert(T::clone(self));
}
}
/**
Scorer that always returns the same, fixed score. Good for combining with things creatively!
*/
......
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