···5151### Bevy Auto Plugin
52525353If you use [Bevy Auto Plugin](https://github.com/strikeforcezero/bevy_auto_plugin/), you can also use the `bevy_auto_plugin` feature flag.
5454-This automatically registers the required system(s) by leveraging the existing `auto_component` and `auto_resource` macros.
5454+This adds build hooks that automatically add the reset plugin.
55555656```rust
5757fn main() {
···6262#[auto_plugin(impl_plugin_trait)]
6363struct MyPlugin;
64646565-// `StatContainer` derive hooks into the existing `auto_component` and `auto_resource` macros.
6666-#[derive(StatContainer, Component, Resource)]
6767-#[auto_component(plugin = MyPlugin)] // Adds `reset_component_modifiers` system.
6868-#[auto_init_resource(plugin = MyPlugin)] // Adds `reset_resource_modifiers` system.
6565+#[derive(StatContainer, Component)]
6666+// Use hook to add the `ResetComponentPlugin` to `MyPlugin` automatically.
6767+#[auto_plugin_build_hook(plugin = MyPlugin, hook = ResetComponentHook)]
6968struct Speed(Stat);
7069```
7171-7272-It is important to note that this only works when the `derive` is above the `auto_*` macro,
7373-and does *not* work with `auto_bind_plugin`.
74707571### Version Compatibility
7672| Bevy | Immediate Stats |
7773|--------|-----------------|
7874| `0.18` | `0.4` |
7975| `0.17` | `0.3` |
8080-| `0.16` | `0.1` - `0.2` |7676+| `0.16` | `0.1` - `0.2` |
+7-31
immediate_stats/src/lib.rs
···5050//!
5151//! ### Bevy Auto Plugin
5252//!
5353-//! If you use [Bevy Auto Plugin](https://github.com/strikeforcezero/bevy_auto_plugin/),
5454-//! you can also use the `bevy_auto_plugin` feature flag. This automatically registers the required
5555-//! system(s) by leveraging the existing `auto_component` and `auto_resource` macros.
5353+//! If you use [Bevy Auto Plugin](https://github.com/strikeforcezero/bevy_auto_plugin/), you can also use the `bevy_auto_plugin` feature flag.
5454+//! This adds build hooks that automatically add the reset plugin.
5655//!
5756#![cfg_attr(not(feature = "bevy_auto_plugin"), doc = "```rust ignore")]
5857#![cfg_attr(feature = "bevy_auto_plugin", doc = "```rust")]
5958//! # use bevy_app::prelude::*;
6059//! # use bevy_ecs::prelude::*;
6160//! # use immediate_stats::*;
6262-//! # use bevy_auto_plugin::prelude::{AutoPlugin, auto_component, auto_resource};
6161+//! # use bevy_auto_plugin::prelude::{AutoPlugin, auto_plugin_build_hook, auto_resource};
6262+//!
6363//! fn main() {
6464//! App::new().add_plugins((ImmediateStatsPlugin, MyPlugin)).run();
6565//! }
···6868//! #[auto_plugin(impl_plugin_trait)]
6969//! struct MyPlugin;
7070//!
7171-//! // `StatContainer` derive hooks into the existing `auto_component` and `auto_resource` macros.
7272-//! #[derive(StatContainer, Component, Resource)]
7373-//! #[auto_component(plugin = MyPlugin)] // Adds `reset_component_modifiers` system.
7474-//! #[auto_resource(plugin = MyPlugin)] // Adds `reset_resource_modifiers` system.
7171+//! #[derive(StatContainer, Component)]
7272+//! // Use hook to add the `ResetComponentPlugin` to `MyPlugin` automatically.
7373+//! #[auto_plugin_build_hook(plugin = MyPlugin, hook = ResetComponentHook)]
7574//! struct Speed(Stat);
7675//! ```
7777-//!
7878-//! It is important to note that this only works when the `derive` is above the `auto_*` macro,
7979-//! and does *not* work with `auto_bind_plugin`.
8076//!
8177//! ### Version Compatibility
8278//! | Bevy | Immediate Stats |
···143139/// assert_eq!(partial.custom, Health::default());
144140/// assert_eq!(partial.ignored, Stat::default().with_bonus(10));
145141/// }
146146-/// ```
147147-/// # Bevy Auto Plugin
148148-/// If the `bevy_auto_plugin` feature flag is enabled, the existing `auto_component` and
149149-/// `auto_resource` macros will register [`reset_component_modifiers`] and/or
150150-/// [`reset_resource_modifiers`] automatically.
151151-#[cfg_attr(not(feature = "bevy_auto_plugin"), doc = "```rust ignore")]
152152-#[cfg_attr(feature = "bevy_auto_plugin", doc = "```rust")]
153153-/// # use bevy_app::prelude::*;
154154-/// # use bevy_ecs::prelude::*;
155155-/// # use immediate_stats::*;
156156-/// # use bevy_auto_plugin::prelude::{AutoPlugin, auto_component, auto_resource};
157157-/// #[derive(AutoPlugin)]
158158-/// #[auto_plugin(impl_plugin_trait)]
159159-/// struct MyPlugin;
160160-///
161161-/// // `StatContainer` derive hooks into the existing `auto_component` and `auto_resource` macros.
162162-/// #[derive(StatContainer, Component, Resource)]
163163-/// #[auto_component(plugin = MyPlugin)] // Adds `reset_component_modifiers` system.
164164-/// #[auto_resource(plugin = MyPlugin)] // Adds `reset_resource_modifiers` system.
165165-/// struct Speed(Stat);
166142/// ```
167143pub use immediate_stats_macros::StatContainer;
168144pub use modifier::*;
+1-1
immediate_stats/tests/bevy_auto_plugin.rs
···11-//! Tests the `add_component` attribute for automatic system registration.
11+//! Tests the `ResetComponentHook` and `ResetResourceHook`.
22#![cfg(feature = "bevy_auto_plugin")]
3344extern crate immediate_stats;