First, I have designed a simple model. I have created three critical classes that we're all probably very familiar with:
= Component
= Entity
= EntityManager
But what happens when specific components must be updated prior to other components during the same game loop iteration?
This may be where I have seen some introduce a "subsystem" concept. I have seen this used in two different ways in fact.
The first way is that when entities are added/removed via the entity manager, an event/callback is triggered and the subsystems react to this by inspecting the entity. If any component the subsystem cares about is found by iterating the component list, the component's reference is added to an internal list. Then the game loop ticks each subsystem in the desired logical order, not the entity manager itself.
The second way would be to have the subsystem actually created the component. When the entity is created, it calls a method on the specific systems necessary to return a reference to a Component. The subsystem would have already added it to its own internal list of components to manage for game loop manipulation. Similarly, during destruction of the entity, each component's subsystem would need to be asked to destroy the component.
I suppose its all a matter of preference but I find the first approach to give a very loose relationship between the component and the subsystem. The second way couples them closer together. But does this matter?
Another open gap for me is how granular is too much?
If we look at a house for example, it contains varying render components and physics components to be rendered and to prevent another entity from walking through its walls. But the house would not contain a health component, a mana component, and a GHealAbilityComponent that say a priest player would have.
Then would all characteristics and abilities be broken into their own component and subsystem classes such that I would see something like:
HealthComponent HealthSubsystem
ManaComponent ManaSubsystem
GHealAbilityComponent GHealAbilitySubsystem
Is this the right approach or should I look at trying to avoid a plethora of subsystems and simply have several core subsystems?
Also should game logic be in the subsystem and invoked by the event handlers on the component when specific events are received? And data elements, such as current health, max health, current mana, max mana, etc. Are these data elements to be maintained in the component class or properties on the owning entity in maybe a name-value-pair list?
Thanks in advance to any insight others may have.