muds
is a minimalistic data structure library for data-oriented design in high-performance, realtime applications such as games. It provides a collections library with data structures that support generational indices as key, and an entity-component-system (ECS) library built on top of it.
no_std
and WASM build. Defaults to f64 generational indices for interop with JS from WASM.System
scheduler / dispatcher, muds
does not take control of your program flow. toml
[dependencies]
muds = "0.1"
Features:
- std
- enables std
support. enabled by default.
- serde
- enables serde
serialize/deserialize implementations of collections and indices
- derive
- enables #[derive(Entity)]
and #[derive(Component)]
macros
- index-u64
- uses IndexU64
as the generational index type for ECS instead of the default IndexF64
See Docs.rs: https://docs.rs/muds
Below is a sample usage of the ECS library. See benches for more examples.
```rust use muds::prelude::*; use muds::ecs::storage::SparseSetStorage;
// 1. Defines the entity and components.
struct Ent;
struct Pos(u32, u32);
// #[storage(S)]
can be used to customize the entity / component storage type.
struct Vel(u32, u32);
// 2. Registers the entity-components archetype to registry.
let mut registry = Registry::default();
registry.register_archetype:: // 3. Insert entities/components to mut storage.
// storage/storagemut returns cons of collection types.
// Each component storage can be retrieved either as immutable (&C) or mutable (&mut C).
{
let cons!(mut ent, mut pos, mut vel) = registry.storagemut:: // 4. Storages are just standard Map types that can be iterated.
// Use MapJoin trait to jointly iterate components as cons.
{
let cons!(ent, mut pos, vel) = registry.storage:: This repository and the code inside it is licensed under the MIT License. Read LICENSE for more information.License