Merge pull request #632 from eightyeight/better-explosion-example

Added a better example of using Explosion in a client/server fashion
This commit is contained in:
Daniel Buckmaster 2014-05-11 13:22:28 +10:00
commit 47dbce1499

View file

@ -106,18 +106,31 @@ ConsoleDocClass( Explosion,
" lightEndBrightness = 0.0;\n" " lightEndBrightness = 0.0;\n"
" lightNormalOffset = 2.0;\n" " lightNormalOffset = 2.0;\n"
"};\n\n" "};\n\n"
"function createExplosion()\n" "function ServerPlayExplosion(%position, %datablock)\n"
"{\n" "{\n"
" // Create a new explosion - it will explode automatically\n" " // Play the given explosion on every client.\n"
" %pos = \"0 0 100\";\n" " // The explosion will be transmitted as an event, not attached to any object.\n"
" %obj = new Explosion()\n" " for(%idx = 0; %idx < ClientGroup.getCount(); %idx++)\n"
" {\n" " {\n"
" position = %pos;\n" " %client = ClientGroup.getObject(%idx);\n"
" dataBlock = GrenadeLauncherExplosion;\n" " commandToClient(%client, 'PlayExplosion', %position, %datablock.getId());\n"
" };\n" " }\n"
"}\n\n"
"function clientCmdPlayExplosion(%position, %effectDataBlock)\n"
"{\n"
" // Play an explosion sent by the server. Make sure this function is defined\n"
" // on the client.\n"
" if (isObject(%effectDataBlock))\n"
" {\n"
" new Explosion()\n"
" {\n"
" position = %position;\n"
" dataBlock = %effectDataBlock;\n"
" };\n"
" }\n"
"}\n\n" "}\n\n"
"// schedule an explosion\n" "// schedule an explosion\n"
"schedule(1000, 0, createExplosion);\n" "schedule(1000, 0, ServerPlayExplosion, \"0 0 0\", GrenadeLauncherExplosion);\n"
"@endtsexample" "@endtsexample"
); );