Skip to content

ExclusiveGroups in place of events

Sebastiano Mandalà edited this page Jan 15, 2019 · 1 revision

ECS should work around the concept of data polling. However many known problems are usually solved through events. In this case data polling can become cumbersome as polling continuously data to know if something changed is a waste of precious instructions. Messaging through events can be still done, but in many ways is not compatible with the ECS logic, so Svelto provides an alternative solution that can suit multiple scenarios through the use of groups.

For example, instead to send events when an item collides, you can move it to the "collided items" group. A separate engine has the responsibility to iterate over this group. while there is still an overhead, iterating on a group of 0 items is pretty fast, so even if it happens continuously, the waste is much limited.

Using groups as alternative of events, not only is much more ECS compatible, but also multi threads friendly.

Clone this wiki locally