Trying to understand poly #1256
-
hello,
And all I want is to have inheriting from if specific gameBox component types like: hitBox, healthBox, patrolBox. Not the issue is that, unless I am doing something wrong, with a classic OOP inheritance, this would not work with the derived component:
What I would like is that all components inheriting from GameBoxComponent would be properly set without having to pass them all to the registry.view, since they all are a GameBoxComponent type. thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
This kind of inheritance is exactly what components aim to replace in your project. |
Beta Was this translation helpful? Give feedback.
-
Yes, I do have those systems. I have a health system, a collision box system, an impact system, and they all communicate with each other |
Beta Was this translation helpful? Give feedback.
Until you don't want to iterate them all at once throught their base class, that's perfectly fine then.
In my own projects I favor composition in this case actually. Something like:
Where
rect_type
is your base class (more or less, you have more data, but you get what I mean).It's a matter of tastes. A non-virtual base used to share the design of a piece of information is also ok.