Repository navigation
Is component arrays getting resized mid-process intentional? #104
|
Currently I'm working on a project and I have 3 components added (doesn't actually matter how many as far as I can see) on let's say 200 entities. When I add one more component to one of these entities the components array numbers get broken up immediately but the entities in the array don't change. Shortest example is: the above code is just to demonstrate this.
there is a workaround for this that I've whipped up which is to just put both the entities and the new components in two arrays then loop over the "to be added" components at the end of the frame. Though this doesn't seem intentional to me. Also, one last thing, if I query for C_Targets and some entities only have C_Targets and others have C_Targets and C_IsAllied, they get processed on different frames. Is this intentional? Is there any way to force them to get processed on the same frame? |
Replies: 1 comment 1 reply
|
Check out the command buffer for this. Essentially modifying entities mid cycle can cause archetype changes. So instead you should add modifications to the command buffer so that you can choose when they execute and your modifications will be loop safe. |
Check out the command buffer for this. Essentially modifying entities mid cycle can cause archetype changes. So instead you should add modifications to the command buffer so that you can choose when they execute and your modifications will be loop safe.