nya-ecs 0.2.0

nya entity component system
Documentation
//! Small simple ECS
//!
//! An [Entity Component System](https://en.wikipedia.org/wiki/Entity_component_system) is a
//! pattern in which entities are composed of simple data components and "systems" that manipulate said components.
//!
//! A system can be a function called every frame that manipulates a specific entity,
//! a query of entities with a certain set of components or whatever.

pub(crate) use std::any::{Any, TypeId};

/// Entity ID
pub type Entity = usize;

pub mod component;
pub use component::{Component, ComponentKey};

mod world;
pub use world::World;

pub mod query;
pub use query::{Exclude, Filter, Query, Queryable};

pub mod system;
pub use system::{QuerySystem, System, SystemManager};

#[cfg(test)]
mod tests {
    use super::*;

    struct Tag;
    crate::component!(Tag);
    #[allow(dead_code)]
    struct Name(String);
    crate::component!(Name);
    #[allow(dead_code)]
    struct Point(i32, i32);
    crate::component!(Point);

    #[test]
    fn stress() {
        let mut world = World::new();

        for i in 0..10000 {
            let entity = world.spawn();
            world.add(entity, Tag);
            world.add(entity, Point(i, 65));
            world.add(entity, Name("Cronus".to_string()));
        }

        assert!(world.has::<Tag>(3));
    }
}