use bevy_ecs::prelude::*;
use serde::Deserialize;
use serde::Serialize;
use std::fmt::Debug;
#[derive(Default, Debug, Copy, Clone, Component, PartialEq)]
#[component(storage = "SparseSet")]
pub struct Running;
#[derive(
Default, Debug, Clone, Copy, Component, PartialEq, Serialize, Deserialize,
)]
#[component(storage = "SparseSet")]
pub enum RunResult {
#[default]
Success,
Failure,
}
pub fn sync_running(
mut commands: Commands,
first_pass: Query<Entity, (Added<RunResult>, With<Running>)>,
second_pass: Query<Entity, (With<RunResult>, Without<Running>)>,
) {
for entity in first_pass.iter() {
commands.entity(entity).remove::<Running>();
}
for entity in second_pass.iter() {
commands.entity(entity).remove::<RunResult>();
}
}