Game stats that reset every frame, inspired by immediate mode GUI.
gamedev bevy stats
0
fork

Configure Feed

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

Auto propagate for any types that *contain* "Stat".

+13 -3
+2 -2
immediate_stats/src/lib.rs
··· 99 99 /// } 100 100 /// ``` 101 101 /// # Configuration 102 - /// By default, it will consider any value of type `Stat` to be a sub-stat. 103 - /// You can use `#[stat]` to add a sub-stat and `#[stat_ignore]` to ignore one. 102 + /// By default, it will consider any field whose type contains "Stat" to be a sub-stat. 103 + /// You can use `#[stat]` to add other sub-stats and `#[stat_ignore]` to ignore one. 104 104 /// ```rust 105 105 /// # use immediate_stats::*; 106 106 /// # #[derive(StatContainer, Default, Debug, PartialEq)]
+10
immediate_stats/tests/derive.rs
··· 2 2 3 3 use immediate_stats::*; 4 4 5 + #[derive(PartialEq, Debug)] 6 + struct MyStat; 7 + 8 + impl StatContainer for MyStat { 9 + fn reset_modifiers(&mut self) {} 10 + } 11 + 5 12 #[derive(StatContainer, PartialEq, Debug)] 6 13 struct Movement { 7 14 speed: Stat, 15 + custom: MyStat, 8 16 other: bool, 9 17 } 10 18 ··· 17 25 bonus: 3, 18 26 multiplier: 1.5, 19 27 }, 28 + custom: MyStat, 20 29 other: true, 21 30 }; 22 31 ··· 26 35 movement, 27 36 Movement { 28 37 speed: Stat::new(base), 38 + custom: MyStat, 29 39 other: true 30 40 } 31 41 );
+1 -1
immediate_stats_macros/src/lib.rs
··· 143 143 let mut is_stat = false; 144 144 145 145 // Check if type is `Stat`. 146 - if field.ty.to_token_stream().to_string() == "Stat" { 146 + if field.ty.to_token_stream().to_string().contains("Stat") { 147 147 is_stat = true; 148 148 } 149 149