Exemplo n.º 1
0
        public NativeArray <int> MoveAllSharedComponents(ManagedComponentStore srcManagedComponents, Allocator allocator)
        {
            var remap = new NativeArray <int>(srcManagedComponents.GetSharedComponentCount(), allocator);

            remap[0] = 0;

            var srcInfos = srcManagedComponents.SharedComponentInfoPtr;

            for (int srcIndex = 1; srcIndex < remap.Length; ++srcIndex)
            {
                var srcData = srcManagedComponents.m_SharedComponentData[srcIndex];
                if (srcData == null)
                {
                    continue;
                }

                var typeIndex = srcInfos[srcIndex].ComponentType;
                var hashCode  = srcInfos[srcIndex].HashCode;
                var dstIndex  = InsertSharedComponentAssumeNonDefaultMove(typeIndex, hashCode, srcData);

                SharedComponentInfoPtr[dstIndex].RefCount += srcInfos[srcIndex].RefCount - 1;

                remap[srcIndex] = dstIndex;
            }

            srcManagedComponents.ResetSharedComponentData();

            return(remap);
        }