public static void CopyManagedObjects(ArchetypeManager typeMan, Chunk *srcChunk, int srcStartIndex, Chunk *dstChunk, int dstStartIndex, int count) { var srcArch = srcChunk->Archetype; var dstArch = dstChunk->Archetype; var srcI = 0; var dstI = 0; while (srcI < srcArch->TypesCount && dstI < dstArch->TypesCount) { if (srcArch->Types[srcI] < dstArch->Types[dstI]) { ++srcI; } else if (srcArch->Types[srcI] > dstArch->Types[dstI]) { ++dstI; } else { if (srcArch->ManagedArrayOffset[srcI] >= 0) { for (var i = 0; i < count; ++i) { var obj = typeMan.GetManagedObject(srcChunk, srcI, srcStartIndex + i); typeMan.SetManagedObject(dstChunk, dstI, dstStartIndex + i, obj); } } ++srcI; ++dstI; } } }
internal void SetComponentObject(Entity entity, ComponentType componentType, object componentObject) { m_Entities->AssertEntityHasComponent(entity, componentType.TypeIndex); Chunk *chunk; int chunkIndex; m_Entities->GetComponentChunk(entity, out chunk, out chunkIndex); m_ArchetypeManager.SetManagedObject(chunk, componentType, chunkIndex, componentObject); }
public static void ClearManagedObjects(ArchetypeManager typeMan, Chunk *chunk, int index, int count) { var arch = chunk->Archetype; for (var type = 0; type < arch->TypesCount; ++type) { if (arch->ManagedArrayOffset[type] < 0) { continue; } for (var i = 0; i < count; ++i) { typeMan.SetManagedObject(chunk, type, index + i, null); } } }
public static unsafe void ClearManagedObjects(ArchetypeManager typeMan, Chunk *chunk, int index, int count) { Archetype *archetype = chunk.Archetype; for (int i = 0; i < archetype->TypesCount; i++) { if (archetype->ManagedArrayOffset[i] >= 0) { int num2 = 0; while (true) { if (num2 >= count) { break; } typeMan.SetManagedObject(chunk, i, index + num2, null); num2++; } } } }
public static unsafe void CopyManagedObjects(ArchetypeManager typeMan, Chunk *srcChunk, int srcStartIndex, Chunk *dstChunk, int dstStartIndex, int count) { Archetype *archetype = srcChunk.Archetype; Archetype *archetypePtr2 = dstChunk.Archetype; int index = 0; int num2 = 0; while ((index < archetype->TypesCount) && (num2 < archetypePtr2->TypesCount)) { if (archetype->Types[index] < archetypePtr2->Types[num2]) { index++; continue; } if (archetype->Types[index] > archetypePtr2->Types[num2]) { num2++; continue; } if (archetype->ManagedArrayOffset[index] >= 0) { int num3 = 0; while (true) { if (num3 >= count) { break; } object val = typeMan.GetManagedObject(srcChunk, index, srcStartIndex + num3); typeMan.SetManagedObject(dstChunk, num2, dstStartIndex + num3, val); num3++; } } index++; num2++; } }