public void PushPacketIntoFrameResource(FrameResource FrameResource) { Dictionary <int, FrameObjectBase> AttachmentRefLookup = new Dictionary <int, FrameObjectBase>(); FrameResource.FrameBlendInfos.AddRange(FrameBlendInfos); FrameResource.FrameGeometries.AddRange(FrameGeometries); FrameResource.FrameMaterials.AddRange(FrameMaterials); FrameResource.FrameSkeletonHierachies.AddRange(FrameSkeletonHierarchy); FrameResource.FrameSkeletons.AddRange(FrameSkeletons); FrameResource.FrameObjects.AddRange(FrameObjects); // Update child relations // Then push Object and hash to AttachmentRefLookup foreach (var Pair in FrameObjects) { FrameObjectBase CurrentObject = (Pair.Value as FrameObjectBase); UpdateParentChildRelations(FrameResource, CurrentObject); } // Update AttachmentReferences on FrameObjectModels foreach (var Pair in FrameObjects) { if (Pair.Value is FrameObjectModel) { FrameObjectModel ModelObject = (Pair.Value as FrameObjectModel); List <int> AttachmentRefs = ModelAttachments[ModelObject.Name.Hash]; for (int i = 0; i < AttachmentRefs.Count; i++) { ModelObject.AttachmentReferences[i].Attachment = OldRefIDLookupTable[AttachmentRefs[i]]; } } } }
private void UpdateParentChildRelations(FrameResource FrameResource, FrameObjectBase ObjectToUpdate) { FrameObjectBase Child = ObjectToUpdate; // Parent Frames FrameObjectBase Parent1 = null; FrameObjectBase Parent2 = null; if (Child.Refs.ContainsKey(FrameEntryRefTypes.Parent1)) { if (OldRefIDLookupTable.TryGetValue(Child.Refs[FrameEntryRefTypes.Parent1], out Parent1)) { Child.SubRef(FrameEntryRefTypes.Parent1); FrameResource.SetParentOfObject(0, Child, Parent1); } else { Child.SubRef(FrameEntryRefTypes.Parent1); FrameResource.SetParentOfObject(0, Child, null); } } if (Child.Refs.ContainsKey(FrameEntryRefTypes.Parent2)) { if (OldRefIDLookupTable.TryGetValue(Child.Refs[FrameEntryRefTypes.Parent2], out Parent2)) { Child.SubRef(FrameEntryRefTypes.Parent2); FrameResource.SetParentOfObject(1, Child, Parent2); } else { Child.SubRef(FrameEntryRefTypes.Parent2); FrameResource.SetParentOfObject(1, Child, null); } } }