From 46c9122432200de9b1b36139bfe1653e1e0a8708 Mon Sep 17 00:00:00 2001 From: Daniel Buckmaster Date: Fri, 25 Apr 2014 13:04:12 +1000 Subject: [PATCH] Added a better example of using Explosion in a client/server fashion. --- Engine/source/T3D/fx/explosion.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/Engine/source/T3D/fx/explosion.cpp b/Engine/source/T3D/fx/explosion.cpp index b84efad3f..ecaadc96a 100644 --- a/Engine/source/T3D/fx/explosion.cpp +++ b/Engine/source/T3D/fx/explosion.cpp @@ -106,18 +106,31 @@ ConsoleDocClass( Explosion, " lightEndBrightness = 0.0;\n" " lightNormalOffset = 2.0;\n" "};\n\n" - "function createExplosion()\n" + "function ServerPlayExplosion(%position, %datablock)\n" "{\n" - " // Create a new explosion - it will explode automatically\n" - " %pos = \"0 0 100\";\n" - " %obj = new Explosion()\n" + " // Play the given explosion on every client.\n" + " // The explosion will be transmitted as an event, not attached to any object.\n" + " for(%idx = 0; %idx < ClientGroup.getCount(); %idx++)\n" " {\n" - " position = %pos;\n" - " dataBlock = GrenadeLauncherExplosion;\n" - " };\n" + " %client = ClientGroup.getObject(%idx);\n" + " commandToClient(%client, 'PlayExplosion', %position, %datablock.getId());\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" "// schedule an explosion\n" - "schedule(1000, 0, createExplosion);\n" + "schedule(1000, 0, ServerPlayExplosion, \"0 0 0\", GrenadeLauncherExplosion);\n" "@endtsexample" );