use bevy::prelude::*;
use super::value::TagParams;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Reflect, Default)]
pub enum TagSource {
#[default]
Extras,
Name,
Reflection,
}
#[derive(Clone, Debug, PartialEq, Reflect, Default)]
pub struct StageTag {
pub key: String,
pub params: TagParams,
pub source: TagSource,
}
impl StageTag {
pub fn new(key: impl Into<String>, source: TagSource) -> Self {
Self {
key: key.into(),
params: TagParams::new(),
source,
}
}
}
#[derive(Component, Clone, Debug, PartialEq, Reflect, Default)]
#[reflect(Component)]
pub struct StageTags {
pub tags: Vec<StageTag>,
pub extras: TagParams,
pub base_name: String,
pub name_params: TagParams,
}
impl StageTags {
pub fn is_empty(&self) -> bool {
self.tags.is_empty() && self.extras.is_empty() && self.name_params.is_empty()
}
pub fn tag(&self, key: &str) -> Option<&StageTag> {
self.tags.iter().find(|t| t.key == key)
}
}