Esempio n. 1
0
 public override bool UpdateInternal(ref Context context)
 {
     if (_looped && _playMode == RandomComponentPlayMode.RandomNoRepeat && _triggerMode == RandomComponentTriggerMode.Retrigger)
     {
         float realtimeDelta = FabricTimer.GetRealtimeDelta();
         _retriggerTimer += realtimeDelta;
         if (_retriggerTimer >= _retriggerTime)
         {
             _componentInstance._instance.SetPlayScheduled(_retriggerTimer - _retriggerTime, 0.0);
             PlayRandomomponent(_componentInstance);
             _retriggerTime  = _delay + UnityEngine.Random.Range(_delayRandomization, _delayMaxRandomization);
             _retriggerTimer = 0f;
         }
     }
     return(base.UpdateInternal(ref context));
 }
Esempio n. 2
0
 public void UpdateInternal()
 {
     profiler.Begin();
     for (int i = 0; i < _eventQueue.Count; i++)
     {
         Event @event = _eventQueue[i];
         if (@event.parentGameObject == null)
         {
             _eventQueue.RemoveAt(i);
         }
         else if (@event._delayTimer < @event._delay)
         {
             @event._delayTimer += FabricTimer.GetRealtimeDelta();
         }
         else if (ProcessEvent(@event))
         {
             _eventQueue.RemoveAt(i);
         }
     }
     _eventEditor.Update();
     _globalParameterManager.Update();
     if (Application.isEditor)
     {
         for (int j = 0; j < _activeEvents.Count; j++)
         {
             ActiveEvent activeEvent = _activeEvents[j];
             if (activeEvent._component == null || !activeEvent._component.IsComponentActive())
             {
                 if (activeEvent._time == 0f)
                 {
                     activeEvent._time = _activeEventPersistenceTime;
                 }
                 else
                 {
                     activeEvent._time -= FabricTimer.GetRealtimeDelta();
                 }
                 if (activeEvent._time <= 0f)
                 {
                     _activeEvents.Remove(activeEvent);
                     activeEvent._time = 0f;
                 }
             }
         }
     }
     profiler.End();
 }
Esempio n. 3
0
 public void Update()
 {
     for (int i = 0; i < _eventQueue.Count; i++)
     {
         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);
     }
 }
Esempio n. 4
0
        public void Update()
        {
            float realtimeDelta = FabricTimer.GetRealtimeDelta();

            if (_direction > 0f)
            {
                _seekTarget += _velocity * realtimeDelta;
            }
            else
            {
                _seekTarget -= _velocity * realtimeDelta;
            }
            _markers.Update(_seekTarget, _direction);
            if (_markers.IsMarkerKeyOff())
            {
                _seekTarget = _markers._keyOffMarker._value;
            }
            if (_velocity != 0f)
            {
                if (_seekTarget > MAX_NORMALISED_RANGE)
                {
                    if (_loopBehaviour == ParameterLoopBehaviour.Loop)
                    {
                        _seekTarget -= MAX_NORMALISED_RANGE - MIN_NORMALISED_RANGE;
                    }
                    else if (_loopBehaviour == ParameterLoopBehaviour.OneShot)
                    {
                        _seekTarget = MAX_NORMALISED_RANGE;
                    }
                    else if (_loopBehaviour == ParameterLoopBehaviour.PingPong)
                    {
                        _direction = -1f;
                    }
                    else
                    {
                        _seekTarget = MAX_NORMALISED_RANGE;
                    }
                    _markers.Reset();
                }
                else if (_seekTarget < MIN_NORMALISED_RANGE)
                {
                    if (_loopBehaviour == ParameterLoopBehaviour.Loop)
                    {
                        _seekTarget += MAX_NORMALISED_RANGE - MIN_NORMALISED_RANGE;
                    }
                    else if (_loopBehaviour == ParameterLoopBehaviour.OneShot)
                    {
                        _seekTarget = MIN_NORMALISED_RANGE;
                    }
                    else if (_loopBehaviour == ParameterLoopBehaviour.PingPong)
                    {
                        _direction = 1f;
                    }
                    else
                    {
                        _seekTarget = MIN_NORMALISED_RANGE;
                    }
                    _markers.Reset();
                }
                if (_seekTarget > MAX_NORMALISED_RANGE)
                {
                    _seekTarget = MAX_NORMALISED_RANGE;
                }
                else if (_seekTarget < MIN_NORMALISED_RANGE)
                {
                    _seekTarget = MIN_NORMALISED_RANGE;
                }
            }
            if (_seekSpeed != 0f)
            {
                float num = _seekSpeed * realtimeDelta;
                if (_seekTarget > _value)
                {
                    _value += num;
                    if (_value > _seekTarget)
                    {
                        _value = _seekTarget;
                    }
                }
                else if (_seekTarget < _value)
                {
                    _value -= num;
                    if (_value < _seekTarget)
                    {
                        _value = _seekTarget;
                    }
                }
            }
            else
            {
                _value = _seekTarget;
            }
            AudioTools.Limit(ref _value, 0f, 1f);
        }
