Пример #1
0
        public void SetReference(ICR2WExport value)
        {
            SetValueInternal(value.ChunkIndex);

            //Populate the reverse-lookups
            GetReference().AdReferences.Add(this);
            cr2w.Chunks[LookUpChunkIndex()].AbReferences.Add(this);
            //Soft mount the chunk except root chunk
            if (GetReference().ChunkIndex != 0)
            {
                GetReference().MountChunkVirtually(LookUpChunkIndex());
            }
            //Hard mounts
            switch (REDName)
            {
            case "parent":
            case "transformParent":
                cr2w.Chunks[LookUpChunkIndex()].MountChunkVirtually(GetReference(), true);
                break;
                //   case "child" when Reference.IsVirtuallyMounted:
                //       //tried for w2ent IAttachments, not the proper way to do it, this is graph viz territory
                //       Reference.MountChunkVirtually(GetVarChunkIndex(), true);
                //       break;
            }
        }
Пример #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, ICR2WExport parentchunk, bool cooked = false)
        {
            _export = new CR2WExport
            {
                objectFlags = (ushort)(cooked ? 8192 : 0),
            };
            AdReferences = new List <IREDChunkPtr>();
            AbReferences = new List <IREDChunkPtr>();

            this.cr2w    = file;
            this.REDType = redtype;
            ParentChunk  = parentchunk;
        }
Пример #3
0
        public void SetReference(ICR2WExport value)
        {
            SetValueInternal(value.ChunkIndex + 1);

            //Populate the reverse-lookups
            GetReference().AdReferences.Add(this);
            cr2w.Chunks[LookUpChunkIndex()].AbReferences.Add(this);
            //Soft mount the chunk except root chunk
            if (GetReference().ChunkIndex != 0)
            {
                GetReference().MountChunkVirtually(LookUpChunkIndex());
            }
        }
Пример #4
0
        public override CVariable SetValue(object val)
        {
            switch (val)
            {
            case ICR2WExport wrapper:
                Reference = wrapper;
                break;

            case IPtrAccessor cval:
                Reference = cval.Reference;
                break;
            }

            return(this);
        }
Пример #5
0
        public override CVariable Copy(ICR2WCopyAction context)
        {
            var copy = (CPtr <T>)base.Copy(context);

            if (Reference != null)
            {
                ICR2WExport newref = context.TryLookupReference(Reference, copy);
                if (newref != null)
                {
                    copy.SetValue(newref);
                }
            }


            return(copy);
        }
Пример #6
0
        public override CVariable SetValue(object val)
        {
            switch (val)
            {
            case int o:
                SetValueInternal(o);
                break;

            case IHandleAccessor cvar:
                this.ChunkHandle = cvar.ChunkHandle;
                this.DepotPath   = cvar.DepotPath;
                this.ClassName   = cvar.ClassName;
                this.Flags       = cvar.Flags;

                this.Reference = cvar.Reference;
                break;
            }

            return(this);
        }
Пример #7
0
        public override CVariable Copy(ICR2WCopyAction context)
        {
            var copy = (CHandle <T>)base.Copy(context);

            copy.ChunkHandle = ChunkHandle;

            // Soft
            copy.DepotPath = DepotPath;
            copy.ClassName = ClassName;
            copy.Flags     = Flags;

            // Ptr
            if (ChunkHandle && Reference != null)
            {
                ICR2WExport newref = context.TryLookupReference(Reference, copy);
                if (newref != null)
                {
                    copy.Reference = newref;
                }
            }

            return(copy);
        }
Пример #8
0
        private void SetValueInternal(int val)
        {
            if (val >= 0)
            {
                this.ChunkHandle = true;
            }


            if (ChunkHandle)
            {
                if (val == 0)
                {
                    Reference = null;
                }
                else
                {
                    Reference = cr2w.Chunks[val - 1];
                    //Populate the reverse-lookups
                    Reference.AdReferences.Add(this);
                    cr2w.Chunks[LookUpChunkIndex()].AbReferences.Add(this);
                    //Soft mount the chunk except root chunk
                    if (Reference.ChunkIndex != 0)
                    {
                        Reference.MountChunkVirtually(LookUpChunkIndex());
                    }
                }
            }
            else
            {
                DepotPath = cr2w.Imports[-val - 1].DepotPathStr;

                var filetype = cr2w.Imports[-val - 1].Import.className;
                ClassName = cr2w.Names[filetype].Str;

                Flags = cr2w.Imports[-val - 1].Import.flags;
            }
        }
Пример #9
0
        private void SetValueInternal(int val)
        {
            try
            {
                Reference = val == 0 ? null : cr2w.Chunks[val - 1];
            }
            catch (Exception ex)
            {
                throw new InvalidPtrException(ex.Message);
            }

            // Try reparenting on virtual mountpoint
            if (Reference != null)
            {
                //Populate the reverse-lookups
                Reference.AdReferences.Add(this);
                cr2w.Chunks[LookUpChunkIndex()].AbReferences.Add(this);
                //Soft mount the chunk except root chunk
                if (Reference.ChunkIndex != 0)
                {
                    Reference.MountChunkVirtually(LookUpChunkIndex());
                }
                //Hard mounts
                switch (REDName)
                {
                case "parent":
                case "transformParent":
                    cr2w.Chunks[LookUpChunkIndex()].MountChunkVirtually(Reference, true);
                    break;
                    //   case "child" when Reference.IsVirtuallyMounted:
                    //       //tried for w2ent IAttachments, not the proper way to do it, this is graph viz territory
                    //       Reference.MountChunkVirtually(GetVarChunkIndex(), true);
                    //       break;
                }
            }
        }
Пример #10
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(
     ICR2WExport sourcechunk,
     ICR2WExport destinationchunk = null,
     Dictionary <ICR2WExport,
                 (ICR2WExport oldchunkparent, ICR2WExport oldchunkvparent)> oldparentinghierarchy = null)
Пример #11
0
 public ChunkViewModel(ICR2WExport export)
 {
     _export = export;
 }
Пример #12
0
 public static int GetLastChildrenIndexRecursive(ICR2WExport chunk) =>
 !chunk.VirtualChildrenChunks.Any()
         ? chunk.ChunkIndex
         : GetLastChildrenIndexRecursive(chunk.VirtualChildrenChunks
                                         .FirstOrDefault(_ => _.ChunkIndex == chunk.VirtualChildrenChunks.Max(p => p.ChunkIndex)));