15 releases
Uses new Rust 2024
new 0.3.0-alpha.1 | Apr 10, 2025 |
---|---|
0.2.0 | Mar 3, 2025 |
0.2.0-beta.2 | Nov 2, 2024 |
0.1.0-alpha.5 | Jul 9, 2024 |
0.1.0-alpha.1 | Nov 30, 2023 |
#589 in Game dev
54 downloads per month
Used in 6 crates
(2 directly)
48KB
988 lines
Magma-ECS
Magma-ECS is the Entity-component-system for the Magma3D engine.
Features
- Simple and Lightweight
- Update function for systems
Allow for easy execution of the systems
- Parallel
All code is automatically parallelized
Disclaimer
This is still in developement and not production ready.
lib.rs
:
This crate provides the Entity-Component-System of the Magma3D-Engine.
The crate provides a World
struct with Resources
and Entities
.
An entity is just an index into the component storage.
A resource is like a global component, independent of the Entities
.
Usage Example
use magma_ecs::World;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut world = World::new();
// Register component types.
world.register_component::<Name>();
world.register_component::<Health>();
world.register_component::<Npc>();
// Add a resource.
world.add_resource(String::from("This is an example resource!"))?;
// create a couple of entities with registered components
for _ in 0..10 {
world.create_entity((Name("Enemy".to_owned()), Health(20), Npc::Enemy))?;
}
Ok(())
}
// Components can be any type that implements `Send + Sync` (or just any if you disable the `multithreading` feature).
struct Name(String);
struct Health(u32);
enum Npc {
Ally,
Enemy,
}
Dependencies
~1–6.5MB
~39K SLoC