4 ms·
> The question is, how do you add those components together? One solution is to use mixins. This gives us some flexibility back, but we can go even further. See
by dkarl 5y ago
> The question is, how do you add those components together? One solution is to use mixins. This gives us some flexibility back, but we can go even further. See, mixins still tie the data of the component to the code that processes it. But when you think of it, some data, like the position of an object, can be useful for several systems (rendering, collision detection, AI…).
Typeclasses allow you to treat your entities as objects with behavior, while at the same time separating concerns in your codebase. The behavior is defined wherever makes sense according to the separation of concerns and then "added" to the bare entity object where it is needed.
You don't really even need typeclasses to achieve this behavior. It's just the adapter pattern.
You might not get the absolute best efficiency this way, but it's not a fatal blow to combining ECS style and OO style.