Open genaray opened 4 years ago
.. sure callbacks are great ! But what if we wanna iterate with a normal system over those newly added/removed entities ? Or if we wanna run over all newly added/removed entities of a certain aspect since the last frame ? This is why i have implemented a addition to the reactive system.
Cool! Do you have concrete examples of use?
As a feature request, this is fairly specialized and less core material (artemis-odb-contrib), unless there are extension points missing in artemis-odb.
Its not perfect yet... and i havent found a good implementation of attaching the component to destroyed entitites, because they dont exist anymore at that point. But it should work for the most use cases :) ( In Unity this is managed by something called StateComponent )
Non-typical lifecycle behavior could be done by adding a 'Deleted' component to signifiydeletion, instead of calling .deleteFromWorld(), and adding an exclusion filter on spots you don't want affected by the deleted entity.
Well i actually use those systems quite heavy. I often mark my entities ( Composition > Inheritance ) with components to signalize certain entity specific events. Thats where my reactive systems come in quite nicely.
Its just an alternative to the inserted and removed callbacks for components which allows us to iterate over them for those who prefer a nice flow. It should be better for multithreading than those added/removed callbacks ^^
Here i am again... this time with a mechanic that is called "ReactiveSystem". Well actually artemis ODB already has one : EntitySubscription-Listeners.
But one major issue i occured was the lack of runtime... sure callbacks are great ! But what if we wanna iterate with a normal system over those newly added/removed entities ? Or if we wanna run over all newly added/removed entities of a certain aspect since the last frame ? This is why i have implemented a addition to the reactive system :-)
It takes multiple frames to "complete" and works like this ( same for removed )
A system which should only exists once in the system hierarchy. You can easily register a aspect, a component that should get added to that component if it was newly inserted and a component that gets added once it exited the aspect.
Furthermore it keeps track of those registered aspects to automaticly add/remove those "marker" component and as an addition it will store all of them since the last frame.
Its not perfect yet... and i havent found a good implementation of attaching the component to destroyed entitites, because they dont exist anymore at that point. But it should work for the most use cases :) ( In Unity this is managed by something called StateComponent )
It makes use of the BufferSystem i developed a week ago :) You simply need to extend that system to inject your own BufferSystems, one running at the start of the frame and one on the end.
Useage is pretty simple... you need to inject your own buffer systems
And then you simply start using it by acessing your extended ReactiveSystem like...