public void CopyValuesTo(CompositeBone target, CompositeBone parentBone, CompositeEntity newParentEntity) { target.Parent = newParentEntity; target.ParentBone = parentBone; target.Name = this.Name; target.SceneItem = this.SceneItem; target.SubItem = this.SubItem; target.InheritPosition = this.InheritPosition; target.InheritRotation = this.InheritRotation; target.InheritScale = this.InheritScale; target.InheritVisibility = this.InheritVisibility; target.MasterVisibility = this.MasterVisibility; target.Interpolate = this.Interpolate; // copy bones for (int i = 0; i < this.ChildBones.Count; i++) { CompositeBone targetCBone; bool addToList = false; // if no child bone is available, create a new one if (target.ChildBones.Count <= i) { targetCBone = new CompositeBone(); addToList = true; } else { targetCBone = target.ChildBones[i]; } this.ChildBones[i].CopyValuesTo(targetCBone, target, newParentEntity); if (addToList == true) { target.AddChildBone(targetCBone); } } // Remove remaining types (can cause garbage!) for (int i = target.ChildBones.Count; i > this.ChildBones.Count; i--) { target.ChildBones.RemoveAt(i - 1); } }