EventStatus IEventListener.Process(Fabric.Event zEvent)
 {
     if (_probability < 100)
     {
         int num = (int)(rnd.NextDouble() * 100.0);
         if (num > _probability)
         {
             return(EventStatus.Not_Handled_Probability);
         }
     }
     if (_postCountMax > 0)
     {
         if (_postCount >= _postCountMax)
         {
             return(EventStatus.Not_Handled_PostCountMax);
         }
         _postCount++;
     }
     if (_ignoreIncomingGameObject)
     {
         zEvent.parentGameObject = FabricManager.Instance.gameObject;
     }
     if (_delay == 0f)
     {
         return(ProcessEvent(zEvent));
     }
     _eventQueue.Add(zEvent);
     zEvent._delay      = _delay;
     zEvent._delayTimer = 0f;
     return(EventStatus.InQueue);
 }
 public EventStatus ProcessEvent(Fabric.Event zEvent)
 {
     _runtimeEvent.Copy(_event);
     _runtimeEvent.parentGameObject = zEvent.parentGameObject;
     _runtimeEvent._eventName       = zEvent._eventName;
     if (_ignoreEventAction)
     {
         _runtimeEvent.Copy(zEvent);
         _runtimeEvent.EventAction = zEvent.EventAction;
     }
     else
     {
         if (zEvent._forceEventAction)
         {
             _runtimeEvent.EventAction = zEvent.EventAction;
         }
         BuildEvent();
     }
     if (_runtimeEvent.EventAction == EventAction.SetGlobalParameter || _runtimeEvent.EventAction == EventAction.SetGlobalSwitch || _runtimeEvent.EventAction == EventAction.AddPreset || _runtimeEvent.EventAction == EventAction.RemovePreset || _runtimeEvent.EventAction == EventAction.SwitchPreset || _runtimeEvent.EventAction == EventAction.ResetDynamicMixer || _runtimeEvent.EventAction == EventAction.TransitionToSnapshot || _runtimeEvent.EventAction == EventAction.LoadAudioMixer || _runtimeEvent.EventAction == EventAction.UnloadAudioMixer || _runtimeEvent.EventAction == EventAction.MicStart || _runtimeEvent.EventAction == EventAction.MicStop)
     {
         EventManager.Instance.ProcessEvent(_runtimeEvent);
     }
     else if (_component != null)
     {
         _runtimeEvent.eventStatus = ((IEventListener)_component).Process(_runtimeEvent);
     }
     if (Application.isEditor && _runtimeEvent.eventStatus != EventStatus.Not_Handled && _runtimeEvent.EventAction == EventAction.PlaySound)
     {
         EventManager.Instance.AddActiveEvent(_runtimeEvent, _component);
     }
     zEvent.Copy(_runtimeEvent);
     return(_runtimeEvent.eventStatus);
 }
