瀏覽代碼

Merge pull request #705 from Azaezel/alpha40/playSoundAugs

augments playSoundAsset
Brian Roberts 3 年之前
父節點
當前提交
f88e82c099

+ 7 - 0
Templates/BaseGame/game/core/clientServer/scripts/server/audio.tscript

@@ -38,3 +38,10 @@ function ServerPlay3D(%profile,%transform)
       ClientGroup.getObject(%idx).play3D(%profile,%transform);
       ClientGroup.getObject(%idx).play3D(%profile,%transform);
 }
 }
 
 
+function ServerPlaySound(%profile,%pos)
+{
+   // Play the given sound profile at the given position on every client
+   // The sound will be transmitted as an event, not attached to any object.
+   for(%idx = 0; %idx < ClientGroup.getCount(); %idx++)
+      commandToClient(ClientGroup.getObject(%idx), PlaySound, %pos);
+}

+ 14 - 4
Templates/BaseGame/game/core/utility/scripts/helperFunctions.tscript

@@ -645,11 +645,21 @@ function populateAllFonts(%font)
 }
 }
 
 
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
-function playSoundAsset(%soundAssetId)
+function clientCMDPlaySound(%soundAssetId,%pos)
+{
+    playSoundAsset(%soundAssetId,%pos);
+}
+
+function playSoundAsset(%soundAssetId,%pos)
 {
 {
    %assetDef = AssetDatabase.acquireAsset(%soundAssetId);
    %assetDef = AssetDatabase.acquireAsset(%soundAssetId);
+   %handle = 0;
    if(isObject(%assetDef))
    if(isObject(%assetDef))
-      %assetDef.playSound();
-   
-   AssetDatabase.releaseAsset(%soundAssetId);
+   {
+      %handle = %assetDef.playSound(%pos);
+      if( isObject( ClientMissionCleanup ) )
+         ClientMissionCleanup.add(%handle);
+  }
+  AssetDatabase.releaseAsset(%soundAssetId);
+  return %handle;
 }
 }