domingo, 31 de octubre de 2010

Component-based systems (part 2)

Next thing is how the components will interact with each other, defining that beforehand is important to have a consistent model. Usually, they should not do that, but what happens when there is a render component that depends on information kept in a spatial component, like the position.
It is quite clear to me that everything should go through the game object in a generic way, but some kind of dependency could not be avoided.

There seems to be two different ways:

1. Dependency on component.

 A component requests the game object for another component in its collection and access it directly.
The component dependent on the other should do nothing if it can't be found.


2. Dependency on property.

A game object is a property container and each component added to its collection registers a reference to where it holds the information. If the module is unloaded the properties should be unregistered too.
The names inside the reference class are going to have unique identifiers, to avoid name collision between similar properties registered by different components. "ComponentName.PropertyName".



At the end I feel that both options are valid and are almost the same, the second adding a little more and maybe unnecessary complexity though.

- MR

No hay comentarios:

Publicar un comentario