Expand description
Simple entity-component system. Pure Rust (macro-free)!
§Example
extern crate recs;
use recs::{Ecs, EntityId};
#[derive(Clone, PartialEq)]
struct Age{years: u32}
#[derive(Clone, PartialEq)]
struct Brain{iq: i32}
fn main() {
// Create an ECS instance
let mut ecs: Ecs = Ecs::new();
// Add entity to the system
let me: EntityId = ecs.create_entity();
// Attach component to the entity
ecs.set(me, &Age{years: 22});
// Get attached component data from entity
let older = ecs.get::<Age>(me).unwrap().years + 1;
// Modify an entity's component
ecs.set(me, &Age{years: older});
// It works!
assert!(ecs.get::<Age>(me) == Some(Age{years: 23}));
assert!(ecs.get::<Brain>(me) == None); // Aw man...
}Structs§
- Iterator that yields references to ECS components.
- Iterator that yields mutable references to ECS components.
- Primary data structure containing entity and component data.
- Iterator for entity IDs.
Type Aliases§
- Value type representing an entry in the entity-component system.