Trait big_brain::scorers::ScorerBuilder[][src]

pub trait ScorerBuilder: Debug + Sync + Send {
    fn build(&self, cmd: &mut Commands<'_>, scorer: Entity, actor: Entity);

    fn attach(&self, cmd: &mut Commands<'_>, actor: Entity) -> Entity { ... }
}

Trait that must be defined by types in order to be ScorerBuilders. ScorerBuilders’ job is to spawn new Scorer entities. In general, most of this is already done for you, and the only method you really have to implement is .build().

The build() method MUST be implemented for any ScorerBuilders you want to define.

Required methods

fn build(&self, cmd: &mut Commands<'_>, scorer: Entity, actor: Entity)[src]

MUST insert your concrete Scorer component into the Scorer [Entity], using cmd. You may use actor, but it’s perfectly normal to just ignore it.

Example

struct MyBuilder;
struct MyScorer;

impl ScorerBuilder for MyBuilder {
    fn build(&self, cmd: &mut Commands, action: Entity, actor: Entity) {
        cmd.entity(action).insert(MyScorer);
    }
}
Loading content...

Provided methods

fn attach(&self, cmd: &mut Commands<'_>, actor: Entity) -> Entity[src]

Don’t implement this yourself unless you know what you’re doing.

Loading content...

Implementors

impl ScorerBuilder for AllOrNothingBuilder[src]

impl ScorerBuilder for FixedScoreBuilder[src]

impl ScorerBuilder for SumOfScorersBuilder[src]

Loading content...