Exemplo n.º 1
0
        internal EntityManager(World world)
        {
            TypeManager.Initialize();

            m_World = world;

            m_ComponentJobSafetyManager =
                (ComponentJobSafetyManager *)UnsafeUtility.Malloc(sizeof(ComponentJobSafetyManager), 64,
                                                                  Allocator.Persistent);
            m_ComponentJobSafetyManager->OnCreate();

            m_EntityComponentStore  = Entities.EntityComponentStore.Create(world.SequenceNumber << 32);
            m_ManagedComponentStore = new ManagedComponentStore();
            m_EntityGroupManager    = new EntityGroupManager(m_ComponentJobSafetyManager);

            m_ExclusiveEntityTransaction = new ExclusiveEntityTransaction(EntityGroupManager,
                                                                          m_ManagedComponentStore, EntityComponentStore);

            m_UniversalQuery = CreateEntityQuery(
                new EntityQueryDesc
            {
                Options = EntityQueryOptions.IncludePrefab | EntityQueryOptions.IncludeDisabled
            }
                );
        }
        internal void DestroyInstance()
        {
            EndExclusiveEntityTransaction();

            m_ComponentJobSafetyManager->PreDisposeCheck();

            m_UniversalQuery.Dispose();
            m_UniversalQuery = null;

            m_UniversalQueryWithChunks.Dispose();
            m_UniversalQueryWithChunks = null;

            m_ComponentJobSafetyManager->Dispose();
            UnsafeUtility.Free(m_ComponentJobSafetyManager, Allocator.Persistent);
            m_ComponentJobSafetyManager = null;

            Entities.EntityComponentStore.Destroy(m_EntityComponentStore);

            m_EntityComponentStore = null;
            m_EntityQueryManager.Dispose();
            m_EntityQueryManager = null;
            m_ExclusiveEntityTransaction.OnDestroy();

            m_ManagedComponentStore.Dispose();

            m_World = null;
            m_Debug = null;
        }
 public EntityQueryManager(ComponentJobSafetyManager *safetyManager)
 {
     m_JobSafetyManager        = safetyManager;
     m_GroupDataChunkAllocator = new ChunkAllocator();
     m_EntityGroupDataCache    = new NativeMultiHashMap <int, int>(1024, Allocator.Persistent);
     m_EntityGroupDatas        = new UnsafeEntityQueryDataPtrList(0, Allocator.Persistent);
 }
Exemplo n.º 4
0
 internal EntityQuery(EntityQueryData *queryData, ComponentJobSafetyManager *safetyManager, EntityComponentStore *entityComponentStore, ManagedComponentStore managedComponentStore)
 {
     m_QueryData             = queryData;
     m_Filter                = default(EntityQueryFilter);
     m_SafetyManager         = safetyManager;
     m_EntityComponentStore  = entityComponentStore;
     m_ManagedComponentStore = managedComponentStore;
 }
Exemplo n.º 5
0
 internal EntityQuery(EntityGroupData *groupData, ComponentJobSafetyManager *safetyManager, ArchetypeManager typeManager, EntityDataManager *entityDataManager)
 {
     m_GroupData         = groupData;
     m_EntityDataManager = entityDataManager;
     m_Filter            = default(EntityQueryFilter);
     m_SafetyManager     = safetyManager;
     ArchetypeManager    = typeManager;
     EntityDataManager   = entityDataManager;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a NativeArray with all the chunks in a given archetype filtered by the provided EntityQueryFilter.
        /// This function will sync the needed types in the EntityQueryFilter.
        /// </summary>
        /// <param name="matchingArchetypes">List of matching archetypes.</param>
        /// <param name="allocator">Allocator to use for the array.</param>
        /// <param name="jobHandle">Handle to the GatherChunks job used to fill the output array.</param>
        /// <param name="filter">Filter used to filter the resulting chunks</param>
        /// <param name="safetyManager">The ComponentJobSafetyManager belonging to this world</param>
        /// <param name="dependsOn">All jobs spawned will depend on this JobHandle</param>

        /// <returns>NativeArray of all the chunks in the matchingArchetypes list.</returns>
        public static NativeArray <ArchetypeChunk> CreateArchetypeChunkArray(
            UnsafeMatchingArchetypePtrList matchingArchetypes, Allocator allocator,
            ref EntityQueryFilter filter, ComponentJobSafetyManager *safetyManager)
        {
            EntityQuery.SyncFilterTypes(ref matchingArchetypes, ref filter, safetyManager);
            var chunks = CreateArchetypeChunkArrayWithoutSync(matchingArchetypes, allocator, out var jobHandle, ref filter);

            jobHandle.Complete();
            return(chunks);
        }
Exemplo n.º 7
0
 internal ArchetypeChunkIterator(UnsafeMatchingArchetypePtrList match, ComponentJobSafetyManager *safetyManager, uint globalSystemVersion,
                                 ref EntityQueryFilter filter)
 {
     m_MatchingArchetypeList               = match;
     m_CurrentArchetypeIndex               = 0;
     m_CurrentChunkInArchetypeIndex        = -1;
     m_CurrentChunkFirstEntityIndexInQuery = 0;
     m_PreviousMatchingChunk               = null;
     m_Filter = filter;
     m_GlobalSystemVersion = globalSystemVersion;
     m_SafetyManager       = safetyManager;
 }
        internal EntityManager(World world)
        {
            TypeManager.Initialize();
            StructuralChange.Initialize();

            m_World = world;

            m_ComponentJobSafetyManager =
                (ComponentJobSafetyManager *)UnsafeUtility.Malloc(sizeof(ComponentJobSafetyManager), 64,
                                                                  Allocator.Persistent);
            m_ComponentJobSafetyManager->OnCreate();

            m_EntityComponentStore  = Entities.EntityComponentStore.Create(world.SequenceNumber << 32);
            m_ManagedComponentStore = new ManagedComponentStore();
            m_EntityQueryManager    = new EntityQueryManager(m_ComponentJobSafetyManager);
            m_EntityDataAccess      = new EntityDataAccess(this, true);

            m_ExclusiveEntityTransaction = new ExclusiveEntityTransaction(this);

            m_UniversalQuery = CreateEntityQuery(
                new EntityQueryDesc
            {
                Options = EntityQueryOptions.IncludePrefab | EntityQueryOptions.IncludeDisabled
            }
                );

            m_UniversalQueryWithChunks = CreateEntityQuery(
                new EntityQueryDesc
            {
                All     = new[] { ComponentType.ReadWrite <ChunkHeader>() },
                Options = EntityQueryOptions.IncludeDisabled | EntityQueryOptions.IncludePrefab
            },
                new EntityQueryDesc
            {
                Options = EntityQueryOptions.IncludeDisabled | EntityQueryOptions.IncludePrefab
            }
                );
        }
 internal unsafe ComponentGroup(EntityQueryData *queryData, ComponentJobSafetyManager *safetyManager, EntityComponentStore *entityComponentStore, ManagedComponentStore managedComponentStore)
 {
     // ctor matching EntityQuery ctor to prevent default parameterless ctor from being created
     throw new NotImplementedException();
 }