A Module is an exported Flow Graph that can be loaded and called from another Flow Graph at any point during the game session.
Any Flow Graph can be converted to a Module simply by creating a new module in the Flow Graph Editor, and copying the Flow Graph contents to this new module.
The advantages of using Modules:
There are currently two supported module types.
Modules are saved in either of these two locations:
A Module is just a special flavor of a Flow Graph. This means any Flow Graph can become a module with a few simple modifications made to it.
First create a module by selecting File -> New FG Module -> Global/Level... in the Flow Graph Editor:
or right-click on the FG Modules item in the Flow Graph overview and choose New Global FG Module / New Level FG Module from the context menu:
Your new module will appear in the Flow Graph overview:
The new module will already contain two nodes: Module:Start_<YourModuleName> and Module:End_<YourModuleName>. These are specifically created for this module, and cannot be removed.
Start Node Outputs:
End Node Inputs:
If you want to delete 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 (Undo is not supported).
To call the Module, all you need to do is use the Call node specific to your module. It will be named Module:Call_<YourModuleName>:
Inputs:
Outputs:
You can also customize the inputs and outputs for each module, to pass extra data back and forth. To do so, select your module and use the Tools -> Edit Module menu option in the Flow Graph editor:
This brings up a dialog which allows adding inputs and outputs:
Supported data types are:
Clicking OK on this dialog will regenerate the module nodes (Start, End and Call) with the new inputs and outputs:
All inputs passed to the Call node will activate the corresponding outputs on the Start node, and similarly inputs to the End node will be passed back to the Call node when Success or Cancel are activated.
To access the Flow Graph Module System from outside you can use the IFlowgraphModuleManager interface.
#include "IFlowgraphModuleManager.h"
//...
IFlowgraphModuleManager* pModuleManager = gEnv->pFlowSystem->GetIModuleManager();
In some cases it might be needed to start module instances directly from code and pass results back to C++. In this case you can do the following:
void CMyClass::MyModuleCallback(bool bSuccess, const TModuleParams& outputParams)
{
// do something with the output parameters
}
void CMyClass::CallMyModule()
{
IFlowGraphModuleManager* pModuleManager = gEnv->pFlowSystem->GetIModuleManager();
if (const IFlowGraphModule* pModule = pModuleManager->GetModule(“MyModule”))
{
TModuleParams inputParams;
//… add input parameters (has to match the inputs in the module)
pModuleManager->CreateModuleInstance(pModule->GetId(), inputParams, functor(*this, &CMyClass::MyModuleCallback));
}
}
In order to get an overview of all currently available Flow Graph modules and/or see currently active module instances it is possible to use the following console variables:
Grayed out modules are modules with no active instances.