protected override void CreateSystems() { var managedType = typeof(ManagedComponentCleanupSystem <>); var collectionType = typeof(CollectionComponentCleanupSystem <>); var managedTagType = typeof(ManagedComponentTag <>); var managedSysStateType = typeof(ManagedComponentSystemStateTag <>); var collectionTagType = typeof(CollectionComponentTag <>); var collectionSysStateType = typeof(CollectionComponentSystemStateTag <>); var componentTypesAny = new NativeList <ComponentType>(Allocator.TempJob); var componentTypesNone = new NativeList <ComponentType>(Allocator.TempJob); var assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (var assembly in assemblies) { if (!BootstrapTools.IsAssemblyReferencingLatios(assembly)) { continue; } foreach (var type in assembly.GetTypes()) { if (type.GetCustomAttribute(typeof(DisableAutoTypeRegistration)) != null) { continue; } if (type == typeof(IComponent) || type == typeof(ICollectionComponent)) { continue; } if (typeof(IComponent).IsAssignableFrom(type)) { GetOrCreateAndAddSystem(managedType.MakeGenericType(type)); componentTypesAny.Add(ComponentType.ReadOnly(managedSysStateType.MakeGenericType(type))); componentTypesNone.Add(ComponentType.ReadOnly(managedTagType.MakeGenericType(type))); } else if (typeof(ICollectionComponent).IsAssignableFrom(type)) { GetOrCreateAndAddSystem(collectionType.MakeGenericType(type)); componentTypesAny.Add(ComponentType.ReadOnly(collectionSysStateType.MakeGenericType(type))); componentTypesNone.Add(ComponentType.ReadOnly(collectionTagType.MakeGenericType(type))); } } } EntityQueryDesc desc = new EntityQueryDesc { Any = componentTypesAny.ToArray(), None = componentTypesNone.ToArray() }; m_anythingNeedsUpdateQuery = GetEntityQuery(desc); componentTypesAny.Dispose(); componentTypesNone.Dispose(); }
public LatiosWorld(string name) : base(name) { BootstrapTools.PopulateTypeManagerWithGenerics(typeof(ManagedComponentTag <>), typeof(IComponent)); BootstrapTools.PopulateTypeManagerWithGenerics(typeof(ManagedComponentSystemStateTag <>), typeof(IComponent)); BootstrapTools.PopulateTypeManagerWithGenerics(typeof(CollectionComponentTag <>), typeof(ICollectionComponent)); BootstrapTools.PopulateTypeManagerWithGenerics(typeof(CollectionComponentSystemStateTag <>), typeof(ICollectionComponent)); worldGlobalEntity = new ManagedEntity(EntityManager.CreateEntity(), EntityManager); sceneGlobalEntity = new ManagedEntity(EntityManager.CreateEntity(), EntityManager); worldGlobalEntity.AddComponentData(new WorldGlobalTag()); sceneGlobalEntity.AddComponentData(new SceneGlobalTag()); m_initializationSystemGroup = GetOrCreateSystem <MyInitializationSystemGroup>(); m_simulationSystemGroup = GetOrCreateSystem <SimulationSystemGroup>(); m_presentationSystemGroup = GetOrCreateSystem <PresentationSystemGroup>(); }
public LatiosWorld(string name) : base(name) { //BootstrapTools.PopulateTypeManagerWithGenerics(typeof(ManagedComponentTag<>), typeof(IManagedComponent)); BootstrapTools.PopulateTypeManagerWithGenerics(typeof(ManagedComponentSystemStateTag <>), typeof(IManagedComponent)); //BootstrapTools.PopulateTypeManagerWithGenerics(typeof(CollectionComponentTag<>), typeof(ICollectionComponent)); BootstrapTools.PopulateTypeManagerWithGenerics(typeof(CollectionComponentSystemStateTag <>), typeof(ICollectionComponent)); worldGlobalEntity = new ManagedEntity(EntityManager.CreateEntity(), EntityManager); sceneGlobalEntity = new ManagedEntity(EntityManager.CreateEntity(), EntityManager); worldGlobalEntity.AddComponentData(new WorldGlobalTag()); sceneGlobalEntity.AddComponentData(new SceneGlobalTag()); #if UNITY_EDITOR EntityManager.SetName(worldGlobalEntity, "World Global Entity"); EntityManager.SetName(sceneGlobalEntity, "Scene Global Entity"); #endif m_initializationSystemGroup = GetOrCreateSystem <LatiosWorldInitializationSystemGroup>(); m_simulationSystemGroup = GetOrCreateSystem <LatiosSimulationSystemGroup>(); m_presentationSystemGroup = GetOrCreateSystem <LatiosPresentationSystemGroup>(); }