| 1 | = Howt to make an object class Synchronisable = |
| 2 | See also [wiki:network/Synchronisable] for more information. |
| 3 | == Basic steps == |
| 4 | 1. {{{ #include "network/Synchronisable.h" }}} |
| 5 | 2. make sure your class inherits from Synchronisable: |
| 6 | {{{ |
| 7 | class XYZ : public network::Synchronisable { ... }; |
| 8 | }}} |
| 9 | 3. create the function void registerAllVariables() and call REGISTERDATA or REGISTERSTRING functions in order to register these variables for synchronisation: |
| 10 | {{{ |
| 11 | void XYZ::registerAllVariables(){ |
| 12 | REGISTERDATA(somevariable); |
| 13 | REGISTERSTRING(meshSrcName_); |
| 14 | } |
| 15 | }}} |
| 16 | 4. make sure registerAllVariables() gets called in the constructor: |
| 17 | {{{ |
| 18 | XYZ::XYZ(){ |
| 19 | registerAllVariables(); |
| 20 | // do not work with synchronisable variables in your constructor (except initialisation) |
| 21 | } |
| 22 | }}} |
| 23 | 5. implement the create() function and put all the code that needs some synchronisable variables to be set inside it: |
| 24 | {{{ |
| 25 | bool XYZ::create(){ |
| 26 | this->ogreMesh_.setMesh(meshSrcName_); |
| 27 | } |
| 28 | }}} |