From 4b2dfb21bfa779eca5e4db1eb37fafa09efc9ca1 Mon Sep 17 00:00:00 2001 From: Seldom <38388947+Seldom-SE@users.noreply.github.com> Date: Tue, 9 Jul 2024 23:29:35 -0700 Subject: [PATCH] Rename `Trigger` to `EntityTrigger` in docs --- examples/chase.rs | 3 ++- src/machine.rs | 2 +- src/trigger.rs | 14 ++++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/chase.rs b/examples/chase.rs index 1243d8c..b376e92 100644 --- a/examples/chase.rs +++ b/examples/chase.rs @@ -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> { (move |In(entity): In, transforms: Query<&Transform>| { diff --git a/src/machine.rs b/src/machine.rs index f2a67f7..23fa8c9 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -33,7 +33,7 @@ trait Transition: Debug + Send + Sync + 'static { fn check(&mut self, world: &World, entity: Entity) -> Option<(Box, 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 diff --git a/src/trigger.rs b/src/trigger.rs index 09370c2..976060b 100644 --- a/src/trigger.rs +++ b/src/trigger.rs @@ -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; @@ -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 { @@ -96,8 +96,10 @@ impl TriggerOut for Result { } } -/// 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`]. @@ -106,10 +108,10 @@ impl TriggerOut for Result { /// 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: 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.