ByChance.Levels2D.Chunk2D.Chunk2D C# (CSharp) Method

Chunk2D() public method

Constructs a new chunk with a reference to the passed chunk template, using that template's width and height and performing deep copies of the lists of contexts and anchors of that template.
is null. is not of the type .
public Chunk2D ( ChunkTemplate chunkTemplate ) : System
chunkTemplate ByChance.Core.ChunkTemplate Chunk template the new chunk will be based on.
return System
        public Chunk2D(ChunkTemplate chunkTemplate)
            : base(chunkTemplate)
        {
            ChunkTemplate2D chunkTemplate2D = chunkTemplate as ChunkTemplate2D;

            // Check the type of the passed template.
            if (chunkTemplate2D == null)
            {
                throw new ArgumentException("Passed template isn't of type ChunkTemplate2D.", "chunkTemplate");
            }

            // Copy template extents.
            this.Extents = chunkTemplate2D.Extents;

            // Perform deep copies of the context and anchor lists of the template.
            foreach (Context2D context in chunkTemplate2D.ChunkTemplateContexts)
            {
                this.ChunkContexts.Add(new Context2D(context, this));
            }

            foreach (Anchor2D anchor in chunkTemplate2D.ChunkTemplateAnchors)
            {
                this.ChunkAnchors.Add(new Anchor2D(anchor, this));
            }
        }