Skip to content

Commit

Permalink
Rename Trigger to EntityTrigger in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldom-SE committed Jul 10, 2024
1 parent c146109 commit 4b2dfb2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion examples/chase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ fn follow(
// For the sake of example, this is a function that returns the `near_player` trigger from before.
// This may be useful so that triggers that accept case-by-case values may be used across the
// codebase. Triggers that don't need to accept any values from local code may be defined as normal
// Bevy systems (see the `done` example). Also consider implementing the `Trigger` trait directly.
// Bevy systems (see the `done` example). Also consider implementing the `EntityTrigger` trait
// directly.
#[allow(dead_code)]
fn near(target: Entity) -> impl EntityTrigger<Out = Result<f32, f32>> {
(move |In(entity): In<Entity>, transforms: Query<&Transform>| {
Expand Down
2 changes: 1 addition & 1 deletion src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ trait Transition: Debug + Send + Sync + 'static {
fn check(&mut self, world: &World, entity: Entity) -> Option<(Box<dyn Insert>, TypeId)>;
}

/// An edge in the state machine. The type parameters are the [`Trigger`] that causes this
/// An edge in the state machine. The type parameters are the [`EntityTrigger`] that causes this
/// transition, the previous state, the function that takes the trigger's output and builds the next
/// state, and the next state itself.
struct TransitionImpl<Trig, Prev, Build, Next>
Expand Down
14 changes: 8 additions & 6 deletions src/trigger.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Triggers are checked to determine whether the machine should transition to a new state. They can
//! be combined with the `not`, `and`, and `or` combinators. See [`Trigger`].
//! be combined with the `not`, `and`, and `or` combinators. See [`EntityTrigger`].
#[cfg(feature = "leafwing_input")]
mod input;
Expand Down Expand Up @@ -30,7 +30,7 @@ pub(crate) fn plug(app: &mut App) {
);
}

/// Wrapper for [`core::convert::Infallible`]. Use for [`Trigger::Err`] if the trigger is
/// Wrapper for [`core::convert::Infallible`]. Use for [`EntityTrigger::Err`] if the trigger is
/// infallible.
#[derive(Debug, Deref, DerefMut, Clone, Copy, PartialEq, Eq)]
pub struct Never {
Expand Down Expand Up @@ -96,8 +96,10 @@ impl<Ok, Err> TriggerOut for Result<Ok, Err> {
}
}

/// Automatically implemented for types that implement [`Trigger`] and certain types that implement
/// [`IntoSystem`]. Types that implement [`IntoSystem`] don't automatically implement [`Trigger`],
/// Automatically implemented for types that implement [`EntityTrigger`] and certain types that
/// implement
/// [`IntoSystem`]. Types that implement [`IntoSystem`] don't automatically implement
/// [`EntityTrigger`],
/// so if you want to accept a trigger somewhere, you can accept a generic that implements this
/// trait instead. Otherwise, the caller will usually have to call `.into_trigger()` when providing
/// a type that implements [`IntoSystem`].
Expand All @@ -106,10 +108,10 @@ impl<Ok, Err> TriggerOut for Result<Ok, Err> {
/// from implementing the same instance of this trait multiple times, since a type may implement
/// multiple instances of [`IntoSystem`]. It doesn't matter what type `Marker` is set to.
pub trait IntoTrigger<Marker>: Sized {
/// The [`Trigger`] type that this is converted into
/// The [`EntityTrigger`] type that this is converted into
type Trigger: EntityTrigger;

/// Convert into a [`Trigger`]
/// Convert into an [`EntityTrigger`]
fn into_trigger(self) -> Self::Trigger;

/// Negates the trigger. Do not override.
Expand Down

0 comments on commit 4b2dfb2

Please sign in to comment.