예제 #1
0
        private void OnSoundControllerListChanged(object o, AudioEmitterComponent.ControllerCollectionChangedEventArgs args)
        {
            AssociatedData associatedData;

            if (!ComponentDatas.TryGetValue(args.EmitterComponent, out associatedData))
            {
                return;
            }

            // A new SoundEffect have been associated to the AudioEmitterComponenent or an old SoundEffect have been deleted.
            // We need to create/destroy the corresponding SoundEffectInstances.

            var listeners = audioSystem.Listeners.Keys;

            foreach (var listener in listeners)
            {
                var currentTuple = Tuple.Create(listener, args.Controller);

                if (args.Action == NotifyCollectionChangedAction.Add)
                {
                    associatedData.ListenerControllerToSoundInstance[currentTuple] = args.Controller.CreateSoundInstance();
                }
                else if (args.Action == NotifyCollectionChangedAction.Remove)
                {
                    args.Controller.DestroySoundInstance(associatedData.ListenerControllerToSoundInstance[currentTuple]);
                    associatedData.ListenerControllerToSoundInstance.Remove(currentTuple);
                }
            }
        }
예제 #2
0
        public AnimationClipResult GetAnimationClipResult(AnimationComponent animationComponent)
        {
            if (!ComponentDatas.ContainsKey(animationComponent))
            {
                return(null);
            }

            return(ComponentDatas[animationComponent].AnimationClipResult);
        }
예제 #3
0
 public override void Update(GameTime time)
 {
     if (ComponentDatas.Count == 0)
     {
         completed = false;
     }
     else
     {
         if (ComponentDatas.All(kvp => kvp.Key.Completed))
         {
             if (!completed)
             {
                 AllTasksCompleted.Broadcast();
             }
             completed = true;
         }
     }
 }
예제 #4
0
 public RenderLight GetRenderLight(LightComponent lightComponent)
 {
     ComponentDatas.TryGetValue(lightComponent, out var renderLight);
     return(renderLight);
 }