Destroy Entity #244
Replies: 4 comments 5 replies
-
There is no way of destroying entities currently, and the app needs to cache for reuse. The issue is that destroying an entity would involve introducing a internal cache of deleted entities. What happens when we then want to allow concurrent creation/deletion of entities? (I.e through systems) It will basically introduce contention as we will always have to lock and check the cache entity. While typing this I realize an atomic can be used as a precheck before any actual lock is used during creation (destroying would always need a lock). I can take a stab at it when I have time. Hopefully later today |
Beta Was this translation helpful? Give feedback.
-
Regarding discussion vs issue: I have no preference unless it is regarding bugs which definitely should be issues |
Beta Was this translation helpful? Give feedback.
-
I made 2451cba which implements the basics. I can't exposed this function to Storage.Subset (and it can't be used by systems) as we dont know on compile time which components will exist on the entity. Therefore the scheduler can not make any safe assumptions about when you are allowed to destroy the entity. See this issue for a bit more details #246 |
Beta Was this translation helpful? Give feedback.
-
A less than optimal workaround for missing Storage.Subset support would be to add some tag component to mark the entity for deletion in the system (and potentially remove components if desired), then you can query for the tag and delete entities on the main thread |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Do I understand correctly, that in order to "destroy" and entity, I simply unset all its components? This will not reduce the numbers of entities, since this is simply a counter, but with 4 billion there should be enough. Would an API to
unsetAllComponents
make sense?My specific use case is map generation. When the parameter for the map size is decreased, the number of tiles and associated entities will be reduced.
Also, I am not sure when to file an issue or start a discussion. Might not matter too much anyways :D
Beta Was this translation helpful? Give feedback.
All reactions