How to achieve a event system? #111
-
How to achieve a event system if we were unable to create or delete component at runtime? In unity ECS, the event system is like adding a event component which containing required data, and there is a system to process this event. for example, block: entity
bock: entity
a system called BlockInteractEventSystem would process any entities with comp BlockType and comp BlockInteractEvent |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello, in DOTS ECS, when you add a new component to an entity, you are effectively moving the entity to a different subset. This is indeed the way to handle change of behaviours. If a new behaviour must be applied to an entity, it should be found into another subset. In Svelto you can create subsets with groups and filters. GroupCompounds help handing multiple states at once. A group compound handles up to 4 states, where the first 1 is usually the type of entity itself. So usually you can handle 3 different states at once. When this becomes to restrictive or cumbersome, filters can be used. the new filters API allows to iterate entities found in specific filters. Each entity can be in any filter you need. the filter ID can identify a state. Rarely is necessary to communicate that something happens and this is awkward to do both with groups and filters. In this case you could potentially create new entities when an event happens and rely on IReactOnAddEx callbacks |
Beta Was this translation helpful? Give feedback.
Hello,
in DOTS ECS, when you add a new component to an entity, you are effectively moving the entity to a different subset. This is indeed the way to handle change of behaviours. If a new behaviour must be applied to an entity, it should be found into another subset.
In Svelto you can create subsets with groups and filters. GroupCompounds help handing multiple states at once. A group compound handles up to 4 states, where the first 1 is usually the type of entity itself. So usually you can handle 3 different states at once.
While you can iterate entities found in specific groups, it's also possible to rely on the IReactOnSwapEx callbacks to react on specific change of state once.
When thi…