For example, let's say we want to give some entities
Regeneration, such that they regenerate 5 health per second.
One option is to have a
BuffsComponent that holds a list of all active buffs. You could create a
RegenerationBuff object that inherits from some base
Buff class, and then stick that in a list inside the
BuffsComponent. Then a
BuffsSystem would query all entities with a
BuffsComponent every frame, and execute the active effect on each buff. Simple.
However, could you not argue that these effects could just be regular old components? That is, why not create a
Regeneration component and then have a system that queries for all entities with a
Regeneration component, and then update their health in that system?
Each approach seems to have its own pros and cons, and I'm not sure if I should have a mix of the two, or fully commit to one. I feel like fully committing to one approach would simplify the architecture and design of the program, so I'm leaning towards that, but I'm not sure which approach to pick. Even if I did have a mix, I'm not sure how to decide on what should be a component versus what should be a buff.
The first approach seems more computationally efficient I suppose? Because one potential implementation of such could involve you just iterating through the list of active buffs and calling execute on each one. However, I feel that while it may be more efficient, it may also be less powerful, because with the second solution I can directly query entities with certain buffs, so I could potentially have more complex interactions between entities based on who is holding which buffs. For example, with a
Flight buff I would likely desire the ability to directly query entities with such a buff, so the latter solution would be preferable.
However, besides the latter solution being potentially slower, it also seems like it could get a bit out of hand. What if I ended up having over 100 different buffs? Adding and removing components to entities is O(1) with my ECS library, but still, it sounds like it could be a bit ridiculous to have hundreds of components for an entity, most of which are just random buffs / passives.
What should I do?