I am porting some code from CryEngine to LumberYard an noticed that I had to declare a component type for all of my object extensions. Why is this necessary and what does it accomplish?
That makes a lot of sense, but it is kind of getting in the way of my object extensions (i think). Why did you have actor encased in a LY namespace and is this required for all Components and extensions? Is this related to this same theme?
With the goal of making Lumberyard extensible and consistent we have taken steps to unify the concepts of IComponent, IEntityProxy and IGameObjectExtension.
Our aim is to allow components to be implemented throughout the codebase without requiring core engine modifications. In order to do this we expect objects that implement IComponent to provide their type, the macro to declare the component type simplifies this as it is required.
With these changes we achieved a concise and consistent language for interacting with components.
Previously, the API for retrieving a point to a game object extension may have looked like this:
MyObject* myObject = static_cast<MyObject*>(entity->GetProxy(ENTITY_PROXY_MYOBJECTT));
By requiring components to provide their own type we are now able to do the equivalent operation with the following code:
MyObjectPtr myObject = entity->GetComponent<MyObject>();
The change reduces the overall complexity of the code, but it is also significantly more extensible as we have removed the need for a centralized enum (i.e ENTITY_PROXY_MYOBJECT).
I hope this helps, thank you for the feedback and keep it coming!
You’re not required to place your components in the LYGame namespace.