internal unsafe ExclusiveEntityTransaction(Unity.Entities.ArchetypeManager archetypes, EntityGroupManager entityGroupManager, Unity.Entities.SharedComponentDataManager sharedComponentDataManager, EntityDataManager *data) { this.m_Safety = new AtomicSafetyHandle(); this.m_Entities = data; this.m_ArchetypeManager = GCHandle.Alloc(archetypes, GCHandleType.Weak); this.m_EntityGroupManager = GCHandle.Alloc(entityGroupManager, GCHandleType.Weak); this.m_SharedComponentDataManager = GCHandle.Alloc(sharedComponentDataManager, GCHandleType.Weak); this.m_CachedComponentTypeInArchetypeArray = (ComponentTypeInArchetype *)UnsafeUtility.Malloc((long)((sizeof(ComponentTypeInArchetype) * 0x20) * 0x400), 0x10, Allocator.Persistent); }
public unsafe void SetSharedComponentData <T>(Entity entity, T componentData) where T : struct, ISharedComponentData { this.CheckAccess(); int typeIndex = TypeManager.GetTypeIndex <T>(); this.m_Entities.AssertEntityHasComponent(entity, typeIndex); Unity.Entities.ArchetypeManager archetypeManager = this.ArchetypeManager; Unity.Entities.SharedComponentDataManager sharedComponentDataManager = this.SharedComponentDataManager; int newSharedComponentDataIndex = sharedComponentDataManager.InsertSharedComponent <T>(componentData); this.m_Entities.SetSharedComponentDataIndex(archetypeManager, sharedComponentDataManager, entity, typeIndex, newSharedComponentDataIndex); sharedComponentDataManager.RemoveReference(newSharedComponentDataIndex, 1); }