![]() ![]() ![]() Apply Artificial Intelligence to IT (AIOps).Here is an extremely simplified example: use parking_lot::Mutex įor position in (). This is Rust's way of telling you that you need to perform appropriate locking if you share data between threads. If you put each data store inside a synchronization primitive, then you can access the individual data stores through a shared reference. Let's say you have an ECS with the following components: Position, Velocity and KeyboardInput. Things like captures for example mess me up terribly, because if I dare capture the ecs object I can never again use it until whatever owns the capture is destroyed. How do I make a data structure whose entire purpose is to handle the lifetime and access of a myriad of objects used everywhere in my program, but never having more than one mutable reference? I have been hitting myself against the wall for days. You cannot in any way have multiple mutable references to one object. It's very ergonomic for an event system to store a mutable reference to the ecs and update the components of certain entities when necessary.Īll of this is in direct opposition with the tyrannical expectations of the borrow checker. Many functions must have mutable access to it, and it might even be convenient for objects to store mutable references to the ECS, for example. The ecs by necessity must be accessed multiple times through the program. The ability to iterate over entities based on the components (e.g.The ability to add components to entities. ![]() I don't understand how to make a safe ECS system in rust, the borrow checker doesn't let me do anything.Īssume we have made an ECS system, we need primarily 3 things: I have spent literal days fighting something that in C++ took me minutes and I am a little frustrated. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |