An experimental, status effects-as-entities system for Bevy.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Added UI to decaying speed example.

+32 -9
-4
Cargo.lock
··· 2778 2778 [[package]] 2779 2779 name = "immediate_stats" 2780 2780 version = "0.3.1" 2781 - source = "registry+https://github.com/rust-lang/crates.io-index" 2782 - checksum = "482b7c9edba946e8c05d113f65486d49b9ed6c811b1fcfef6ae74ffceb74a198" 2783 2781 dependencies = [ 2784 2782 "bevy_app", 2785 2783 "bevy_auto_plugin", ··· 2791 2789 [[package]] 2792 2790 name = "immediate_stats_macros" 2793 2791 version = "0.3.1" 2794 - source = "registry+https://github.com/rust-lang/crates.io-index" 2795 - checksum = "83e6b22ee0ec8640bdb21c4da3b820530b1b185603eb0259dedb0be1681713b2" 2796 2792 dependencies = [ 2797 2793 "darling 0.23.0", 2798 2794 "proc-macro-error",
+3 -1
Cargo.toml
··· 28 28 29 29 [dev-dependencies] 30 30 bevy = "0.17" 31 - immediate_stats = { version = "0.3", features = ["bevy_auto_plugin"] } 31 + immediate_stats = { path = "../immediate_stats/immediate_stats", features = [ 32 + "bevy_auto_plugin", 33 + ] } 32 34 bevy_auto_plugin = { version = "0.8" } 33 35 34 36 [lints.rust]
+27 -3
examples/immediate_stats/decaying_speed.rs
··· 16 16 .add_plugins(ResetComponentPlugin::<MovementSpeed>::new()) 17 17 .add_systems(Startup, init_scene) 18 18 .add_systems(Update, (on_space_pressed, apply_speed_boost)) 19 + .add_systems(PostUpdate, update_ui) 19 20 .run(); 20 21 } 21 22 ··· 32 33 /// Spawn a target on startup. 33 34 fn init_scene(mut commands: Commands) { 34 35 commands.spawn((Name::new("Target"), MovementSpeed(Stat::new(100)))); 36 + commands.spawn(Text::default()); 37 + commands.spawn(Camera2d); 35 38 } 36 39 37 40 /// When space is pressed, apply decaying speed to the target. ··· 44 47 return; 45 48 } 46 49 47 - info!("Applying Effect"); 48 50 commands.entity(*target).with_effect(EffectBundle { 49 51 mode: EffectMode::Insert, // Block having multiple of effect stacked on a single target. 50 52 lifetime: Some(Lifetime::from_seconds(2.0)), // The duration of the effect. 51 53 bundle: DecayingSpeed { 52 54 // Start with double move speed. 53 - start_speed_boost: Modifier::from_multiplier(2.0), 55 + start_speed_boost: Modifier { 56 + bonus: 20, 57 + multiplier: 2.0, 58 + }, 54 59 }, 55 60 ..default() 56 61 }); ··· 72 77 effect.start_speed_boost, 73 78 lifetime.timer.fraction_remaining(), 74 79 ); 80 + } 81 + } 75 82 76 - info!("The target now has {} movement speed.", speed.0.total()); 83 + fn update_ui( 84 + mut ui: Single<&mut Text>, 85 + target: Single<&MovementSpeed>, 86 + effects: Query<(Entity, &Lifetime, &DecayingSpeed)>, 87 + ) { 88 + ui.0 = "Press Space to apply decaying movement speed\n\n".to_string(); 89 + 90 + ui.0 += &format!("Speed: {:.1} ({:.1})\n\n", target.0.total(), target.0); 91 + 92 + for (entity, lifetime, speed) in &effects { 93 + ui.0 += &format!( 94 + "{} - {:.1}s ({:.1})\n", 95 + entity, 96 + lifetime.timer.remaining_secs(), 97 + speed 98 + .start_speed_boost 99 + .scaled(lifetime.timer.fraction_remaining()) 100 + ); 77 101 } 78 102 }
+2 -1
examples/poison.rs
··· 10 10 App::new() 11 11 .add_plugins((DefaultPlugins, AlchemyPlugin)) 12 12 .add_systems(Startup, init_scene) 13 - .add_systems(Update, (on_space_pressed, deal_poison_damage, update_ui)) 13 + .add_systems(Update, (on_space_pressed, deal_poison_damage)) 14 + .add_systems(PostUpdate, update_ui) 14 15 .run(); 15 16 } 16 17