예제 #1
0
        public override void Update()
        {
            int x1, x2, y1, y2;
            var intersecting = HashSetPool <Uprootable, PipPlantOverlay> .Allocate();

            base.Update();
            // SimDebugView is updated on a background thread, so since plant checking
            // must be done on the FG thread, it is updated here
            Grid.GetVisibleExtents(out Vector2I min, out Vector2I max);
            x1 = min.x; x2 = max.x;
            y1 = min.y; y2 = max.y;
            // Refresh plant list with plants on the screen
            RemoveOffscreenTargets(layerTargets, min, max, null);
            partition.GetAllIntersecting(new Vector2(x1, y1), new Vector2(x2, y2),
                                         intersecting);
            foreach (var uprootable in intersecting)
            {
                AddTargetIfVisible(uprootable, min, max, layerTargets, targetLayer);
            }
            for (int y = y1; y <= y2; y++)
            {
                for (int x = x1; x <= x2; x++)
                {
                    int cell = Grid.XYToCell(x, y);
                    if (Grid.IsValidCell(cell))
                    {
                        cells[cell] = PipPlantOverlayTests.CheckCell(cell);
                    }
                }
            }
            UpdateHighlightTypeOverlay(min, max, layerTargets, plants, conditions,
                                       OverlayModes.BringToFrontLayerSetting.Constant, targetLayer);
            intersecting.Recycle();
        }
    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);
    }