Пример #1
0
        public Chunk(int x, int y)
        {
            this.X = x;
            this.Y = y;

            tiles   = new Tile[SIZE * SIZE * DEPTH];
            this.ID = ((long)x << 32) | (uint)y;

            TotalCount++;

            Graphics = new ChunkGraphics(this);
        }
Пример #2
0
        public void Dispose()
        {
            if (tiles != null)
            {
                for (int x = 0; x < SIZE; x++)
                {
                    for (int y = 0; y < SIZE; y++)
                    {
                        for (int z = 0; z < DEPTH; z++)
                        {
                            int index = GetIndex(x, y, z);
                            var t     = tiles[index];
                            if (!t.IsBlank)
                            {
                                t.Def.UponRemoved(ref tiles[index], this, x, y, z, true);
                            }
                        }
                    }
                }
            }

            if (Graphics != null)
            {
                Graphics.Dispose();
                Graphics.Chunk = null;
                Graphics       = null;
            }

            RequiresRedraw = false;
            foreach (var e in entities)
            {
                e.CurrentChunk = null;
            }
            entities?.Clear();
            entities = null;
        }