コード例 #1
0
    private void UpdateSources()
    {
        this.sources.Sort(this.compareSources);
        int i = 0;

        while (i < this.sources.Count)
        {
            LinearEmitter.Source source = this.sources[i];
            int num = this.DescendToClosestSegment(source.segment);
            if (this.IsSegmentOccluded(num))
            {
                num = this.AscendToAudibleSegment(source.segment);
            }
            if (!this.IsSegmentOccluded(num))
            {
                source.segment = num;
            }
            LinearEmitter.Segment segment = this.segments[source.segment];
            if (this.IsSegmentOccluded(source.segment) || segment.sqrDistance > this.sqrEventMaximumDistance)
            {
                UnityUtil.ERRCHECK(source.eventInstance.stop(STOP_MODE.ALLOWFADEOUT));
                UnityUtil.ERRCHECK(source.eventInstance.release());
                this.sources.RemoveAt(i);
            }
            else
            {
                Vector3 vector       = segment.closestPoint - source.position;
                float   sqrMagnitude = vector.sqrMagnitude;
                float   num2         = this.sourceSpeed * Time.deltaTime;
                if (num2 * num2 >= sqrMagnitude)
                {
                    source.position = segment.closestPoint;
                }
                else
                {
                    source.position += vector.normalized * num2;
                }
                this.UpdateSource(source);
                this.sources[i] = source;
                i++;
            }
        }
        while (this.sources.Count < this.maximumSourceCount)
        {
            int num3 = this.FindClosestAudibleSegment();
            if (num3 < 0 || this.segments[num3].sqrDistance > this.sqrEventMaximumDistance)
            {
                break;
            }
            LinearEmitter.Source source2;
            source2.segment  = num3;
            source2.position = this.segments[num3].closestPoint;
            UnityUtil.ERRCHECK(this.eventDescription.createInstance(out source2.eventInstance));
            this.UpdateSource(source2);
            UnityUtil.ERRCHECK(source2.eventInstance.start());
            this.sources.Add(source2);
        }
    }
コード例 #2
0
 private void SetSourceParameterValues(LinearEmitter.Source source)
 {
     if (this.parameters != null)
     {
         float closestT = this.segments[source.segment].closestT;
         int   segment  = source.segment;
         int   index    = (source.segment + 1) % this.points.Count;
         for (int i = 0; i < this.parameters.Count; i++)
         {
             if (this.parameters[i].index >= 0)
             {
                 float num   = this.parameters[i].values[segment];
                 float num2  = this.parameters[i].values[index];
                 float value = num + (num2 - num) * closestT;
                 UnityUtil.ERRCHECK(source.eventInstance.setParameterValueByIndex(this.parameters[i].index, value));
             }
         }
     }
 }
コード例 #3
0
ファイル: LinearEmitter.cs プロジェクト: K07H/The-Forest
 private void UpdateSource(LinearEmitter.Source source)
 {
     this.OccludeSegments(source);
     FMOD.Studio.ATTRIBUTES_3D attributes;
     attributes.position = source.position.toFMODVector();
     attributes.forward  = base.transform.forward.toFMODVector();
     attributes.up       = base.transform.up.toFMODVector();
     attributes.velocity = Vector3.zero.toFMODVector();
     UnityUtil.ERRCHECK(source.eventInstance.set3DAttributes(attributes));
     if (this.windParameterIndex >= 0 && TheForestAtmosphere.Instance != null)
     {
         UnityUtil.ERRCHECK(source.eventInstance.setParameterValueByIndex(this.windParameterIndex, TheForestAtmosphere.Instance.WindIntensity));
     }
     if (this.rainParameterIndex >= 0)
     {
         UnityUtil.ERRCHECK(source.eventInstance.setParameterValueByIndex(this.rainParameterIndex, (!Scene.WeatherSystem.Raining) ? 0f : 1f));
     }
     this.SetSourceParameterValues(source);
 }
コード例 #4
0
    private void OccludeSegments(LinearEmitter.Source occluder)
    {
        if (this.audibleSegments.Count == 0)
        {
            return;
        }
        Vector3 closestPoint = this.segments[occluder.segment].closestPoint;
        Vector3 v            = closestPoint - LocalPlayer.Transform.position;
        float   sqrMagnitude = v.sqrMagnitude;

        v.y = 0f;
        float   num  = -45f;
        Vector3 rhs  = v.RotateY(num);
        Vector3 rhs2 = v.RotateY(-num);
        int     i    = 0;

        while (i < this.audibleSegments.Count)
        {
            int index = this.audibleSegments[i];
            LinearEmitter.Segment segment = this.segments[index];
            bool flag = false;
            if (segment.sqrDistance >= sqrMagnitude)
            {
                Vector3 lhs = segment.closestPoint - LocalPlayer.Transform.position;
                lhs.y = 0f;
                if (Vector3.Dot(lhs, rhs) >= 0f && Vector3.Dot(lhs, rhs2) >= 0f)
                {
                    this.SetSegmentOccluded(index, true);
                    int index2 = this.audibleSegments.Count - 1;
                    this.audibleSegments[i] = this.audibleSegments[index2];
                    this.audibleSegments.RemoveAt(index2);
                    flag = true;
                }
            }
            if (!flag)
            {
                i++;
            }
        }
    }