internal void AddCreateCommand(EntityCommandBufferChain *chain, ECBCommand op, EntityArchetype archetype) { if (chain->m_PrevCreateCommand != null && chain->m_PrevCreateCommand->Archetype == archetype && chain->m_PrevCreateCommand->BatchCount < kMaxBatchCount) { ++chain->m_PrevCreateCommand->BatchCount; var data = (CreateCommand *)Reserve(chain, sizeof(CreateCommand)); data->Header.CommandType = (int)op; data->Header.TotalSize = sizeof(CreateCommand); data->Archetype = archetype; data->BatchCount = 0; } else { var data = (CreateCommand *)Reserve(chain, sizeof(CreateCommand)); data->Header.CommandType = (int)op; data->Header.TotalSize = sizeof(CreateCommand); data->Archetype = archetype; data->BatchCount = 1; chain->m_PrevCreateCommand = data; } }
internal void AddEntityCommand(EntityCommandBufferChain *chain, ECBCommand op, Entity e) { if (chain->m_PrevEntityCommand != null && chain->m_PrevEntityCommand->Entity == e && chain->m_PrevEntityCommand->BatchCount < kMaxBatchCount) { ++chain->m_PrevEntityCommand->BatchCount; var data = (EntityCommand *)Reserve(chain, sizeof(EntityCommand)); data->Header.CommandType = (int)op; data->Header.TotalSize = sizeof(EntityCommand); data->Entity = e; data->BatchCount = 0; } else { var data = (EntityCommand *)Reserve(chain, sizeof(EntityCommand)); data->Header.CommandType = (int)op; data->Header.TotalSize = sizeof(EntityCommand); data->Entity = e; data->BatchCount = 1; chain->m_PrevEntityCommand = data; } }
public unsafe DynamicBuffer <T> CreateBufferCommand <T>(ECBCommand commandType, EntityCommandBufferChain *chain, int jobIndex, Entity e, AtomicSafetyHandle bufferSafety, AtomicSafetyHandle arrayInvalidationSafety) where T : struct, IBufferElementData { AtomicSafetyHandle handle = bufferSafety; AtomicSafetyHandle.UseSecondaryVersion(ref handle); return(new DynamicBuffer <T>(this.AddEntityBufferCommand <T>(chain, jobIndex, commandType, e), handle, arrayInvalidationSafety, false)); }
internal void AddEntityCommand(EntityCommandBufferChain *chain, ECBCommand op, Entity e) { var data = (EntityCommand *)Reserve(chain, sizeof(EntityCommand)); data->Header.CommandType = (int)op; data->Header.TotalSize = sizeof(EntityCommand); data->Entity = e; }
internal void AddCreateCommand(EntityCommandBufferChain *chain, ECBCommand op, EntityArchetype archetype) { var data = (CreateCommand *)Reserve(chain, sizeof(CreateCommand)); data->Header.CommandType = (int)op; data->Header.TotalSize = sizeof(CreateCommand); data->Archetype = archetype; }
internal void AddEntityComponentTypeCommand(EntityCommandBufferChain *chain, ECBCommand op, Entity e, ComponentType t) { var sizeNeeded = Align(sizeof(EntityComponentCommand), 8); var data = (EntityComponentCommand *)Reserve(chain, sizeNeeded); data->Header.Header.CommandType = (int)op; data->Header.Header.TotalSize = sizeNeeded; data->Header.Entity = e; data->ComponentTypeIndex = t.TypeIndex; }
public DynamicBuffer <T> CreateBufferCommand <T>(ECBCommand commandType, EntityCommandBufferChain *chain, Entity e) where T : struct, IBufferElementData { BufferHeader *header = AddEntityBufferCommand <T>(chain, commandType, e); #if ENABLE_UNITY_COLLECTIONS_CHECKS var safety = m_BufferSafety; AtomicSafetyHandle.UseSecondaryVersion(ref safety); return(new DynamicBuffer <T>(header, safety)); #else return(new DynamicBuffer <T>(header)); #endif }
internal void AddEntityComponentCommand <T>(EntityCommandBufferChain *chain, ECBCommand op, Entity e, T component) where T : struct { var typeSize = UnsafeUtility.SizeOf <T>(); var typeIndex = TypeManager.GetTypeIndex <T>(); var sizeNeeded = Align(sizeof(EntityComponentCommand) + typeSize, 8); var data = (EntityComponentCommand *)Reserve(chain, sizeNeeded); data->Header.Header.CommandType = (int)op; data->Header.Header.TotalSize = sizeNeeded; data->Header.Entity = e; data->ComponentTypeIndex = typeIndex; data->ComponentSize = typeSize; UnsafeUtility.CopyStructureToPtr(ref component, (byte *)(data + 1)); }
internal void AddEntitySharedComponentCommand <T>(EntityCommandBufferChain *chain, ECBCommand op, Entity e, int hashCode, object boxedObject) where T : struct { var typeIndex = TypeManager.GetTypeIndex <T>(); var sizeNeeded = Align(sizeof(EntitySharedComponentCommand), 8); var data = (EntitySharedComponentCommand *)Reserve(chain, sizeNeeded); data->Header.Header.CommandType = (int)op; data->Header.Header.TotalSize = sizeNeeded; data->Header.Entity = e; data->ComponentTypeIndex = typeIndex; data->HashCode = hashCode; if (boxedObject != null) { data->BoxedObject = GCHandle.Alloc(boxedObject); // We need to store all GCHandles on a cleanup list so we can dispose them later, regardless of if playback occurs or not. data->Prev = chain->m_CleanupList; chain->m_CleanupList = data; } else { data->BoxedObject = new GCHandle(); } }
internal BufferHeader *AddEntityBufferCommand <T>(EntityCommandBufferChain *chain, ECBCommand op, Entity e) where T : struct, IBufferElementData { var typeIndex = TypeManager.GetTypeIndex <T>(); var type = TypeManager.GetTypeInfo <T>(); var sizeNeeded = Align(sizeof(EntityBufferCommand) + type.SizeInChunk, 8); var data = (EntityBufferCommand *)Reserve(chain, sizeNeeded); data->Header.Header.CommandType = (int)op; data->Header.Header.TotalSize = sizeNeeded; data->Header.Entity = e; data->ComponentTypeIndex = typeIndex; data->ComponentSize = type.SizeInChunk; BufferHeader.Initialize(&data->TempBuffer, type.BufferCapacity); return(&data->TempBuffer); }
internal unsafe void AddEntityCommand(EntityCommandBufferChain *chain, int jobIndex, ECBCommand op, Entity e) { int num1; if ((chain.m_PrevEntityCommand == null) || !(chain.m_PrevEntityCommand.Entity == e)) { num1 = 0; } else { num1 = (int)(chain.m_PrevEntityCommand.BatchCount < 0x200); } if (num1 == 0) { EntityCommand *commandPtr2 = (EntityCommand *)ref this.Reserve(chain, jobIndex, sizeof(EntityCommand)); commandPtr2->Header.CommandType = (int)op; commandPtr2->Header.TotalSize = sizeof(EntityCommand); commandPtr2->Header.SortIndex = chain.m_LastSortIndex; commandPtr2->Entity = e; commandPtr2->BatchCount = 1; chain.m_PrevEntityCommand = commandPtr2; } else { int *numPtr1 = (int *)ref chain.m_PrevEntityCommand.BatchCount; numPtr1[0]++; EntityCommand *commandPtr = (EntityCommand *)ref this.Reserve(chain, jobIndex, sizeof(EntityCommand)); commandPtr->Header.CommandType = (int)op; commandPtr->Header.TotalSize = sizeof(EntityCommand); commandPtr->Header.SortIndex = chain.m_LastSortIndex; commandPtr->Entity = e; commandPtr->BatchCount = 0; } }
internal unsafe void AddEntitySharedComponentCommand <T>(EntityCommandBufferChain *chain, int jobIndex, ECBCommand op, Entity e, int hashCode, object boxedObject) where T : struct { int size = Align(sizeof(EntitySharedComponentCommand), 8); EntitySharedComponentCommand *commandPtr = (EntitySharedComponentCommand *)ref this.Reserve(chain, jobIndex, size); commandPtr->Header.Header.CommandType = (int)op; commandPtr->Header.Header.TotalSize = size; commandPtr->Header.Header.SortIndex = chain.m_LastSortIndex; commandPtr->Header.Entity = e; commandPtr->ComponentTypeIndex = TypeManager.GetTypeIndex <T>(); commandPtr->HashCode = hashCode; if (boxedObject == null) { commandPtr->BoxedObject = new GCHandle(); } else { commandPtr->BoxedObject = GCHandle.Alloc(boxedObject); commandPtr->Prev = chain.m_CleanupList; chain.m_CleanupList = commandPtr; } }
internal unsafe void AddEntityComponentTypeCommand(EntityCommandBufferChain *chain, int jobIndex, ECBCommand op, Entity e, ComponentType t) { int size = Align(sizeof(EntityComponentCommand), 8); EntityComponentCommand *commandPtr = (EntityComponentCommand *)ref this.Reserve(chain, jobIndex, size); commandPtr->Header.Header.CommandType = (int)op; commandPtr->Header.Header.TotalSize = size; commandPtr->Header.Header.SortIndex = chain.m_LastSortIndex; commandPtr->Header.Entity = e; commandPtr->ComponentTypeIndex = t.TypeIndex; }
internal unsafe BufferHeader *AddEntityBufferCommand <T>(EntityCommandBufferChain *chain, int jobIndex, ECBCommand op, Entity e) where T : struct, IBufferElementData { TypeManager.TypeInfo typeInfo = TypeManager.GetTypeInfo <T>(); int size = Align(sizeof(EntityBufferCommand) + typeInfo.SizeInChunk, 8); EntityBufferCommand *commandPtr = (EntityBufferCommand *)ref this.Reserve(chain, jobIndex, size); commandPtr->Header.Header.CommandType = (int)op; commandPtr->Header.Header.TotalSize = size; commandPtr->Header.Header.SortIndex = chain.m_LastSortIndex; commandPtr->Header.Entity = e; commandPtr->ComponentTypeIndex = TypeManager.GetTypeIndex <T>(); commandPtr->ComponentSize = typeInfo.SizeInChunk; BufferHeader.Initialize(&commandPtr->TempBuffer, typeInfo.BufferCapacity); return(&commandPtr->TempBuffer); }
internal unsafe void AddEntityComponentCommand <T>(EntityCommandBufferChain *chain, int jobIndex, ECBCommand op, Entity e, T component) where T : struct { int num2 = UnsafeUtility.SizeOf <T>(); int size = Align(sizeof(EntityComponentCommand) + num2, 8); EntityComponentCommand *commandPtr = (EntityComponentCommand *)this.Reserve(chain, jobIndex, size); commandPtr->Header.Header.CommandType = (int)op; commandPtr->Header.Header.TotalSize = size; commandPtr->Header.Header.SortIndex = chain.m_LastSortIndex; commandPtr->Header.Entity = e; commandPtr->ComponentTypeIndex = TypeManager.GetTypeIndex <T>(); commandPtr->ComponentSize = num2; UnsafeUtility.CopyStructureToPtr <T>(ref component, (void *)(commandPtr + 1)); }