{english}h1. Flowgraph Module System

{toc-zone:minlevel=2|type=list|separator\=newline|location=top}

h2. 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 creating a new module in the Flowgraph Editor, and copying the Flowgraph contents to this new module.

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.
* Modules are instanced, meaning that multiple copies of the same module can be active simultaneously, but running with different inputs


h2. 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. First create a module by selecting *File \-> New FG Module...* in the Flowgraph Editor:

!NewModule.jpg!

or right-click on the *FG Modules* item in the Flowgraph overview and choose *New FG Module* from the context menu:

!NewModule2.jpg!

Save the module in either _../<YourGameFolder>/Libs/FlowgraphModules/_ (for a global module accessible in all levels) or _../<YourGameFolder>/Levels/<levelfolder>/FlowgraphModules/_ (for a level specific module). Your new module will appear in the Flowgraph overview:

!mymodule.jpg!

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 output:*
* *Start* \- Called when Module is loaded. Treat this like you would the *Misc:Start* Node.

*End node inputs:*
* *Success* \- call this to end the module and pass a 'success' status back to the caller
* *Cancel* \- call this to end the module and pass a 'canceled' status back to the caller

h2. Deleting a Module

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

!DeleteModule.jpg!

{note:title=Note}If you delete a Module it will also delete the saved XML file.
{note}
h2. 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.


h2. Calling a Module from Flowgraph

So now we have this Module ready to be used in our level. 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>*:

!CallModule.jpg!

*Inputs:*
* *Call* \- Call to load the Module and begin its execution.

*Outputs:*
* *Done* \- Called when the Module returns with a Success status.
* *Canceled* \- Called when the Module returns with a Fail status.

h2. Custom Module Ports

You can also customize the inputs and outputs for each module, to pass extra data back and forth. To do so, use the *Tools \-> Edit Module* menu option in the flowgraph editor:

 !EditModuleMenu.jpg!

This brings up a dialog which allows adding inputs and outputs:

 !NewInput.jpg!

Clicking *OK* on this dialog will regenerate the module nodes (*Start*, *End* and *Call*) with the new inputs and outputs:

!NewNodes.jpg!

!NewCallNode.jpg!

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.

h2. C+\+ Interface

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

{code:title=Code/CryEngine/CryCommon/IFlowgraphModuleManager.h|borderStyle=solid}#include "IFlowgraphModuleManager.h"
//...
IFlowgraphModuleManager* pModuleManager = gEnv->pFlowSystem->GetIModuleManager();
{code}

h2. Debugging

In order to get an overview of all currently available Flowgraph Modules and/or see currently active module instances it is possible to use the following console variables:

*fg_debugmodules* 0/1/2 - 0: Disabled / 1: Shows a list of all currently available modules / 2: Shows a list of all currently available modules and active module instances
*fg_debugmodules_filter* "filterstring" - "filterstring" can be used to only show specific modules

!flowgraph_modules_debugging.png!

{toc-zone}
{english}















{korean}h1. ??? ??? ?? ???

{toc-zone:minlevel=2|type=list|separator\=newline|location=top}

h2. ?????



???? ?? ? ? ?? ?? ??? ???? ?? ?? ????? ?? ??? ???? ??? ? ?? ????? ??? ???? ????. ?? ??? ???? ??? ??? ??? ???? ?? "Save" ??? ???? ??? ???? *Xml* ???? ?????? ??? ?? ? ? ????.



?? ??? ??:

* ?? ??? ???? ? ?????? ??? ? ??? ?? ???? ?? ? ? ????.

* ??? ??? ?? ???/??? ?? ?? ?? ? ??? ?? ?? ??? ? ? ????.

* ??? ???/??? ??? ?? ???? ??? ? ? ??? ??? ?? ???? ?? ???? ???? ? ? ????.



h2. ??? ??? ??? ????



??? ??? ???? ??? ?? ???. ? ??, ?? ??? ???? ??? ??? ??? ?? ??? ? ? ??? ????. ?? ???? ??? ???? ???? ??? ?? ???? ??? ??? ???? ???? ??? ????. ???? ??? ?? *Module:Start*??? ???? ???. ??? ??? ???? ? ?? ???? ???.  ?? ?? ??? ?? ? ?? ??? ?????. (??? ??? ???)



!fg_module_start.jpg!



*???:*

* *??* - ??? ?? ?? ?????.Called when Module is loaded. ??? Misc:Start ??? ???? ???.

* *???* - ???ID? ??? ????? ??? ?? ???. ??? ??, ?? ??? (??? ???? ???? ??? ?? ?? ???? ???? ?? ??) ????? ??? ?????.

* *????1* - ???? ???? ???? ?? ??? ?? ?????.

* *????2* -???? ???? ???? ?? ??? ?? ?????.

* *????3* -???? ???? ???? ?? ??? ?? ?????.

