static void Initialize()
 {
     TypeManager.Initialize();
     ManagedComponentStore.CompanionLinkTypeIndex     = TypeManager.GetTypeIndex(typeof(CompanionLink));
     ManagedComponentStore.InstantiateHybridComponent = InstantiateHybridComponentDelegate;
     ManagedComponentStore.AssignHybridComponentsToCompanionGameObjects = AssignHybridComponentsToCompanionGameObjectsDelegate;
 }
Beispiel #2
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
            }
                );
        }
Beispiel #3
0
 protected override unsafe void OnCreateManager()
 {
     TypeManager.Initialize();
     this.Entities = (EntityDataManager *)UnsafeUtility.Malloc((long)sizeof(EntityDataManager), 0x40, Allocator.Persistent);
     this.Entities.OnCreate();
     this.m_SharedComponentManager              = new SharedComponentDataManager();
     this.ArchetypeManager                      = new Unity.Entities.ArchetypeManager(this.m_SharedComponentManager);
     this.ComponentJobSafetyManager             = new Unity.Entities.ComponentJobSafetyManager();
     this.m_GroupManager                        = new EntityGroupManager(this.ComponentJobSafetyManager);
     this.m_ExclusiveEntityTransaction          = new ExclusiveEntityTransaction(this.ArchetypeManager, this.m_GroupManager, this.m_SharedComponentManager, this.Entities);
     this.m_CachedComponentTypeInArchetypeArray = (ComponentTypeInArchetype *)UnsafeUtility.Malloc((long)(sizeof(ComponentTypeInArchetype) * 0x400), 0x10, Allocator.Persistent);
 }
        internal EntityManager(World world)
        {
            TypeManager.Initialize();
            StructuralChange.Initialize();
            EntityCommandBuffer.Initialize();

            m_World = world;

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

            m_EntityComponentStore  = Entities.EntityComponentStore.Create(world.SequenceNumber << 32);
            m_EntityQueryManager    = Unity.Entities.EntityQueryManager.Create(m_DependencyManager);
            m_ManagedComponentStore = new ManagedComponentStore();

            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
            }
                );

            #if ENABLE_UNITY_COLLECTIONS_CHECKS
            m_UniversalQuery._DisallowDisposing           = "EntityManager.UniversalQuery may not be disposed";
            m_UniversalQueryWithChunks._DisallowDisposing = "EntityManager.UniversalQuery may not be disposed";
            #endif
        }
        protected override void OnCreateManager(int capacity)
        {
            TypeManager.Initialize();

            m_Entities = (EntityDataManager *)UnsafeUtility.Malloc(sizeof(EntityDataManager), 64, Allocator.Persistent);
            m_Entities->OnCreate(capacity);

            m_SharedComponentManager = new SharedComponentDataManager();

            m_ArchetypeManager        = new ArchetypeManager(m_SharedComponentManager);
            ComponentJobSafetyManager = new ComponentJobSafetyManager();
            m_GroupManager            = new EntityGroupManager(ComponentJobSafetyManager);

            m_ExclusiveEntityTransaction = new ExclusiveEntityTransaction(m_ArchetypeManager, m_GroupManager, m_SharedComponentManager, m_Entities);

            m_CachedComponentTypeArray            = (ComponentType *)UnsafeUtility.Malloc(sizeof(ComponentType) * 32 * 1024, 16, Allocator.Persistent);
            m_CachedComponentTypeInArchetypeArray = (ComponentTypeInArchetype *)UnsafeUtility.Malloc(sizeof(ComponentTypeInArchetype) * 32 * 1024, 16, Allocator.Persistent);
        }
Beispiel #6
0
        static SharedComponentDataManager()
        {
            TypeManager.Initialize();
            var assemblies = AppDomain.CurrentDomain.GetAssemblies();

            ISharedComponentDataType = typeof(ISharedComponentData);
            for (int i = 0; i < assemblies.Length; ++i)
            {
                var types = assemblies[i].GetTypes();
                for (int j = 0; j < types.Length; ++j)
                {
                    if (!types[j].IsValueType || !ISharedComponentDataType.IsAssignableFrom(types[j]) || (types[j].IsGenericType && types[j].IsGenericTypeDefinition))
                    {
                        continue;
                    }
                    TypeManager.GetTypeIndex(types[j]);
                }
            }
            for (int i = 1, length = TypeManager.GetTypeCount(); i < length; ++i)
            {
                var type = TypeManager.GetType(i);
                if (!type.IsValueType || !ISharedComponentDataType.IsAssignableFrom(type) || (type.IsGenericType && type.IsGenericTypeDefinition))
                {
                    continue;
                }
#if REF_EQUATABLE
                var EqualsMethodInfo = type.GetMethod("Equals", BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly, null, CallingConventions.Any, EqualsTypeArray, null);
                if (EqualsMethodInfo == null || EqualsMethodInfo.DeclaringType != type)
                {
                    throw new Exception(type.FullName);
                }
                var GetHashCodeMethodInfo = type.GetMethod("GetHashCode", BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly, null, CallingConventions.Any, Array.Empty <Type>(), null);
                if (GetHashCodeMethodInfo == null || GetHashCodeMethodInfo.DeclaringType != type)
                {
                    throw new Exception(type.FullName);
                }
#endif
                SharedComponentTypeStart = i;
                break;
            }
        }
        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
            }
                );
        }
Beispiel #8
0
        internal void Initialize(World world)
        {
            TypeManager.Initialize();
            StructuralChange.Initialize();
            EntityCommandBuffer.Initialize();

#if ENABLE_UNITY_COLLECTIONS_CHECKS
            m_Safety = AtomicSafetyHandle.Create();

#if UNITY_2020_1_OR_NEWER
            if (s_staticSafetyId.Data == 0)
            {
                CreateStaticSafetyId();
            }
            AtomicSafetyHandle.SetStaticSafetyId(ref m_Safety, s_staticSafetyId.Data);
#endif

            m_JobMode = false;
#endif
            m_EntityDataAccess = (EntityDataAccess *)UnsafeUtility.Malloc(sizeof(EntityDataAccess), 16, Allocator.Persistent);
            UnsafeUtility.MemClear(m_EntityDataAccess, sizeof(EntityDataAccess));
            EntityDataAccess.Initialize(m_EntityDataAccess, world);
        }