···11-//! A very simple example using Bevy Butler. Requires the `bevy_butler` feature flag, which is *depreciated*.
22-//!
33-//! **Please see the Bevy Auto Plugin example instead.**
44-55-use bevy::prelude::*;
66-use bevy_butler::*;
77-use immediate_stats::*;
88-99-fn main() {
1010- App::new()
1111- .add_plugins((MinimalPlugins, ImmediateStatsPlugin, SpeedPlugin))
1212- .run();
1313-}
1414-1515-#[butler_plugin]
1616-struct SpeedPlugin;
1717-1818-// Implements `reset_modifiers` by passing the call onto `Stat`.
1919-// This will also add the `ResetComponentPlugin` to `SpeedPlugin`.
2020-#[derive(StatContainer, Component)]
2121-#[add_component(plugin = SpeedPlugin)]
2222-struct Speed(Stat);
2323-2424-#[add_system(plugin = SpeedPlugin, schedule = Startup)]
2525-fn init_speed(mut commands: Commands) {
2626- commands.spawn(Speed(Stat::new(10))); // Set base speed to 10.
2727-}
2828-2929-#[add_system(plugin = SpeedPlugin, schedule = Update, in_set = StatSystems::Modify)]
3030-fn apply_modifiers(mut speeds: Query<&mut Speed>) {
3131- for mut speed in &mut speeds {
3232- speed.0 *= 2.0; // Applies a multiplier to the final result.
3333- speed.0 += 5; // Adds a bonus to the final result.
3434- // The order does not matter, bonuses are always applied before multipliers.
3535- }
3636-}
3737-3838-#[add_system(plugin = SpeedPlugin, schedule = Update, in_set = StatSystems::Read)]
3939-fn read_speed(speeds: Query<&Speed>) {
4040- for speed in &speeds {
4141- println!("The current speed is {}.", speed.0.total());
4242- assert_eq!(speed.0.total(), 30); // (10 + 5) * 2 = 30
4343- }
4444-}