private void AddTimedInstance(Polluter p, float time)
    {
        NoiseSplat noiseSplat = new NoiseSplat(p, time + Time.time);

        p.SetSplat(noiseSplat);
        removeTime.Add(new Pair <float, NoiseSplat>(time + Time.time, noiseSplat));
    }
    public static string GetLoudestNoisePolluterAtCell(int cell)
    {
        float             num               = float.NegativeInfinity;
        string            result            = null;
        AudioEventManager audioEventManager = Get();
        Vector2I          vector2I          = Grid.CellToXY(cell);
        Vector2           pos               = new Vector2((float)vector2I.x, (float)vector2I.y);
        IEnumerator       enumerator        = audioEventManager.spatialSplats.GetAllIntersecting(pos).GetEnumerator();

        try
        {
            while (enumerator.MoveNext())
            {
                NoiseSplat noiseSplat = (NoiseSplat)enumerator.Current;
                float      loudness   = noiseSplat.GetLoudness(cell);
                if (loudness > num)
                {
                    result = noiseSplat.GetProvider().GetName();
                }
            }
            return(result);
        }
        finally
        {
            IDisposable disposable;
            if ((disposable = (enumerator as IDisposable)) != null)
            {
                disposable.Dispose();
            }
        }
    }
    private void RemoveExpiredSplats()
    {
        if (removeTime.Count > 1)
        {
            removeTime.Sort((Pair <float, NoiseSplat> a, Pair <float, NoiseSplat> b) => a.first.CompareTo(b.first));
        }
        int num = -1;

        for (int i = 0; i < removeTime.Count; i++)
        {
            Pair <float, NoiseSplat> pair = removeTime[i];
            if (pair.first > Time.time)
            {
                break;
            }
            Pair <float, NoiseSplat> pair2 = removeTime[i];
            NoiseSplat second = pair2.second;
            if (second != null)
            {
                IPolluter provider = second.GetProvider();
                FreePolluter(provider as Polluter);
            }
            num = i;
        }
        for (int num2 = num; num2 >= 0; num2--)
        {
            removeTime.RemoveAt(num2);
        }
    }
    public List <PolluterDisplay> GetPollutersForCell(int cell)
    {
        polluters.Clear();
        Vector2I    vector2I   = Grid.CellToXY(cell);
        Vector2     pos        = new Vector2((float)vector2I.x, (float)vector2I.y);
        IEnumerator enumerator = spatialSplats.GetAllIntersecting(pos).GetEnumerator();

        try
        {
            while (enumerator.MoveNext())
            {
                NoiseSplat noiseSplat = (NoiseSplat)enumerator.Current;
                float      loudness   = noiseSplat.GetLoudness(cell);
                if (!(loudness <= 0f))
                {
                    PolluterDisplay item = default(PolluterDisplay);
                    item.name     = noiseSplat.GetName();
                    item.value    = LoudnessToDB(loudness);
                    item.provider = noiseSplat.GetProvider();
                    polluters.Add(item);
                }
            }
        }
        finally
        {
            IDisposable disposable;
            if ((disposable = (enumerator as IDisposable)) != null)
            {
                disposable.Dispose();
            }
        }
        return(polluters);
    }
示例#5
0
 public void Clear()
 {
     if (splat != null)
     {
         splat.Clear();
         splat = null;
     }
 }
 public void ClearNoiseSplat(NoiseSplat splat)
 {
     if (splats.Contains(splat))
     {
         splats.Remove(splat);
         spatialSplats.Remove(splat);
     }
 }
 public void Clear()
 {
     if (splat != null)
     {
         AudioEventManager.Get().ClearNoiseSplat(splat);
         splat.Clear();
         splat = null;
     }
 }
    public NoiseSplat CreateNoiseSplat(Vector2 pos, int dB, int radius, string name, GameObject go)
    {
        Polluter polluter = GetPolluter(radius);

        polluter.SetAttributes(pos, dB, go, name);
        NoiseSplat noiseSplat = new NoiseSplat(polluter, 0f);

        polluter.SetSplat(noiseSplat);
        return(noiseSplat);
    }
 public void SetSplat(NoiseSplat new_splat)
 {
     if (new_splat == null && splat != null)
     {
         Clear();
     }
     splat = new_splat;
     if (splat != null)
     {
         AudioEventManager.Get().AddSplat(splat);
     }
 }
示例#10
0
 public void Refresh()
 {
     if (active)
     {
         if (splat != null)
         {
             AudioEventManager.Get().ClearNoiseSplat(splat);
             splat.Clear();
         }
         KSelectable component  = GetComponent <KSelectable>();
         string      name       = (!((UnityEngine.Object)component != (UnityEngine.Object)null)) ? base.name : component.GetName();
         GameObject  gameObject = GetComponent <KMonoBehaviour>().gameObject;
         splat = AudioEventManager.Get().CreateNoiseSplat(GetPosition(), noise, radius, name, gameObject);
     }
 }
示例#11
0
 public void SetSplat(NoiseSplat new_splat)
 {
     splat = new_splat;
 }
 public void AddSplat(NoiseSplat splat)
 {
     splats.Add(splat);
     spatialSplats.Add(splat);
 }