示例#1
0
    private void Start()
    {
        if (FMOD_StudioSystem.instance)
        {
            this.eventDescription = FMOD_StudioSystem.instance.GetEventDescription(this.eventPath);
        }
        if (this.eventDescription == null)
        {
            base.enabled = false;
            return;
        }
        float num;

        UnityUtil.ERRCHECK(this.eventDescription.getMaximumDistance(out num));
        this.sqrEventMaximumDistance = num * num;
        this.windParameterIndex      = FMODCommon.FindParameterIndex(this.eventDescription, "wind");
        this.compareSources          = delegate(AreaEmitter.Source a, AreaEmitter.Source b)
        {
            float sqrDistance  = a.polygon.GetSegment(a.segment).sqrDistance;
            float sqrDistance2 = b.polygon.GetSegment(b.segment).sqrDistance;
            return(Math.Sign(sqrDistance - sqrDistance2));
        };
        this.inverseTransformDelegate = new Func <Vector3, Vector2>(this.InverseTransformPoint);
        this.bounds = new Bounds(this.TransformPoint(this.perimeter.points[0]), Vector3.zero);
        this.perimeter.points.ForEach(delegate(Vector2 point)
        {
            this.bounds.Encapsulate(this.TransformPoint(point));
        });
        for (int i = -1; i < this.voids.Count; i++)
        {
            this.GetPolygon(i).Start(num, new Func <Vector2, Vector3>(this.TransformPoint));
        }
    }
示例#2
0
 private void Start()
 {
     if (!SteamDSConfig.isDedicatedServer)
     {
         this.eventDescription       = FMOD_StudioSystem.instance.GetEventDescription("event:/ambient/water/water_runoff", true);
         this.gradientParameterIndex = FMODCommon.FindParameterIndex(this.eventDescription, "gradient");
         this.wetnessParameterIndex  = FMODCommon.FindParameterIndex(this.eventDescription, "wetness");
         UnityUtil.ERRCHECK(this.eventDescription.getMaximumDistance(out this.gridCellSize));
         this.gridCellSize /= 10f;
         int num = this.targetSourceCount - 1;
         this.sampleGrid   = new WaterOnTerrainSFX.GridCell[21, 21];
         this.sources      = new List <WaterOnTerrainSFX.Source>(num);
         this.sourcePool   = new Stack <WaterOnTerrainSFX.Source>(num);
         this.centreSource = new WaterOnTerrainSFX.Source();
         for (int i = 0; i < num; i++)
         {
             this.sourcePool.Push(new WaterOnTerrainSFX.Source());
         }
         FMOD_Listener.DrawWaterOnTerrain = new Action(this.DrawDebug);
     }
     else
     {
         base.enabled = false;
     }
 }
示例#3
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);
        }
    }
示例#4
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;
     }
 }
示例#5
0
    private void OnEnable()
    {
        TreeWindSfxManager.Add(this);
        EventDescription eventDescription = FMOD_StudioSystem.instance.GetEventDescription(this.EventPath);

        if (eventDescription != null)
        {
            if (this.WindParameterIndex == -1)
            {
                this.WindParameterIndex = FMODCommon.FindParameterIndex(eventDescription, "wind");
            }
            if (this.SizeParameterIndex == -1)
            {
                this.SizeParameterIndex = FMODCommon.FindParameterIndex(eventDescription, "size");
            }
            if (this.TimeParameterIndex == -1)
            {
                this.TimeParameterIndex = FMODCommon.FindParameterIndex(eventDescription, "time");
            }
        }
    }