1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! # XECS
//! xecs is a rust Entity-Component-System library
//! # Details
//! XECS is a Grouped ECS library.
//! # Examples
//! ### Create an empty world
//! ```no_run
//! # use xecs::World;
//! let mut world = World::new();
//! ```
//! ### Register some components
//! Component is T : Send + Sync + 'static
//! ```no_run
//! struct Position(f64,f64,f64);
//! struct Particle;
//! world.register::<Position>();
//! world.register::<Particle>();
//! ```
//! ### Create 100 entity with Position and Particle components
//! ```no_run
//! for _ in 0..100 {
//!     world
//!         .create_entity()
//!         .attach(Position(1.0,2.0,1.2))
//!         .attach(Particle);
//! }
//!
//! ```
//! ### Make a full-owning group to improve the performance of query iteration
//! ```no_run
//! world.make_group::<(Particle,Position)>(true,true);
//! ```
//! ### Create a system and update all entities with position and particle components
//! ```no_run
//! # use xecs::{System, World};
//! # use std::cell::RefMut;
//! # use std::convert::Infallible;
//! struct UpdatePosition;
//! impl<'a> System<'a> for UpdatePosition {
//!     type InitResource = ();
//!     type Resource = (&'a mut World);
//!     type Dependencies = ();
//!     type Error = Infallible;
//!
//!
//!     fn update(&'a mut self, world : RefMut<'a,World>) -> Result<(),Self::Error> {
//!         for (pos,_tag) in world.query::<(&mut Position,&Particle)>() {
//!             pos.0 += 1.1;
//!             pos.1 += 1.2;
//!             pos.3 += 1.4;
//!         }
//!         Ok(())
//!     }
//! }
//! ```
//! ### Add system to stage and run this stage
//! ```no_run
//! # use xecs::Stage;
//! let mut stage = Stage::from_world(world);
//! stage.add_system(UpdatePosition);
//! stage.run();
//! ```

pub mod world;
pub mod entity;
pub mod components;
pub mod group;
pub mod query;
pub mod sparse_set;
pub mod system;
pub mod stage;
pub mod resource;

pub use entity::{ EntityId,Entities };
pub use world::World;
pub use components::Component;
pub use system::{System,Errors,End};
pub use stage::Stage;