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.

Add Auto Plugin hooks.

+34
+6
immediate_stats/src/bevy.rs
··· 1 1 #![cfg(feature = "bevy")] 2 2 //! Contains systems and components for resetting [`StatContainer`]s in the Bevy game engine. 3 3 4 + #[cfg(feature = "bevy_auto_plugin")] 5 + mod auto_plugin; 6 + 4 7 use crate::StatContainer; 5 8 use crate::modifier::Modifier; 6 9 use crate::stat::Stat; ··· 11 14 use bevy_reflect::Reflect; 12 15 use bevy_reflect::prelude::ReflectDefault; 13 16 use std::marker::PhantomData; 17 + 18 + #[cfg(feature = "bevy_auto_plugin")] 19 + pub use auto_plugin::*; 14 20 15 21 /// Configures [system ordering](StatSystems) and registers types with the Bevy type registry. 16 22 ///
+28
immediate_stats/src/bevy/auto_plugin.rs
··· 1 + #![cfg(feature = "bevy_auto_plugin")] 2 + //! Contains a hook for resetting [`StatContainer`]s using Bevy Auto Plugin. 3 + 4 + use crate::{ResetComponentPlugin, ResetResourcePlugin, StatContainer}; 5 + use bevy_app::App; 6 + use bevy_auto_plugin::prelude::AutoPluginBuildHook; 7 + use bevy_ecs::component::Mutable; 8 + use bevy_ecs::prelude::{Component, Resource}; 9 + 10 + /// A Bevy Auto Plugin hook that adds the [`ResetComponentPlugin`] for the component. 11 + pub struct ResetComponentHook; 12 + 13 + impl<T: Component<Mutability = Mutable> + StatContainer + 'static> AutoPluginBuildHook<T> 14 + for ResetComponentHook 15 + { 16 + fn on_build(&self, app: &mut App) { 17 + app.add_plugins(ResetComponentPlugin::<T>::new()); 18 + } 19 + } 20 + 21 + /// A Bevy Auto Plugin hook that adds the [`ResetResourcePlugin`] for the resource. 22 + pub struct ResetResourceHook; 23 + 24 + impl<T: Resource + StatContainer + 'static> AutoPluginBuildHook<T> for ResetResourceHook { 25 + fn on_build(&self, app: &mut App) { 26 + app.add_plugins(ResetResourcePlugin::<T>::new()); 27 + } 28 + }