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.
enum
s 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§
sourcetype Key: 'static + Send + Sync + Clone + PartialEq
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)]
.
sourcetype OmniQuery: QueryData
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§
sourcefn remove_components(key: &Self::Key, cmd: &mut EntityCommands<'_>)
fn remove_components(key: &Self::Key, cmd: &mut EntityCommands<'_>)
Remove the behavior components that were created by a suggestion with the specified key.
sourcefn add_components(self, cmd: &mut EntityCommands<'_>)
fn add_components(self, cmd: &mut EntityCommands<'_>)
Add behavior components created from the suggestion.
sourcefn update_into_components(
self,
components: &mut <Self::OmniQuery as WorldQuery>::Item<'_>,
) -> Result<(), Self>
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.