public ControllerCollectionChangedEventArgs(Entity entity, AudioEmitterSoundController controller, AudioEmitterComponent component, NotifyCollectionChangedAction action)
 {
     Entity = entity;
     Controller = controller;
     EmitterComponent = component;
     Action = action;
 }
示例#2
0
        /// <summary>
        /// Attach a <see cref="SoundEffect"/> to this emitter component.
        /// Once attached a <see cref="AudioEmitterSoundController"/> can be queried using <see cref="GetSoundEffectController"/> to control the attached SoundEffect.
        /// </summary>
        /// <param name="soundEffect">The SoundEffect to attach</param>
        /// <exception cref="ArgumentNullException">The provided <paramref name="soundEffect"/> is null.</exception>
        /// <exception cref="InvalidOperationException">The provided <paramref name="soundEffect"/> can not be localized (contains more than one channel).</exception>
        /// <remarks>Attaching a soundEffect already attached has no effects.</remarks>
        public void AttachSoundEffect(SoundEffect soundEffect)
        {
            if (soundEffect == null)
            {
                throw new ArgumentNullException("soundEffect");
            }
            if (soundEffect.WaveFormat.Channels > 1)
            {
                throw new InvalidOperationException("The provided SoundEffect has more than one channel. It can not be localized in the 3D scene.");
            }

            if(SoundEffectToController.ContainsKey(soundEffect))
                return;

            var newController = new AudioEmitterSoundController(this, soundEffect);
            SoundEffectToController[soundEffect] = newController;
            if(ControllerCollectionChanged != null)
                ControllerCollectionChanged.Invoke(this, new ControllerCollectionChangedEventArgs(Entity, newController, NotifyCollectionChangedAction.Add ));
        }
        public void AttachSound(Sound sound)
        {
            if (sound == null)
            {
                throw new ArgumentNullException(nameof(sound));
            }
            if (sound.Channels > 1)
            {
                throw new InvalidOperationException("The provided Sound has more than one channel. It can not be localized in the 3D scene.");
            }

            if(SoundToController.ContainsKey(sound))
                return;

            var newController = new AudioEmitterSoundController(this, sound);
            SoundToController[sound] = newController;
            ControllerCollectionChanged?.Invoke(this, new ControllerCollectionChangedEventArgs(Entity, newController, this, NotifyCollectionChangedAction.Add ));
        }