public void AssertWillDestroyAllInLinkedEntityGroup(NativeArray <ArchetypeChunk> chunkArray,
                                                            BufferTypeHandle <LinkedEntityGroup> linkedGroupTypeHandle,
                                                            ref Entity errorEntity,
                                                            ref Entity errorReferencedEntity)
        {
            var chunks      = (ArchetypeChunk *)chunkArray.GetUnsafeReadOnlyPtr();
            var chunksCount = chunkArray.Length;

            var tempChunkStateFlag = (uint)ChunkFlags.TempAssertWillDestroyAllInLinkedEntityGroup;

            for (int i = 0; i != chunksCount; i++)
            {
                var chunk = chunks[i].m_Chunk;
                Assert.IsTrue((chunk->Flags & tempChunkStateFlag) == 0);
                chunk->Flags |= tempChunkStateFlag;
            }

            errorEntity           = default;
            errorReferencedEntity = default;

            for (int i = 0; i < chunkArray.Length; ++i)
            {
                if (!chunks[i].Has(linkedGroupTypeHandle))
                {
                    continue;
                }

                var chunk   = chunks[i];
                var buffers = chunk.GetBufferAccessor(linkedGroupTypeHandle);

                for (int b = 0; b != buffers.Length; b++)
                {
                    var buffer      = buffers[b];
                    int entityCount = buffer.Length;
                    var entities    = (Entity *)buffer.GetUnsafeReadOnlyPtr();
                    for (int e = 0; e != entityCount; e++)
                    {
                        var referencedEntity = entities[e];
                        if (Exists(referencedEntity))
                        {
                            var referencedChunk = GetChunk(referencedEntity);

                            if ((referencedChunk->Flags & tempChunkStateFlag) == 0)
                            {
                                errorEntity           = entities[0];
                                errorReferencedEntity = referencedEntity;
                            }
                        }
                    }
                }
            }

            for (int i = 0; i != chunksCount; i++)
            {
                var chunk = chunks[i].m_Chunk;
                Assert.IsTrue((chunk->Flags & tempChunkStateFlag) != 0);
                chunk->Flags &= ~tempChunkStateFlag;
            }
        }
Ejemplo n.º 2
0
 public static bool Has <T>(this ArchetypeChunk chunk, BufferTypeHandle <T> chunkBufferType) where T : struct, IBufferElementData => chunk.Has(chunkBufferType.Value);
Ejemplo n.º 3
0
 public static BufferAccessor <T> GetBufferAccessor <T>(this ArchetypeChunk chunk, BufferTypeHandle <T> bufferComponentType) where T : struct, IBufferElementData => chunk.GetBufferAccessor(bufferComponentType.Value);
Ejemplo n.º 4
0
 public void ScheduleTimeInitialize(ComponentSystemBase jobComponentSystem, bool isReadOnly)
 {
     _typeHandle = jobComponentSystem.GetBufferTypeHandle <T>(isReadOnly);
 }