//! Behavior trait kernels: the trait definitions, their dispatch runners, and the shared
//! dyn-clone machinery. Concrete behaviors live in `weapons/` and `pools/`; entities
//! (Enemy, Tower, GroundPool, Projectile) live in their own modules.

pub mod damage;
pub mod enemy;
pub mod pool;
pub mod projectile;
pub mod status;
pub mod tower;

/// Generates the dyn-clone dance for an object-safe behavior trait: a `$clone` supertrait
/// carrying `clone_box`, a blanket impl for every `Clone` behavior, and the
/// `Clone for Box<dyn $behavior>` glue that makes `Vec<Box<dyn $behavior>>` cloneable.
///
/// `Clone` can't be a supertrait of an object-safe trait (it returns `Self`), so each
/// behavior family routes cloning through a boxed `clone_box` instead. This replaces four
/// hand-copied versions of the same pattern.
macro_rules! dyn_clone_trait {
    ($clone:ident, $behavior:ident) => {
        pub trait $clone {
            fn clone_box(&self) -> Box<dyn $behavior>;
        }
        impl<T: $behavior + Clone + 'static> $clone for T {
            fn clone_box(&self) -> Box<dyn $behavior> {
                Box::new(self.clone())
            }
        }
        impl Clone for Box<dyn $behavior> {
            fn clone(&self) -> Self {
                self.clone_box()
            }
        }
    };
}
pub(crate) use dyn_clone_trait;
