Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TickActionStateSystem set to allow configuring tick_action_state individually #639

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/action_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub use action_data::*;
/// Actions can be disabled in four different ways, with increasing granularity:
///
/// 1. By disabling updates to all actions using a run condition on [`InputManagerSystem::Update`](crate::plugin::InputManagerSystem::Update).
/// 2. By disabling updates to all actions of type `A` using a run condition on [`tick_action_state::<A>`](crate::systems::tick_action_state).
/// 2. By disabling updates to all actions of type `A` using a run condition on [`TickActionStateSystem::<A>`](crate::plugin::TickActionStateSystem).
/// 3. By setting a specific action state to disabled using [`ActionState::disable`].
/// 4. By disabling a specific action using [`ActionState::disable_action`].
///
Expand Down
31 changes: 29 additions & 2 deletions src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ impl<A: Actionlike + TypePath + bevy::reflect::GetTypeRegistration> Plugin
// Main schedule
app.add_systems(
PreUpdate,
(tick_action_state::<A>, clear_central_input_store)
(
tick_action_state::<A>.in_set(TickActionStateSystem::<A>::new()),
clear_central_input_store,
)
.in_set(InputManagerSystem::Tick)
.before(InputManagerSystem::Update),
)
Expand Down Expand Up @@ -182,6 +185,7 @@ impl<A: Actionlike + TypePath + bevy::reflect::GetTypeRegistration> Plugin
app.add_systems(
FixedPostUpdate,
tick_action_state::<A>
.in_set(TickActionStateSystem::<A>::new())
.in_set(InputManagerSystem::Tick)
.before(InputManagerSystem::Update),
);
Expand All @@ -193,7 +197,9 @@ impl<A: Actionlike + TypePath + bevy::reflect::GetTypeRegistration> Plugin
Machine::Server => {
app.add_systems(
PreUpdate,
tick_action_state::<A>.in_set(InputManagerSystem::Tick),
tick_action_state::<A>
.in_set(TickActionStateSystem::<A>::new())
.in_set(InputManagerSystem::Tick),
);
}
};
Expand Down Expand Up @@ -284,6 +290,27 @@ pub enum InputManagerSystem {
ManualControl,
}

#[derive(SystemSet, Clone, Hash, Debug, PartialEq, Eq)]
/// [`SystemSet`] for the [`tick_action_state`](crate::systems::tick_action_state) system, is a child set of [`InputManagerSystem::Tick`].
pub struct TickActionStateSystem<A: Actionlike> {
phantom_data: PhantomData<A>,
}

impl<A: Actionlike> TickActionStateSystem<A> {
/// Creates a [`TickActionStateSystem`] set instance.
pub fn new() -> Self {
Self {
phantom_data: PhantomData,
}
}
}

impl<A: Actionlike> Default for TickActionStateSystem<A> {
fn default() -> Self {
Self::new()
}
}

/// A plugin to handle accumulating mouse movement and scroll events.
///
/// This is a clearer, more reliable and more efficient approach to computing the total mouse movement and scroll for the frame.
Expand Down