Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 20 Next »

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:

  • Same Flowgraph can be used in multiple levels, but only exist in one location.
  • Modules can receive unique input values from their caller, allowing them to be very robust.
  • Modules can return unique output values to their callers, allowing them to be used in many different situations.

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).

Outputs:

  • Start - Called when Module is loaded. Treat this like you would the Misc:Start Node.
  • Entity - EntityId assigned to the Module as its Graph Entity. This is your your own reference; any Node that is either set to use the Graph Entity or not assigned an Entity will automatically use this.
  • Param1 - Additional parameter data passed from the Caller Node.
  • Param2 - Additional parameter data passed from the Caller Node.
  • Param3 - Additional parameter data passed from the Caller Node.
  • Param4 - Additional parameter data passed from the Caller Node.
  • Param5 - Additional parameter data passed from the Caller Node.
  • Param6 - Additional parameter data passed from the Caller Node.

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.

Inputs:

  • End - Call to return from the Module with a Success status.
  • Cancel - Call to return from the Module with a Fail status.
  • Param1 - Additional parameter data passed back to the Caller Node.
  • Param2 - Additional parameter data passed back to the Caller Node.
  • Param3 - Additional parameter data passed back to the Caller Node.
  • Param4 - Additional parameter data passed back to the Caller Node.
  • Param5 - Additional parameter data passed back to the Caller Node.
  • Param6 - Additional parameter data passed back to the Caller Node.

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.

Note

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:

  • \Game\Libs\FlowgraphModules
    This is your Global Modules folder. Save your Module here if you want to use it in multiple levels.
  • Game\Level\MyLevel\FlowgraphModules
    This is your Level Modules folder. Every Level can have their own Modules folder. Save your module here if you want to use it only in one particular level.

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.

Inputs:

  • Call - Call to load the Module and begin its execution.
  • Module - Name of the Module to call. This should match the name of the Xml file you saved in the previous step. You do not have to include the ".xml" part.
  • Entity - EntityId that should be this Module's Graph Entity.
  • Param1 - Additional parameter data to pass to the Module's Start nodes.
  • Param2 - Additional parameter data to pass to the Module's Start nodes.
  • Param3 - Additional parameter data to pass to the Module's Start nodes.
  • Param4 - Additional parameter data to pass to the Module's Start nodes.
  • Param5 - Additional parameter data to pass to the Module's Start nodes.
  • Param6 - Additional parameter data to pass to the Module's Start nodes.

Outputs:

  • Called - Called when the Module is fully loaded and has started executing. Returns True if successful, False if failed to load.
  • Done - Called when the Module returns with a Success status.
  • Canceled - Called when the Module returns with a Fail status.
  • Param1 - Additional parameter data passed back from the Module when it returned.
  • Param2 - Additional parameter data passed back from the Module when it returned.
  • Param3 - Additional parameter data passed back from the Module when it returned.
  • Param4 - Additional parameter data passed back from the Module when it returned.
  • Param5 - Additional parameter data passed back from the Module when it returned.
  • Param6 - Additional parameter data passed back from the Module when it returned.

C++ Interface

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

Code/CryEngine/CryCommon/IFlowgraphModuleManager.h
#include "IFlowgraphModuleManager.h"
//...
IFlowgraphModuleManager* pModuleManager = gEnv->pFlowSystem->GetIModuleManager();
  • No labels