use std::any::{
Any,
TypeId,
};
use bevy::prelude::*;
#[derive(Resource, Default)]
pub struct CheckpointRegistry {
types: SceneFilter,
}
impl CheckpointRegistry {
pub fn allow_all(&mut self) {
self.types = SceneFilter::allow_all();
}
pub fn deny_all(&mut self) {
self.types = SceneFilter::deny_all();
}
pub fn allow<T: Any>(&mut self) {
self.types = std::mem::take(&mut self.types).allow::<T>();
}
pub fn allow_id(&mut self, type_id: TypeId) {
self.types = std::mem::take(&mut self.types).allow_by_id(type_id);
}
pub fn deny<T: Any>(&mut self) {
self.types = std::mem::take(&mut self.types).deny::<T>();
}
pub fn deny_id(&mut self, type_id: TypeId) {
self.types = std::mem::take(&mut self.types).deny_by_id(type_id);
}
pub fn is_allowed<T: Any>(&self) -> bool {
self.types.is_allowed::<T>()
}
pub fn is_allowed_by_id(&self, type_id: TypeId) -> bool {
self.types.is_allowed_by_id(type_id)
}
pub fn is_denied<T: Any>(&self) -> bool {
self.types.is_denied::<T>()
}
pub fn is_denied_by_id(&self, type_id: TypeId) -> bool {
self.types.is_denied_by_id(type_id)
}
}