schell / apecs

An asyncronous and pleasant entity-component system for Rust
46 stars 3 forks source link
app-engine ecs game-development game-engine rust

apecs

Async-friendly and Pleasant Entity Component System

apecs is an entity-component system written in Rust that can share world resources with futures run in any async runtime. This makes it great for general applications, quick game prototypes, DIY engines and any simulation that has discrete steps in time.

Why

Most ECS libraries (and game main-loops in general) are polling based. This is great for certain tasks, but things get complicated when programming in the time domain. Async / await is great for programming in the time domain without explicitly spawning new threads or blocking, but it isn't supported by ECS libraries.

apecs was designed to to be an ECS that plays nice with async / await.

What and How

At its core apecs is a library for sharing resources across disparate polling and async loops. It uses derivable traits and channels to orchestrate systems' access to resources and uses rayon (where available) for concurrency.

Goals

Features

Here is a quick table of features compared to other ECSs.

Feature apecs bevy_ecs hecs legion planck_ecs shipyard specs
storage archetypal hybrid archetypal archetypal separated sparse separated
system scheduling ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
early exit systems ✔️
parallel systems ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
change tracking ✔️ ✔️ kinda ✔️ ✔️
async support ✔️

Feature examples

Roadmap

Tests

cargo test
wasm-pack test --firefox crates/apecs

I like firefox, but you can use different browsers for the wasm tests. The tests make sure apecs works on wasm.

Benchmarks

The apecs benchmarks measure itself against my favorite ECS libs: specs, bevy, hecs, legion, shipyard and planck_ecs.

cargo bench -p benchmarks

Minimum supported Rust version 1.65

apecs uses generic associated types for its component iteration traits.