bevy_yoetz::prelude

Trait YoetzSuggestion

source
pub trait YoetzSuggestion:
    'static
    + Sized
    + Send
    + Sync {
    type Key: 'static + Send + Sync + Clone + PartialEq;
    type OmniQuery: QueryData;

    // Required methods
    fn key(&self) -> Self::Key;
    fn remove_components(key: &Self::Key, cmd: &mut EntityCommands<'_>);
    fn add_components(self, cmd: &mut EntityCommands<'_>);
    fn update_into_components(
        self,
        components: &mut <Self::OmniQuery as WorldQuery>::Item<'_>,
    ) -> Result<(), Self>;
}
Expand description

An action suggestion for the AI agent to consider.

Avoid implementing this trait manually - prefer using the YoetzSuggestion derive macro.

enums that implement this trait are mainly used as the generic parameter for YoetzAdvisor and as the data passed to it. A YoetzPlugin parametrized on them should also be added to the Bevy application.

Required Associated Types§

source

type Key: 'static + Send + Sync + Clone + PartialEq

The key identifies a suggestion even when its data changes. The YoetzSuggestion derive macro generates a key that is a “subset” of the enum - it contains all the variants, but each variant only contains the fields marked as #[yoetz(key)].

source

type OmniQuery: QueryData

A query that allows access to all possible behavior components.

The query generated by the YoetzSuggestion derive macro is unsightly and there it never a reason to use it manually.

Required Methods§

source

fn key(&self) -> Self::Key

Generate a Key that identifies the suggestion.

source

fn remove_components(key: &Self::Key, cmd: &mut EntityCommands<'_>)

Remove the behavior components that were created by a suggestion with the specified key.

source

fn add_components(self, cmd: &mut EntityCommands<'_>)

Add behavior components created from the suggestion.

source

fn update_into_components( self, components: &mut <Self::OmniQuery as WorldQuery>::Item<'_>, ) -> Result<(), Self>

Update the existing behavior components from the suggestion’s data.

The method generated by the YoetzSuggestion derive macro will only update the fields marked with #[yoetz(input)]. Fields marked with #[yoetz(state)] will not be updated because the action systems are allowed to store their own state there (or just maintain the initial state from when the behavior was chosen), and fields marked with #[yoetz(key)] will not be updated because when they change the Key changes and the components themselves will be re-inserted rather than updated.

Object Safety§

This trait is not object safe.

Implementors§