-
I have two systems that need to create a certain type of entity, which includes a fixed set of components. Currently, my implementation is as follows: pub fn s1(c1: Command) {
c1.spawn((DrawObject::new(), Background::new()))
}
pub fn s2(c2: Command) {
c2.spawn((DrawObject::new(), Text::new()))
} However, the apply function of these two systems can only be executed sequentially, and they cannot be parallelized with other systems. I think the following approach should solve this problem: pub fn s1(c1: EntityCreator<(DrawObject, Background)>) {
c1.spawn((DrawObject::new(), Background::new()))
}
pub fn s2(c2: EntityCreator<(DrawObject, Text)>) {
c2.spawn((DrawObject::new(), Text::new()))
} In theory, the write operations of c1 and c2 to the world do not conflict with each other. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Is there a reason you aren't using bundles here? Also, whats the reason they have to be sequential? If they are both spawned in the same frame then order shouldn't really matter since those changes don't take effect until the |
Beta Was this translation helpful? Give feedback.
-
AFAIK this is unfortunately not true:
|
Beta Was this translation helpful? Give feedback.
That's much easier than done IMO, since currently this is inherently a very sequential operation. It requires:
Vec
for the new entity (may require a resize)Vec
for the new entity (may also require a resize, also for reserved entities this is the empty archetype)All of these operations are not easy to make thread-safe. Moreover there's a lot of code that relies on accessing these
Vec
s to be as fast and cheap as possible, so any form of synchronization may be unwante…