Quote:Original post by matthewbot
Am I completely missing other advantages to indirection and using messages and things? Or are there instances that i haven't yet thought of where my no messages and no way to actually access specific components given an entity will break down?
Because then you lose the ability to dynamically generate entitys from data files. For example, if you have a data-file like this:
entity name="Soldier"component type="position"component type="health" initialValue="100"component type="HumanRenderer"... etc
Creating the components is really difficult because the system would need to know the graph of all dependencies up-front and ensure it creates them in the right order. It also means if you add a new component and you want your HumandRenderer to take a dependency on it, for example, you need to update all of your definitions to include the new component.
By doing the dependencies dynamically, you avoid all those problems. You add all the components to the entities at once (using the default constructor for simplicity) and then they can just query each other for their properties, etc. If you add a new kind of component to the system, you don't have to update all the entity definition files - just make sure components which want to use it can handle the case where it's no there.