47 releases

0.7.6 Nov 11, 2023
0.7.4 Apr 10, 2023
0.7.1 Dec 21, 2022
0.7.0 Oct 29, 2022
0.3.3 Jul 28, 2021

#170 in Simulation

Download history 6/week @ 2023-08-05 45/week @ 2023-08-12 45/week @ 2023-08-26 3/week @ 2023-09-02 116/week @ 2023-09-09 1/week @ 2023-09-16 2/week @ 2023-09-23 7/week @ 2023-09-30 1/week @ 2023-10-14 5/week @ 2023-10-21 80/week @ 2023-10-28 7/week @ 2023-11-04 25/week @ 2023-11-11 6/week @ 2023-11-18

120 downloads per month

MIT/Apache

110KB
2.5K SLoC

rs-ecs

crates.io docs.rs github.com

A reasonably simple entity component system (ECS) developed for use in the simulation models of project group EcoEpi at the Helmholtz Centre for Environmental Research. The design is based on hecs but has a significantly reduced API surface.

It also has a few changes and additions specific to our use case:

  • Its borrow checking is not thread-safe. Single-threaded simulations are often preferable as their execution is trivially deterministic. Additionally, running multiple instances of these in parallel often gives the highest throughput.
  • It supports amortised random access to query results by entity identifier using the QueryRef::map method. This can be useful to efficiently traverse graph-like relations between entities.
  • Entities can be transferred between worlds without serialisation using the World::transfer method. We use this to completely remove entities from the simulation while keeping their full dynamic state around for later inspection.
  • Worlds can be snapshotted to enable e.g. rollback netcode. Due to the lack of specialization on stable Rust, this requires a Cloner to collect clone and copy methods for all component types.
  • The World::exchange method combines removing some and then adding other components for a given entity. This can be used to optimise type-level state machines.
  • While queries must be dispatched from a single thread, their results can be iterated using multiple threads via the QueryRef::par_iter method. The method is optional, implemented using Rayon and enabled by the rayon Cargo feature.

License

Licensed under

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~235KB