Example #1
0
        private void Mark()
        {
            for (var i = cells.Count - 1; i >= 0; i--)
            {
                D2dPool <D2dEdgeColliderCell> .Despawn(cells[i], c => c.Clear(unusedColliders));
            }

            cells.Clear();
        }
        public static void ClearTempGroups()
        {
            for (var i = TempGroups.Count - 1; i >= 0; i--)
            {
                D2dPool <D2dSplitGroup> .Despawn(TempGroups[i], j => j.Clear());
            }

            TempGroups.Clear();
        }
Example #3
0
            public void Clear()
            {
                for (var i = Pixels.Count - 1; i >= 0; i--)
                {
                    D2dPool <D2dFloodfillPixel> .Despawn(Pixels[i]);
                }

                Pixels.Clear();
            }
Example #4
0
        public static void ClearAll()
        {
            for (var i = SplitGroups.Count - 1; i >= 0; i--)
            {
                var splitGroup = SplitGroups[i];

                splitGroup.Clear();

                D2dPool <D2dSplitGroup> .Despawn(splitGroup);
            }

            SplitGroups.Clear();
        }
Example #5
0
        public void Clear()
        {
            for (var i = Pixels.Count - 1; i >= 0; i--)
            {
                D2dPool <D2dSplitPixel> .Despawn(Pixels[i]);
            }

            Data = null;

            Rect.Clear();

            Pixels.Clear();
        }
Example #6
0
        private static void Clear(List <Island> islands)
        {
            for (var i = islands.Count - 1; i >= 0; i--)
            {
                var island = islands[i];

                island.Clear();

                D2dPool <Island> .Despawn(island);
            }

            islands.Clear();
        }
Example #7
0
        public static void DespawnTempIslands(Island borderIsland = null)
        {
            if (borderIsland != null)
            {
                D2dPool <Island> .Despawn(borderIsland, j => j.Clear());
            }

            if (TempIslands.Count > 0)
            {
                for (var i = TempIslands.Count - 1; i >= 0; i--)
                {
                    D2dPool <Island> .Despawn(TempIslands[i], j => j.Clear());
                }

                TempIslands.Clear();
            }
        }
Example #8
0
        public static void DespawnTempSplitGroups(D2dSplitGroup borderGroup = null)
        {
            if (borderGroup != null)
            {
                D2dPool <D2dSplitGroup> .Despawn(borderGroup, g => g.Clear());
            }

            if (TempSplitGroups.Count > 0)
            {
                for (var i = TempSplitGroups.Count - 1; i >= 0; i--)
                {
                    D2dPool <D2dSplitGroup> .Despawn(TempSplitGroups[i], g => g.Clear());
                }

                TempSplitGroups.Clear();
            }
        }
Example #9
0
        public static void Clear()
        {
            for (var i = Islands.Count - 1; i >= 0; i--)
            {
                var island = Islands[i];

                island.Clear();

                D2dPool <Island> .Despawn(island);
            }

            for (var i = BorderIslands.Count - 1; i >= 0; i--)
            {
                var island = BorderIslands[i];

                island.Clear();

                D2dPool <Island> .Despawn(island);
            }

            Islands.Clear();
            BorderIslands.Clear();
        }
        public static void Find(byte[] newData, int newWidth, int newHeight)
        {
            width       = newWidth;
            height      = newHeight;
            total       = newWidth * newHeight;
            spreadCount = 0;

            if (cells == null || total > cells.Length)
            {
                cells = new byte[total];
            }

            for (var i = Islands.Count - 1; i >= 0; i--)
            {
                D2dPool <D2dFloodfillIsland> .Despawn(Islands[i], j => j.Clear());
            }

            Islands.Clear();

            // Find all solid pixels
            for (var i = 0; i < total; i++)
            {
                cells[i] = newData[i] > 127 ? CELL_SOLID : CELL_EMPTY;
            }

            for (var i = 0; i < total; i++)
            {
                if (cells[i] == CELL_SOLID)
                {
                    currentIsland = D2dPool <D2dFloodfillIsland> .Spawn() ?? new D2dFloodfillIsland();

                    BeginFloodFill(i, i % newWidth, i / newWidth);

                    Islands.Add(currentIsland);
                }
            }
        }