| Crates.io | simplecs |
| lib.rs | simplecs |
| version | 0.1.2 |
| created_at | 2025-06-21 22:55:30.105218+00 |
| updated_at | 2025-06-22 19:06:10.404061+00 |
| description | A simple entity-component system, focusing on simplicity and ergonomics. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1721156 |
| size | 15,167 |
simplecs is a lightweight, zero-dependency Entity-Component System (ECS) for Rust.
It emphasizes simplicity, type-safety, and ergonomic querying.
With<T> / Without<T>ComponentStorageBuilderTypeId + Any internally for type-erased bucketsuse simplecs::*;
W
struct Position(f32, f32);
impl Component for Position {}
struct Velocity(f32, f32);
impl Component for Velocity {}
component_list!(Position, Velocity);
fn main() {
let mut storage = ComponentStorageBuilder::<u32>::new()
.with::<Position>()
.with::<Velocity>()
.build();
storage.add_component(1, Position(1.0, 2.0));
storage.add_component(1, Velocity(0.1, 0.1));
storage.add_component(2, Position(5.0, 5.0));
let moving = storage.query::<With<(Position, Velocity)>>();
assert_eq!(moving, vec![1]);
let static_entities = storage.query::<(With<Position>, Without<Velocity>)>();
assert_eq!(static_entities, vec![2]);
}
simplecs uses type-safe static dispatch to query entities:
With<T> – selects entities with components TWithout<T> – selects entities that lack T(With<A>, Without<B>) work tooDefine component groups with a macro:
component_list!(A, B, C, D, E, F);
Then use in queries:
let ids = storage.query::<(With<(Position, Velocity)>, Without<Health>)>();
Storage<E, T>dyn ComponentBucket<E>Copy + Eq + Hash type (e.g. u32)Licensed under either of:
For questions, ideas, or contributions, feel free to open an issue or PR.
Want to regenerate this README from your docs?
cargo install cargo-readme
cargo readme > README.md
License: MIT OR Apache-2.0