Flowgraph Module System

What is a Module

A Module is an exported Flowgraph that can be loaded and called from another Flowgraph at any point during the game session. Any Flowgraph can be converted to a Module simply by exporting the Flowgraph to its Xml format using the "Save" option in the Flowgraph Editor.

The advantages of using Modules:

Converting a Flowgraph to a Module

A Module is just a special flavor of a Flowgraph. This means ANY Flowgraph can become a Module with a few simple modifications made to it. So pick your favorite Flowgraph that you want to turn into a Module, or create a simple one to work with. The first thing you will need to do is place a Module:Start Node. This acts as the starting point for your Module when it is called. It also carries over any input sent from the Caller Node (more on this later).


After you have placed the Starting point, you may want to place an Ending point by using the Module:Return Node. Note that this set is not required. When a Module returns, it is unloaded and stops executing. If you want your Module to always remain executing while the level is being played, then don't return from it! Returning from a Module does allow you to pass optional data back to the Caller.


Creating an empty Module

If you want to create a new Module from scratch you can simply choose File->New FG Module... from the Flowgraph Editor menu. This will create a new Flowgraph with the Module:Start and Module:Return flownodes already added to it.

Deleting or Renaming a Module

If you want to delete or rename a specific Module you can right click on the Module name in the FG Modules list.

If you delete a Module it will also delete the saved XML file.

Saving a Module

To save your Flowgraph so that it can be used as a Module, all you need to do is bring up your Flowgraph in the Flowgraph Editor, and select Save from the File Menu. There are multiple locations where you should save the Flowgraph, depending on how you want to use it:

When loading a Module, the system will first check the current level's FlowgraphModules folder. If the Module is not found there, it will then look in the Global FlowgraphModules folder. This gives you the potential to overwrite a Global Module with a Level-Specific Module if you wish.

Calling a Module from Flowgraph

So now we have this Module ready to be used in our level. To call the Module, all we need to do is use the Module:Call Node.



C++ Interface

To access the Flowgraph Module System from outside you can use the IFlowgraphModuleManager interface.

IFlowgraphModuleManager* pModuleManager = gEnv->pFlowSystem->GetIModuleManager();