Exemple #3
0
    EventStatus IEventListener.Process(Fabric.Event zEvent)
    {
        switch (zEvent.EventAction)
        {
        case EventAction.AddPreset:
            AddPreset((string)zEvent._parameter);
            break;

        case EventAction.RemovePreset:
            RemovePreset((string)zEvent._parameter);
            break;

        case EventAction.ResetDynamicMixer:
            Reset();
            break;

        case EventAction.SwitchPreset:
        {
            SwitchPresetData switchPresetData = (SwitchPresetData)zEvent._parameter;
            if (switchPresetData != null)
            {
                if (switchPresetData._sourcePreset.Length > 0)
                {
                    SwitchPreset(switchPresetData._sourcePreset, switchPresetData._targetPreset);
                }
                else
                {
                    SwitchPreset(_currentSwitchedPreset, switchPresetData._targetPreset);
                }
            }
            break;
        }
        }
        return(EventStatus.Handled);
    }
    public bool ProcessEvent(Fabric.Event postedEvent)
    {
        EventSequencerEntry eventSequencerEntry = _sequenceEntries.FindItem(postedEvent._eventName);

        if (eventSequencerEntry != null)
        {
            eventSequencerEntry.ProcessEvent(postedEvent);
            return(true);
        }
        return(false);
    }
    EventStatus IEventListener.Process(Fabric.Event zEvent)
    {
        if (_audioMixers.Count == 0)
        {
            return(EventStatus.Not_Handled);
        }
        switch (zEvent.EventAction)
        {
        case EventAction.LoadAudioMixer:
        {
            UnityEngine.Audio.AudioMixer audioMixer3 = Resources.Load((string)zEvent._parameter) as UnityEngine.Audio.AudioMixer;
            if (audioMixer3 != null)
            {
                _audioMixers.Add(audioMixer3);
            }
            break;
        }

        case EventAction.UnloadAudioMixer:
        {
            UnityEngine.Audio.AudioMixer audioMixer2 = _audioMixers.Find((UnityEngine.Audio.AudioMixer x) => x.name.Contains((string)zEvent._parameter));
            if (audioMixer2 != null)
            {
                _audioMixers.Remove(audioMixer2);
                Resources.UnloadAsset(audioMixer2);
            }
            break;
        }

        case EventAction.TransitionToSnapshot:
        {
            TransitionToSnapshotData transitionToSnapshotData = (TransitionToSnapshotData)zEvent._parameter;
            if (transitionToSnapshotData == null)
            {
                break;
            }
            for (int i = 0; i < _audioMixers.Count; i++)
            {
                UnityEngine.Audio.AudioMixer audioMixer = _audioMixers[i];
                if (audioMixer != null)
                {
                    AudioMixerSnapshot audioMixerSnapshot = audioMixer.FindSnapshot(transitionToSnapshotData._snapshot);
                    if (audioMixerSnapshot != null)
                    {
                        audioMixerSnapshot.TransitionTo(transitionToSnapshotData._timeToReach);
                    }
                }
            }
            break;
        }
        }
        return(EventStatus.Handled);
    }
 public void ProcessEvent(Fabric.Event postedEvent)
 {
     if (postedEvent.EventAction == EventAction.PlaySound || postedEvent.EventAction == EventAction.PlayScheduled)
     {
         postedEvent._onEventNotify = OnEventNotify;
         _stopping = false;
     }
     else if (postedEvent.EventAction == EventAction.StopSound)
     {
         EventManager.Instance.PostEvent(events[CurrentIndex()].eventName, EventAction.StopSound, _gameObject);
         _stopping = true;
     }
     _gameObject = postedEvent.parentGameObject;
 }
        private EventStatus ProcessEvent(Fabric.Event zEvent)
        {
            EventStatus result = EventStatus.Not_Handled;

            for (int i = 0; i < _eventList.Count; i++)
            {
                EventStatus eventStatus = _eventList[i].ProcessEvent(zEvent);
                if (eventStatus != EventStatus.Not_Handled)
                {
                    result = EventStatus.Handled;
                }
            }
            return(result);
        }
Exemple #8
0
 public void Copy(Fabric.Event fromEvent)
 {
     _eventName            = fromEvent._eventName;
     EventAction           = fromEvent.EventAction;
     eventStatus           = fromEvent.eventStatus;
     parentGameObject      = fromEvent.parentGameObject;
     _parameter            = fromEvent._parameter;
     _delay                = fromEvent._delay;
     _delayTimer           = fromEvent._delayTimer;
     _initialiseParameters = fromEvent._initialiseParameters;
     _onEventNotify        = fromEvent._onEventNotify;
     _eventCategory        = fromEvent._eventCategory;
     _priority             = fromEvent._priority;
 }
 public void Update()
 {
     for (int i = 0; i < _eventQueue.Count; i++)
     {
         Fabric.Event @event = _eventQueue[i];
         if (@event._delayTimer < @event._delay)
         {
             @event._delayTimer += FabricTimer.GetRealtimeDelta();
             continue;
         }
         ProcessEvent(@event);
         @event._delay      = 0f;
         @event._delayTimer = 0f;
         @event.eventStatus = EventStatus.Handled;
         _eventQueue.RemoveAt(i);
     }
 }
