예제 #1
0
 private static EventInstance PlayOneshotInternal(string path, Vector3 position, FMODCommon.NetworkRole role, params object[] parameterValues)
 {
     if (path.Length <= 0 || !FMOD_StudioSystem.instance)
     {
         return(null);
     }
     if (BoltNetwork.isRunning)
     {
         bool flag = false;
         if (role != FMODCommon.NetworkRole.None)
         {
             if (role != FMODCommon.NetworkRole.Server)
             {
                 if (role == FMODCommon.NetworkRole.Any)
                 {
                     flag = true;
                 }
             }
             else
             {
                 flag = BoltNetwork.isServer;
             }
         }
         else
         {
             flag = false;
         }
         if (flag)
         {
             int num = CoopAudioEventDb.FindId(path);
             if (num >= 0)
             {
                 int   num2  = -1;
                 float value = 0f;
                 if (parameterValues.Length == 2 && parameterValues[0] is string && parameterValues[1] is float)
                 {
                     num2  = FMODCommon.GetParameterIndex(path, parameterValues[0] as string);
                     value = (float)parameterValues[1];
                 }
                 if (num2 >= 0)
                 {
                     FmodOneShotParameter fmodOneShotParameter = FmodOneShotParameter.Create(GlobalTargets.Others, ReliabilityModes.Unreliable);
                     fmodOneShotParameter.EventPath = num;
                     fmodOneShotParameter.Position  = position;
                     fmodOneShotParameter.Index     = num2;
                     fmodOneShotParameter.Value     = value;
                     fmodOneShotParameter.Send();
                 }
                 else
                 {
                     FmodOneShot fmodOneShot = FmodOneShot.Create(GlobalTargets.Others, ReliabilityModes.Unreliable);
                     fmodOneShot.EventPath = num;
                     fmodOneShot.Position  = position;
                     fmodOneShot.Send();
                 }
             }
             else
             {
                 UnityEngine.Debug.LogFormat("Couldn't find event path in CoopAudioEventDb: {0}", new object[]
                 {
                     path
                 });
             }
         }
     }
     if (FMOD_StudioSystem.instance)
     {
         return(FMOD_StudioSystem.instance.PlayOneShot(path, position, delegate(EventInstance instance)
         {
             instance.setParameterValue("time", FMOD_StudioEventEmitter.HoursSinceMidnight);
             FMODCommon.SetParameterValues(instance, parameterValues);
             return true;
         }));
     }
     return(null);
 }