Пример #1
0
    private void Start()
    {
        this.bounds = new Bounds(base.transform.TransformPoint(this.points[0]), Vector3.zero);
        this.points.ForEach(delegate(Vector3 point)
        {
            this.bounds.Encapsulate(base.transform.TransformPoint(point));
        });
        int capacity = (!this.loop) ? (this.points.Count - 1) : this.points.Count;

        this.segments        = new List <LinearEmitter.Segment>(capacity);
        this.segmentFlags    = new List <LinearEmitter.SegmentFlags>(capacity);
        this.audibleSegments = new List <int>();
        this.ForEachSegment(delegate(Vector3 start, Vector3 end)
        {
            LinearEmitter.Segment item;
            item.start        = base.transform.TransformPoint(start);
            item.delta        = base.transform.TransformPoint(end) - item.start;
            item.length       = item.delta.magnitude;
            item.sqrDistance  = 0f;
            item.closestPoint = Vector3.zero;
            item.closestT     = 0f;
            this.segments.Add(item);
            this.segmentFlags.Add(LinearEmitter.SegmentFlags.None);
        });
        if (FMOD_StudioSystem.instance)
        {
            this.eventDescription = FMOD_StudioSystem.instance.GetEventDescription(this.eventPath);
        }
        if (this.eventDescription == null || !FMOD_StudioSystem.instance)
        {
            base.enabled = false;
        }
        else
        {
            float num;
            UnityUtil.ERRCHECK(this.eventDescription.getMaximumDistance(out num));
            this.sqrEventMaximumDistance = num * num;
            this.windParameterIndex      = FMODCommon.FindParameterIndex(this.eventDescription, "wind");
            this.rainParameterIndex      = FMODCommon.FindParameterIndex(this.eventDescription, "rain");
            this.compareSources          = ((LinearEmitter.Source a, LinearEmitter.Source b) => Math.Sign(this.segments[a.segment].sqrDistance - this.segments[b.segment].sqrDistance));
            if (this.parameters != null)
            {
                for (int i = 0; i < this.parameters.Count; i++)
                {
                    LinearEmitter.ParameterInfo value = this.parameters[i];
                    value.index        = FMODCommon.FindParameterIndex(this.eventDescription, this.parameters[i].name);
                    this.parameters[i] = value;
                }
            }
            this.CreateGrid(num);
        }
    }
Пример #2
0
 public void Activate()
 {
     LinearEmitter.sAwaitingBankLoad.Remove(this);
     if (this.isActive)
     {
         return;
     }
     if (string.IsNullOrEmpty(this.eventPath))
     {
         UnityEngine.Debug.LogError("No event path specified for Linear Emitter", this);
         return;
     }
     this.eventDescription = null;
     if (FMOD_StudioSystem.instance)
     {
         RESULT @event = FMOD_StudioSystem.instance.System.getEvent(this.eventPath, out this.eventDescription);
         if (@event != RESULT.ERR_EVENT_NOTFOUND)
         {
             UnityUtil.ERRCHECK(@event);
         }
     }
     if (this.eventDescription == null)
     {
         LinearEmitter.sAwaitingBankLoad.Add(this);
     }
     else
     {
         float num;
         UnityUtil.ERRCHECK(this.eventDescription.getMaximumDistance(out num));
         this.sqrEventMaximumDistance = num * num;
         this.windParameterIndex      = FMODCommon.FindParameterIndex(this.eventDescription, "wind");
         this.rainParameterIndex      = FMODCommon.FindParameterIndex(this.eventDescription, "rain");
         this.compareSources          = ((LinearEmitter.Source a, LinearEmitter.Source b) => Math.Sign(this.segments[a.segment].sqrDistance - this.segments[b.segment].sqrDistance));
         if (this.parameters != null)
         {
             for (int i = 0; i < this.parameters.Count; i++)
             {
                 LinearEmitter.ParameterInfo value = this.parameters[i];
                 value.index        = FMODCommon.FindParameterIndex(this.eventDescription, this.parameters[i].name);
                 this.parameters[i] = value;
             }
         }
         this.CreateGrid(num);
         this.isActive = true;
     }
 }