Exemple #10
0
    public override EventStatus OnProcessEvent(Fabric.Event zEvent, ComponentInstance zInstance)
    {
        EventStatus result = EventStatus.Failed_Uknown;

        if (zEvent.EventAction == EventAction.SetSwitch)
        {
            if (_switchComponentSwitchType == SwitchComponentSwitchType.OnSwitch)
            {
                List <ComponentInstance> list = FindInstances(zEvent.parentGameObject, createIfNoneFound: false);
                if (list != null && list.Count > 0)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        ComponentInstance componentInstance = list[i];
                        ((SwitchComponent)componentInstance._instance).SetSwitch((string)zEvent._parameter);
                        result = EventStatus.Handled;
                    }
                }
                else
                {
                    SetSwitch((string)zEvent._parameter);
                    result = EventStatus.Handled;
                }
            }
            else
            {
                List <ComponentInstance> list2 = FindInstances(zEvent.parentGameObject, createIfNoneFound: false);
                if (list2 != null && list2.Count > 0)
                {
                    for (int j = 0; j < list2.Count; j++)
                    {
                        ComponentInstance componentInstance2 = list2[j];
                        ((SwitchComponent)componentInstance2._instance).SetDefferedSwitch((string)zEvent._parameter);
                        result = EventStatus.Handled;
                    }
                }
                else
                {
                    SetDefferedSwitch((string)zEvent._parameter);
                    result = EventStatus.Handled;
                }
            }
        }
        return(result);
    }
    public override EventStatus OnProcessEvent(Fabric.Event zEvent, ComponentInstance zInstance)
    {
        EventStatus result = EventStatus.Failed_Uknown;

        if (zEvent.EventAction == EventAction.SetAudioClipReference)
        {
            List <ComponentInstance> list = FindInstances(zEvent.parentGameObject, createIfNoneFound: false);
            if (list != null && list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    ComponentInstance componentInstance = list[i];
                    ((DialogAudioComponent)componentInstance._instance).SetAudioClipReference((string)zEvent._parameter);
                    result = EventStatus.Handled;
                }
            }
            else
            {
                SetAudioClipReference((string)zEvent._parameter);
                result = EventStatus.Handled;
            }
        }
        return(result);
    }
 public EventStatus ProcessEvent(Fabric.Event zEvent)
 {
     return(EventStatus.Not_Handled);
 }
    public override EventStatus OnProcessEvent(Fabric.Event zEvent, ComponentInstance zInstance)
    {
        EventStatus result = EventStatus.Failed_Uknown;

        if (zEvent.EventAction == EventAction.AdvanceSequence && _sequenceType == SequenceComponentType.PlayOnAdvance)
        {
            List <ComponentInstance> list = null;
            if (_syncAdvanceBetweenInstances)
            {
                list = new List <ComponentInstance>(_componentInstances.Length);
                for (int i = 0; i < _componentInstances.Length; i++)
                {
                    list.Add(_componentInstances[i]);
                }
            }
            else
            {
                list = FindInstances(zEvent.parentGameObject, createIfNoneFound: false);
            }
            if (list != null && list.Count > 0)
            {
                for (int j = 0; j < list.Count; j++)
                {
                    ComponentInstance componentInstance = list[j];
                    if (!((SequenceComponent)componentInstance._instance)._stopInProgress)
                    {
                        if ((_playlistPlayToEnd[_prevPlayingComponentIndex] || IsMusicSyncEnabled()) && _currentlyPlayingComponent != null && _currentlyPlayingComponent.IsPlaying())
                        {
                            ((SequenceComponent)componentInstance._instance)._advanceEventTriggered = true;
                            continue;
                        }
                        ((SequenceComponent)componentInstance._instance).PlayNextEntry();
                        result = EventStatus.Handled;
                        if (HasValidEventNotifier())
                        {
                            NotifyEvent(EventNotificationType.OnSequenceAdvance, _currentlyPlayingComponent);
                        }
                    }
                    else
                    {
                        result = EventStatus.Not_Handled_Stopped;
                    }
                }
            }
            else
            {
                PlayNextEntry();
                result = EventStatus.Handled;
            }
        }
        else if (zEvent.EventAction == EventAction.ResetSequence)
        {
            List <ComponentInstance> list2 = FindInstances(zEvent.parentGameObject, createIfNoneFound: false);
            if (list2 != null && list2.Count > 0)
            {
                for (int k = 0; k < list2.Count; k++)
                {
                    ComponentInstance componentInstance2 = list2[k];
                    ((SequenceComponent)componentInstance2._instance).ResetSequence();
                    result = EventStatus.Handled;
                }
            }
            else
            {
                ResetSequence();
                result = EventStatus.Handled;
            }
        }
        return(result);
    }