Esempio n. 5
0
 public void Update(Component component)
 {
     if (_parameters == null)
     {
         return;
     }
     for (int i = 0; i < _cachedValues.Length; i++)
     {
         _cachedValues[i] = 1f;
     }
     for (int j = 0; j < _parameters.Length; j++)
     {
         RTPParameterToProperty rTPParameterToProperty = _parameters[j];
         rTPParameterToProperty._parameter.Update();
         float num = 1f;
         _ = rTPParameterToProperty._property._min;
         _ = rTPParameterToProperty._property._max;
         if (rTPParameterToProperty._type == RTPParameterType.Distance || rTPParameterToProperty._parameter.Name == "Distance")
         {
             _ = 1f / (rTPParameterToProperty._parameter._max - rTPParameterToProperty._parameter._min);
             if (component.ParentGameObject != null)
             {
                 if (FabricManager.Instance._audioListener != null)
                 {
                     num = Vector3.Distance(component.ParentGameObject.transform.position, FabricManager.Instance._audioListener.transform.position);
                 }
                 else if (Camera.main != null)
                 {
                     num = Vector3.Distance(component.ParentGameObject.transform.position, Camera.main.transform.position);
                 }
                 rTPParameterToProperty._parameter.SetValue(num);
                 num = CalculateNewValue(rTPParameterToProperty, rTPParameterToProperty._parameter.GetCurrentValue());
             }
         }
         else if (rTPParameterToProperty._type == RTPParameterType.Modulator)
         {
             RTPModulator rtpModulator = rTPParameterToProperty._rtpModulator;
             if (rtpModulator != null)
             {
                 num = rtpModulator.GetValue(Time.time);
                 rTPParameterToProperty._parameter.SetValue(num);
                 num = CalculateNewValue(rTPParameterToProperty, rTPParameterToProperty._parameter.GetCurrentValue());
             }
         }
         else if (rTPParameterToProperty._type == RTPParameterType.Listener_Angle)
         {
             if (component.ParentGameObject != null)
             {
                 Vector3 from = default(Vector3);
                 Vector3 to   = default(Vector3);
                 if (FabricManager.Instance._audioListener != null)
                 {
                     from = Vector3.forward;
                     to   = FabricManager.Instance._audioListener.transform.forward;
                 }
                 else if (Camera.main != null)
                 {
                     from = Vector3.forward;
                     to   = Camera.main.transform.forward;
                 }
                 num = Vector3.Angle(from, to);
                 rTPParameterToProperty._parameter.SetValue(num);
                 num = CalculateNewValue(rTPParameterToProperty, rTPParameterToProperty._parameter.GetCurrentValue());
             }
         }
         else if (rTPParameterToProperty._type == RTPParameterType.Component_Angle)
         {
             if (component.ParentGameObject != null)
             {
                 Vector3 from2 = default(Vector3);
                 Vector3 to2   = default(Vector3);
                 if (FabricManager.Instance._audioListener != null)
                 {
                     from2 = component.ParentGameObject.transform.position - FabricManager.Instance._audioListener.transform.position;
                     to2   = component.ParentGameObject.transform.forward;
                 }
                 else if (Camera.main != null)
                 {
                     from2 = component.ParentGameObject.transform.position - Camera.main.transform.position;
                     to2   = component.ParentGameObject.transform.forward;
                 }
                 num = Vector3.Angle(from2, to2);
                 rTPParameterToProperty._parameter.SetValue(num);
                 num = CalculateNewValue(rTPParameterToProperty, rTPParameterToProperty._parameter.GetCurrentValue());
             }
         }
         else if (rTPParameterToProperty._type == RTPParameterType.Component_Velocity)
         {
             if (component.ParentGameObject != null)
             {
                 num = (component.ParentGameObject.transform.position - rTPParameterToProperty._previousPosition).magnitude / FabricTimer.GetRealtimeDelta();
                 rTPParameterToProperty._parameter.SetValue(num);
                 num = CalculateNewValue(rTPParameterToProperty, rTPParameterToProperty._parameter.GetCurrentValue());
                 rTPParameterToProperty._previousPosition = component.ParentGameObject.transform.position;
             }
         }
         else if (rTPParameterToProperty._type == RTPParameterType.Listener_Velocity)
         {
             if (FabricManager.Instance._audioListener != null)
             {
                 num = (FabricManager.Instance._audioListener.transform.position - rTPParameterToProperty._previousPosition).magnitude / FabricTimer.GetRealtimeDelta();
                 rTPParameterToProperty._previousPosition = FabricManager.Instance._audioListener.transform.position;
             }
             else if (Camera.main != null)
             {
                 num = (Camera.main.transform.position - rTPParameterToProperty._previousPosition).magnitude / FabricTimer.GetRealtimeDelta();
                 rTPParameterToProperty._previousPosition = Camera.main.transform.position;
             }
             rTPParameterToProperty._parameter.SetValue(num);
             num = CalculateNewValue(rTPParameterToProperty, rTPParameterToProperty._parameter.GetCurrentValue());
         }
         else if (rTPParameterToProperty._type == RTPParameterType.Volume_Meter)
         {
             VolumeMeter volumeMeter = rTPParameterToProperty._volumeMeter;
             if (volumeMeter != null)
             {
                 num = volumeMeter.volumeMeterState.mRMS;
                 rTPParameterToProperty._parameter.SetValue(num);
                 num = CalculateNewValue(rTPParameterToProperty, rTPParameterToProperty._parameter.GetCurrentValue());
             }
         }
         else if (rTPParameterToProperty._type == RTPParameterType.Global_Parameter)
         {
             GlobalParameter globalParameter = EventManager.Instance._globalParameterManager._globalRTParameters.FindItem(rTPParameterToProperty._globalParameterName);
             if (globalParameter != null)
             {
                 rTPParameterToProperty._parameter._max = globalParameter._max;
                 rTPParameterToProperty._parameter._min = globalParameter._min;
                 rTPParameterToProperty._parameter.SetValue(globalParameter.GetCurrentValue());
                 num = CalculateNewValue(rTPParameterToProperty, rTPParameterToProperty._parameter.GetCurrentValue());
             }
         }
         else if (rTPParameterToProperty._type == RTPParameterType.Custom_Parameter)
         {
             ICustomRTPParameter customRTPParameter = FabricManager.Instance._customRTPParameter;
             if (customRTPParameter != null)
             {
                 num = customRTPParameter.UpdateProperty(component, rTPParameterToProperty._property, rTPParameterToProperty._propertyType);
                 num = CalculateNewValue(rTPParameterToProperty, num);
                 rTPParameterToProperty._parameter.SetValue(num);
             }
         }
         else if (rTPParameterToProperty._type == RTPParameterType.Max_Instances)
         {
             num = ((!(component.ComponentHolder != null)) ? 0f : ((float)component.ComponentHolder.GetNumActiveComponentInstances() / (float)component.MaxInstances));
             num = CalculateNewValue(rTPParameterToProperty, num);
             rTPParameterToProperty._parameter.SetValue(num);
         }
         else
         {
             num = CalculateNewValue(rTPParameterToProperty, rTPParameterToProperty._parameter.GetCurrentValue());
         }
         rTPParameterToProperty._property._value = num;
         if ((object)component != null)
         {
             _ = rTPParameterToProperty._property._property;
             _cachedValues[rTPParameterToProperty._property._property] *= num;
             ((IRTPPropertyListener)component).UpdateProperty(rTPParameterToProperty._property, _cachedValues[rTPParameterToProperty._property._property], rTPParameterToProperty._propertyType);
         }
     }
 }