i just watched the video and now i better understand where the idea of josh comes from. But i still think the proposed solution is wrong.
As mentioned, it will remove versatility of components. Now you end up having to write a very specific component for each type.
Take the example from the video and the HealthManager component:
- Since you can't seperate it anymore you would end up with a HealthManagement part in the Monster, Player, Damagable Objects and so on. Its not very reusable. And if you change one thing, you would have to change it in each and any script.
- About the issue with the calling order:
Yes its hard to explain and would probably trick me over (however i was right of the bat able to tell why it happens. No idea why it took a week for josh)
Also another thing in the examples are bad in my opinion is to check for function names. If someone adds a component with a function with the same name, and even worse if that function has a different type or amount of arguments, it will crash.
So my proposal:
Add a way to use dependencies between components. This is pretty default to understand for any programmer and should be easy to explain.
I haven't programmed with LUA for some time so i don't know if its possible, but maybe you can do some kind of inheritence, so you could have your FPS player extend from the HealthManager. Or maybe like interfaces in other languages.
If thats not possible, i guess what could work is defining what component needs another component to be called first. That way you give the responsibility of dependencies to the components and the user who is just consuming components does not have to care about this design detail.
Or if its possible: Have some kind of event system. So the actual calling of component functions really only happens if all components and its functions are there.
Maybe a
entity.components.HealthManager:CallFunction('AddDamage', self.damage)
call could do the actual call once its sure also the FPSPlayer component (and any other component) is there.
Of course if its possible to hide this design detail and still use regular `entity.components.HealthManager:AddDamage(self.damage)` that would be even better.
These are just some really quick ideas around the issue without removing multiple components.