Does adding Delegates/Function pointers to an entity break ECS ideology?

Started by
9 comments, last by DemonDar 7 years, 9 months ago

The main argument against using events in Components/Entities is that prevent serialization (in example using SQL), however, if events are added/removed by systems on entity creation/destruction you don't need to serialize the event because it is already handled in a deterministic way by the systems. The "purist" reasoning of not using events just sucks, because you'll need events and hence it is better to plainly write "HERE A EVENT" instead of hiding the event behind complex architectures that introduce new bugs:

ways of hiding an event:

- create message object

- event bus/chain

A system would add an event on entity creation/ destruction, another system would trigger it, you store the event in the entity and you save troubles, end of the story and you'll still be able to serialize in SQL your entities. you could use Action slots in c# or lists of std::function in C++. There are also nice libraries in C++ like "IncrediblyFastDelegates" that do the job pretty well.

This topic is closed to new replies.

Advertisement