Ralith / hecs

A handy ECS
Apache License 2.0
924 stars 81 forks source link

Cloning World? #297

Closed Siccity closed 1 year ago

Siccity commented 1 year ago

Hello!

For my project i need to implement determinism with rollback, so I'll need to store copies of the world state potentially several times at every game tick. From what I can tell, hecs::World does not implement Clone. Is there something else I can do?

I am fairly new to Rust. I tried a local patch of hecs, adding #[derive(Clone)] to World and all its variables. Eventually I ended up rubbing against AtomicUsize and simply put it didn't work out.

Is there a fork or something I can use?

The world doesn't consist of a ton of items but it will be run at up to 60 times per frame on weak hardware, so performance is top priority.

Siccity commented 1 year ago

I realized copying the world may not be the best approach after all. Instead, I went with an approach that implements ring buffers inside the components. This way I don't have to copy the world at all.