Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.
X

The Factory system

Hello!

Here is another walk-through/overview of another engine system. This one will be focusing on the Factory manager and how it interacts with the properties and enteties of the engine.

The Factory Manager:

The factory manager is the singleton that the developer will contact in the program when he wants to create an entity. It is also the class that is contacted from the state when it wants to load a level. This is meant to give developers a standardized way of creating entities in the engine, the definitions of these entities are done through the blueprint system that was covered in a previous post.

After these entities are defined through reading the blueprint and level files it is time to create actual in-game entities from them, this posed a problem for us, since we did not want the developer to have to go in to the “FactoryManager” and rewrite it so that it could handle every new property that they want to add to their game. We came up with a solution that was heavily inspired by a game engine that we had worked closely with before: “Nebula Trifid” , we designed two macros that the developer adds to the top of their properties .h(“SetUpProperty(PropertyName);”) and .cpp(ImplementProperty(PropertyName);) files. These define static functions that when called from the setup part of the developers application file would send the name of the property and a function pointer pointing to a creation function for the property to the “FactoryManager”. These are then stored in a map where the key is the name of the property and the value is the function pointer.

Later when the “FactoryManager” is told to create an entity with the property “x” the “FactoryManager” will get the pointer from the map where “x” is the key and use it to create a property that it can then handle as a “PropertyBase” pointer thanks to the polymorphic inheritance that the entity system uses. Thus the “FactoryManager” can create and deliver a fully functional game entity with all its properties correctly attached without any modification needed to the manager when new properties are added to the project.

Be Sociable, Share!

Leave a comment  

name*

email*

website

Submit comment