Quick question on component inheritance
Posted: 2014-07-30, 17:20
While I am not able to program, I thought I'd spend some time designing the game I am going to be building on my return. I am currently designing the component system, and had a quick question on component inheritance.
In my design, if something is alive (i.e. can die/be destroyed), it will have a Health component. The health component will have the elements - GetMaxHealth, SetMaxHealth, AddHealth, GetHeath, SetHealth, GetIsAlive, Kill. Internal Variables would be health, maxhealth, isalive. Obviously this could be expanded as required.
I will then add a sub-component for those Alive entities which have armor called Armor and add the elements - GetMaxArmor, SetMaxArmor, AddArmor, GetArmor, SetArmor. Internal variables would be armor, maxarmor.
My question is, If I added the Armor component to an entity, would the Health component be added by default, as it is part of the armor component? or would I still need to to add the Armor and Health components to the entity?
In my design, if something is alive (i.e. can die/be destroyed), it will have a Health component. The health component will have the elements - GetMaxHealth, SetMaxHealth, AddHealth, GetHeath, SetHealth, GetIsAlive, Kill. Internal Variables would be health, maxhealth, isalive. Obviously this could be expanded as required.
I will then add a sub-component for those Alive entities which have armor called Armor and add the elements - GetMaxArmor, SetMaxArmor, AddArmor, GetArmor, SetArmor. Internal variables would be armor, maxarmor.
My question is, If I added the Armor component to an entity, would the Health component be added by default, as it is part of the armor component? or would I still need to to add the Armor and Health components to the entity?