#ecs #entity #component #system #tiny

tiny_ecs

A tiny ECS that tries to avoid unnecessary copy/clones

32 releases

0.19.6 Jul 12, 2020
0.19.4 Oct 5, 2019
0.18.1 Jul 21, 2019

#415 in Data structures

Download history 3/week @ 2021-06-02 34/week @ 2021-06-09 4/week @ 2021-06-16 2/week @ 2021-06-23 6/week @ 2021-06-30 3/week @ 2021-07-07 35/week @ 2021-07-14 2/week @ 2021-07-21 69/week @ 2021-07-28 36/week @ 2021-08-04 34/week @ 2021-08-11 2/week @ 2021-08-18 1/week @ 2021-08-25 1/week @ 2021-09-01 3/week @ 2021-09-08 2/week @ 2021-09-15

162 downloads per month

MPL-2.0 license

28KB
316 lines

Build Status

Tiny ECS

The intention of this crate is that a basic ECS is provided, where you will be required to exercise a little additional control.

Where most other ECS crates provide a mechanism for inserting "systems" in to the ECS to run against entities, this one leaves it out - you can think of it as a "system for entity/components". You will need to create external systems; these can be a function, a loop, or anything else.

Internally this ECS is the use of bitmasks. Each entity ID is in practice an internal index number in to an array which contains bitmasks. The bitmasks themselves keep track of what components the entity has.

Note: borrows of items are checked at runtime, but there are also some unchecked borrows provided.

Memory use

The ECS is backed by Persist-O-Vec which is a storage that aims to have fast push, pop, insert, and remove while also keeping stable indexes and memory locations. Because of the way this works, and the fact that not every slot in the storage will be used the memory-to-use ratio can be high.

The use of Persist-O-Vec means that each component will use an additional 24 bytes, this includes 24 bytes per empty slot also.

For each component type there will be allocated an Persist store equal to the expected maximum entity count. Slots in that storage remain allocated in memory throughout the life of the storage, but may or may not actually contain data.

Benchmarks

Based on the ecs_bench project.

Alternatives

If you're looking for something a bit more robust, just as fast, and cutting edge then one of the following may better better for you:

License

MPL v2

Dependencies

~540KB
~11K SLoC