Closed wangsihao87 closed 4 years ago
I recommend marking an entity which you want to destory as ‘isDestroy’ = true instead of calling Entity.Destroy() immediately while ExecuteSystem or ReactiveSystem is running.
After all system execution completes, you can call Entity.Destroy() to destroy the entity which is marked ‘isDestroy’ from CleanupSystem.
I recommend marking an entity which you want to destory as ‘isDestroy’ = true instead of calling Entity.Destroy() immediately while ExecuteSystem or ReactiveSystem is running.
After all system execution completes, you can call Entity.Destroy() to destroy the entity which is marked ‘isDestroy’ from CleanupSystem.
Hi, It's not the same situation , I do real Destroy in a CleanupSystem. What I means is “Entity.Destroy()” which internally call “Entity.RemoveAllComponents()” would trigger xxxcomponent.removed() and the related reactiveSystem would excute. I think it's should not be a right behaviour? Nobody want to process a really destroyed entity, Am I right?
Reactive system uses collector which collects entities, but not removes them until processed. Filter
method can be used to check if entity still has relevant component.
This is intended behaviour.
You can filter for e.isEnabled
to check if the entity is not destroyed yet.
There are scenarios e.g. counting destroyed entities where you actually want the reactive system to be able to process destroyed entities.
Hi,
I have a ReactiveSystem which collect entities with ComponentA removed, This system will be triggered when I call Entity.Destroy on the entity who has a ComponentA, the collected entity is fully empty (has no component), Is this the proper behaviour of Entitas? In my original thought, destoryed entity would not be conllected any way. If So What should I do to prevent the destroyed entity to be collected
Cheers