Пример #1
0
        // Does not reindex /TODO
        public CR2WExportWrapper CreateChunk(string type, int chunkindex = 0, CR2WExportWrapper parent = null, CR2WExportWrapper virtualparent = null, CVariable cvar = null)
        {
            var chunk = new CR2WExportWrapper(this, type, parent);

            if (cvar != null)
            {
                chunk.CreateDefaultData();
            }
            else
            {
                chunk.CreateDefaultData(cvar);
            }

            if (parent != null)
            {
                chunk.ParentChunk = parent;
            }
            if (virtualparent != null)
            {
                chunk.MountChunkVirtually(virtualparent);
            }

            Chunks.Insert(chunkindex, chunk);
            return(chunk);
        }
Пример #2
0
        /// <summary>
        /// This constructor should be used when manually creating chunks
        /// </summary>
        /// <param name="file"></param>
        /// <param name="redtype"></param>
        /// <param name="parentchunk"></param>
        /// <param name="cooked"></param>
        public CR2WExportWrapper(CR2WFile file, string redtype, CR2WExportWrapper parentchunk, bool cooked = false)
        {
            _export = new CR2WExport
            {
                objectFlags = (ushort)(cooked ? 8192 : 0),
            };
            AdReferences = new List <IChunkPtrAccessor>();
            AbReferences = new List <IChunkPtrAccessor>();

            this.cr2w    = file;
            this.REDType = redtype;
            ParentChunk  = parentchunk;
        }
Пример #3
0
        // Does not reindex /TODO
        public CR2WExportWrapper CreateChunk(CVariable cvar, int chunkindex = 0, CR2WExportWrapper parent = null, CR2WExportWrapper virtualparent = null)
        {
            // checks to see if the variable from which the chunk is built is properly constructed
            if (cvar == null || cvar.REDName != cvar.REDType || cvar.ParentVar != null)
            {
                throw new NotImplementedException();
            }

            var chunk = new CR2WExportWrapper(this, cvar.REDType, parent);

            chunk.CreateDefaultData(cvar);

            if (parent != null)
            {
                chunk.ParentChunk = parent;
            }
            if (virtualparent != null)
            {
                chunk.MountChunkVirtually(virtualparent);
            }

            Chunks.Insert(chunkindex, chunk);
            return(chunk);
        }
Пример #4
0
 /// <summary>
 /// Used when pasting-in-place a chunk, takes care of (virtual) children.
 /// </summary>
 /// <param name="sourcechunk"></param>
 /// <param name="destinationchunk"></param>
 /// <param name="oldparentinghierarchy"></param>
 public void AddChildrenChunks(
     CR2WExportWrapper sourcechunk,
     CR2WExportWrapper destinationchunk = null,
     Dictionary <CR2WExportWrapper,
                 (CR2WExportWrapper oldchunkparent, CR2WExportWrapper oldchunkvparent)> oldparentinghierarchy = null)