Skip to content

Commit

Permalink
Clean up plugin-related code (#37)
Browse files Browse the repository at this point in the history
* Remove AbilityPlugin::server

Fixes #14

* Use a more helpful name for the run condition
  • Loading branch information
alice-i-cecile authored Aug 29, 2023
1 parent 3fd5b94 commit 4d5b5c6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
6 changes: 6 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release Notes

## Version 0.6

### Usability

- removed the useless `AbilityPlugin::server()` plugin creation method

## Version 0.5

- now supports Bevy 0.11
Expand Down
16 changes: 1 addition & 15 deletions src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,6 @@ impl<A: Abilitylike> Default for AbilityPlugin<A> {
}
}

impl<A: Abilitylike> AbilityPlugin<A> {
/// Creates a version of the plugin intended to run on the server
///
/// Inputs will not be processed; instead, [`ActionState`](crate::action_state::ActionState)
/// should be copied directly from the state provided by the client,
/// or constructed from [`ActionDiff`](crate::action_state::ActionDiff) event streams.
#[must_use]
pub fn server() -> Self {
Self {
_phantom: PhantomData,
}
}
}

impl<A: Abilitylike> Plugin for AbilityPlugin<A> {
fn build(&self, app: &mut App) {
use crate::systems::*;
Expand All @@ -74,7 +60,7 @@ impl<A: Abilitylike> Plugin for AbilityPlugin<A> {
app.add_systems(
PreUpdate,
tick_cooldowns::<A>
.run_if(run_if_enabled::<A>)
.run_if(actions_toggled::<A>)
.in_set(InputManagerSystem::Tick)
.before(InputManagerSystem::Update),
);
Expand Down
2 changes: 1 addition & 1 deletion src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ pub fn regenerate_resource_pool<P: Pool + Component + Resource>(
}

/// Returns [`ShouldRun::No`] if [`DisableInput`] exists and [`ShouldRun::Yes`] otherwise
pub(super) fn run_if_enabled<A: Abilitylike>(toggle_actions: Res<ToggleActions<A>>) -> bool {
pub(super) fn actions_toggled<A: Abilitylike>(toggle_actions: Res<ToggleActions<A>>) -> bool {
toggle_actions.enabled
}

0 comments on commit 4d5b5c6

Please sign in to comment.