* *????4* - ???? ???? ???? ?? ??? ?? ?????.

* *????5* -???? ???? ???? ?? ??? ?? ?????.

* *????6* - ???? ???? ???? ?? ??? ?? ?????.



??? ??? ???, ???? *Module:Return* ??? ??? ?? ???? ?? ???. ? ??? ? ?? ??? ????. ??? ???? ??? ??? ???? ??? ????. ??? ???? ?? ??? ?? ???? ?? ????, ??? ?? ??? ???. ???? ?? ?? ?? ??? ???? ???? ?? ???? ?? ?????.



!fg_module_return.jpg!



*??:*

* *??(End)* - ???? ?? ?? ?? ??? ??? ?? ????.

* *??* - ???? ?? ?? ?? ??? ??? ?? ????.

* *????1* - ???? ???? ???? ?? ??? ?? ?????.

* *???? 2* - ???? ???? ???? ?? ??? ?? ?????.

* *????3* - ???? ???? ???? ?? ??? ?? ?????.

* *????4* - ???? ???? ???? ?? ??? ?? ?????.

* *????5* - ???? ???? ???? ?? ??? ?? ?????.

* *????6* - ???? ???? ???? ?? ??? ?? ?????.



h2. ?? ?? ????



????? ?? ??? ?? ??? ?? ?? ??? ??? ??? ??? *File->New FG Module...*? ???? ???. ??? ?? ??? *Module:Start* ? *Module:Return*? ??? ??? ?? ??? ??? ???? ?????.



!fg_modules_empty.jpg!



h2. ?? ?? ?? ?? ??



?? ??? ?? ?? ?? ??? ?? ??, *FG Modules* ????? ?? ??? ???? ???? ???.



!fg_modules_rename_delete.jpg!

{note:title=Note}?? ??? ??? XML ??? ?? ?? ???.

{note}



h2. ?? ????



??? ???? ?? ??? ???? ????? ??? ??? ???? ??? ???? ??? ? ?? ??? *Save*? ???? ???. ???? ??? ?? ??? ???? ??? ? ?? ???? ????? ????.

* *{_}Game/Libs/FlowgraphModules/_*

??? ??? ??? ?? ?? ???. ?? ????? ??? ???? ??? ??? ??????.

* *{_}Game/Level/MyLevel/FlowgraphModules/_*

??? ??? ?? ?? ?????. ?? ??? ??? ?? ??? ??? ???. ??? ????? ??? ???? ??? ??? ??????.



??? ????, ???? ?? ??? _FlowgraphModules_ ??? ?? ?? ?????. ?? ???? ??? ?? ? ???, ???? _FlowgraphModules_ ??? ?????. ??? ?? ?? ??-?? ??? ?? ??? ???  *overwrite* ???? ?????.



h2. ??? ????? ?? ???



?? ???? ??? ? ?? ??? ??? ?????. ??? ??? ???? *Module:Call*??? ???? ???.



!fg_module_call.jpg!



*??:*

* *?(Call)* - ??? ???? ??? ???? ?? ????.

* *??* - ?? ?? ????? ????? ??? Xml?? ??? ???? ???. ".xml" ??? ???? ??? ???.

* *???* - ???ID? ? ??? ??? ????? ???.

* *????1* - ???? ???? ???? ??? ??? ??? ?????.

* *????2* - ???? ???? ???? ??? ??? ??? ?????.

* *????3* - ???? ???? ???? ??? ??? ??? ?????.

* *????4* - ???? ???? ???? ??? ??? ??? ?????.

* *????5* - ???? ???? ???? ??? ??? ??? ?????.

* *????6* - ???? ???? ???? ??? ??? ??? ?????.



*???:*

* *??(Called)* - ?? ??? ?? ?? ??? ?? ?? ? ????. ??? True? ??, ?? ??? False? ??

* *??(Done)* - ??? ??? ?? ???? ??? ?????.

* *??(Canceled)* - ??? ??? ?? ???? ??? ?????.

* *????1* - ???? ???? ???? ??? ?? ? ? ?? ?? ???.

* *????2* - ???? ???? ???? ??? ?? ? ? ?? ?? ???.

* *????3* - ???? ???? ???? ??? ?? ? ? ?? ?? ???.

* *????4* - ???? ???? ???? ??? ?? ? ? ?? ?? ???.

* *????5* - ???? ???? ???? ??? ?? ? ? ?? ?? ???.

* *????6* - ???? ???? ???? ??? ?? ? ? ?? ?? ???.



h2. C++ ?????



??? ??? ??? ?? ???? ???, *IFlowgraphModuleManager* ?????? ???? ???.

{code:title=Code/CryEngine/CryCommon/IFlowgraphModuleManager.h|borderStyle=solid}#include "IFlowgraphModuleManager.h"

//...

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

{code}

{toc-zone}
{korean}