@@ -990,19 +990,30 @@ public static void GenerateSoundSources(CodeMemberMethod method, SoundSourceColl
990990 {
991991 foreach ( var sound in sounds )
992992 {
993- CodeMethodInvokeExpression addSound = new CodeMethodInvokeExpression (
994- new CodeVariableReferenceExpression ( collVar ) , "Add" ,
995- new CodeSnippetExpression (
996- string . Format ( "new SoundSource {{ SoundType = SoundType.{0}, SoundAsset = \" {1}\" }}" , sound . SoundType , sound . SoundAsset ) ) ) ;
993+ var soundSource = GenerateSoundSource ( method , sound ) ;
994+ CodeMethodInvokeExpression addSound = new CodeMethodInvokeExpression ( new CodeVariableReferenceExpression ( collVar ) , "Add" , soundSource ) ;
997995 method . Statements . Add ( addSound ) ;
998-
999- method . Statements . Add ( new CodeMethodInvokeExpression (
1000- new CodeFieldReferenceExpression ( new CodeTypeReferenceExpression ( "SoundManager" ) , "Instance" ) ,
1001- "AddSound" ,
1002- new CodePrimitiveExpression ( sound . SoundAsset ) ) ) ;
1003996 }
1004997 }
1005998
999+ /// <summary>
1000+ /// Generates the sound source.
1001+ /// </summary>
1002+ /// <param name="method">The method.</param>
1003+ /// <param name="sound">The sound.</param>
1004+ public static CodeSnippetExpression GenerateSoundSource ( CodeMemberMethod method , SoundSource sound )
1005+ {
1006+ CodeSnippetExpression expression = new CodeSnippetExpression (
1007+ string . Format ( "new SoundSource {{ SoundType = SoundType.{0}, SoundAsset = \" {1}\" , Volume = {2}f }}" , sound . SoundType , sound . SoundAsset , sound . Volume ) ) ;
1008+
1009+ method . Statements . Add ( new CodeMethodInvokeExpression (
1010+ new CodeFieldReferenceExpression ( new CodeTypeReferenceExpression ( "SoundManager" ) , "Instance" ) ,
1011+ "AddSound" ,
1012+ new CodePrimitiveExpression ( sound . SoundAsset ) ) ) ;
1013+
1014+ return expression ;
1015+ }
1016+
10061017 private static List < DependencyProperty > GetAttachedProperties ( DependencyObject obj )
10071018 {
10081019 List < DependencyProperty > result = new List < DependencyProperty > ( ) ;
0 commit comments