Closed genaray closed 3 years ago
It wouldn't make much sens as you would no longer have the component ^^. But the generator also pick up DefaultEcs With/Without/WhenAdded/WhenChanged and of course WhenRemoved attribute at the system type level in case you want extra rules but don't need the actual component value. It also pick up the Either variants but I am still looking into how having it directly expressed in the parameters of the Update decorated method.
It wouldn't make much sens as you would no longer have the component ^^. But the generator also pick up DefaultEcs With/Without/WhenAdded/WhenChanged and of course WhenRemoved attribute at the system type level in case you want extra rules but don't need the actual component value. It also pick up the Either variants but I am still looking into how having it directly expressed in the parameters of the Update decorated method.
Well you are right, thanks :D The component does not exist anymore which makes it basically impossible. I guess im gonna use the listeners instead, the removedComponentListener does pass the removed component to the method which is great because i need to dispose it properly.
Yeah since Entity containers (set, map, ...) are used with a delay by systems compared to when the component operations actually occur there is no longer the component value, and storing it in the system would complicate things. For cleanup logic with disposable components it is better to use the World.SubscribeComponentRemoved
which is synchronous with the actual component removal. If you need to filter out the entities inside the callback, you can always create a query AsPredicate
so you can test the entity before actually doing the cleanup.
Well i saw theres a [Added] and [Changed] attribute for the generation to listen for added/changed components... what about the removed ones ? :) I couldnt find an [Removed] attribute for params, would be great to have one.