Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: opt-out of bar creation using InhibitBar #36

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ use crate::material::BarMaterial;
use crate::mesh::MeshHandles;
use crate::prelude::{BarOrientation, BarSettings, ColorScheme};

#[derive(Component, Reflect, Default)]
pub struct InhibitBar<T: Percentage + Component>(#[reflect(ignore)] PhantomData<T>);

pub struct HealthBarPlugin<T: Percentage + Component + TypePath> {
phantom: PhantomData<T>,
}
Expand Down Expand Up @@ -38,6 +41,7 @@ impl<T: Percentage + Component + TypePath> Plugin for HealthBarPlugin<T> {
app.init_resource::<MeshHandles>()
.init_resource::<ColorScheme<T>>()
.register_type::<BarSettings<T>>()
.register_type::<InhibitBar<T>>()
.add_systems(PostUpdate, reset_rotation)
.add_systems(
Update,
Expand All @@ -62,7 +66,7 @@ fn spawn<T: Percentage + Component + TypePath>(
mut meshes: ResMut<Assets<Mesh>>,
mut mesh_handles: ResMut<MeshHandles>,
color_scheme: Res<ColorScheme<T>>,
query: Query<(Entity, &T, &BarSettings<T>), Added<T>>,
query: Query<(Entity, &T, &BarSettings<T>), (Added<T>, Without<InhibitBar<T>>)>,
) {
query.iter().for_each(|(entity, percentage, settings)| {
let width = settings.normalized_width();
Expand Down
Loading