Example #1
0
    /// <summary>
    /// EntityManager.BeforeStructuralChange must be called before invoking this.
    /// ManagedComponentStore.Playback must be called after invoking this.
    /// EntityQueryManager.AddAdditionalArchetypes must be called after invoking this.
    /// Invoking this must be wrapped in ArchetypeChangeTracking.
    /// </summary>
    /// <param name="chunks"></param>
    /// <param name="sharedComponentIndex"></param>
    /// <param name="componentType"></param>
    internal void AddSharedComponentDataDuringStructuralChange(NativeArray <ArchetypeChunk> chunks, int sharedComponentIndex, ComponentType componentType)
    {
        Assert.IsTrue(componentType.IsSharedComponent);
        EntityComponentStore->AssertCanAddComponent(chunks, componentType);

        StructuralChange.AddSharedComponentChunks(EntityComponentStore, (ArchetypeChunk *)NativeArrayUnsafeUtility.GetUnsafePtr(chunks), chunks.Length, componentType.TypeIndex, sharedComponentIndex);
    }
Example #2
0
    internal void AddSharedComponentData(NativeArray <ArchetypeChunk> chunks, int sharedComponentIndex, ComponentType componentType)
    {
        Assert.IsTrue(componentType.IsSharedComponent);
        EntityComponentStore->AssertCanAddComponent(chunks, componentType);

        if (m_IsMainThread)
        {
            BeforeStructuralChange();
        }
        var archetypeChanges = EntityComponentStore->BeginArchetypeChangeTracking();

        StructuralChange.AddSharedComponentChunks(EntityComponentStore, (ArchetypeChunk *)NativeArrayUnsafeUtility.GetUnsafePtr(chunks), chunks.Length, componentType.TypeIndex, sharedComponentIndex);

        EntityComponentStore->EndArchetypeChangeTracking(archetypeChanges, EntityQueryManager);
        PlaybackManagedChanges();
    }