/// <summary>
        /// Engines root contextualize your engines and entities. You don't need to limit yourself to one EngineRoot
        /// as multiple engines root could promote separation of scopes. The EntitySubmissionScheduler checks
        /// periodically if new entity must be submitted to the database and the engines. It's an external
        /// dependencies to be independent by the running platform as the user can define it.
        /// The EntitySubmissionScheduler cannot hold an EnginesRoot reference, that's why
        /// it must receive a weak reference of the EnginesRoot callback.
        /// </summary>
        public EnginesRoot(IEntitiesSubmissionScheduler entitiesComponentScheduler)
        {
            _entitiesOperations        = new ThreadSafeDictionary <ulong, EntitySubmitOperation>();
            serializationDescriptorMap = new SerializationDescriptorMap();
            _reactiveEnginesAddRemove  = new FasterDictionary <RefWrapper <Type>, FasterList <IEngine> >();
            _reactiveEnginesSwap       = new FasterDictionary <RefWrapper <Type>, FasterList <IEngine> >();
            _enginesSet                  = new FasterList <IEngine>();
            _enginesTypeSet              = new HashSet <Type>();
            _disposableEngines           = new FasterList <IDisposable>();
            _transientEntitiesOperations = new FasterList <EntitySubmitOperation>();

            _groupEntityComponentsDB =
                new FasterDictionary <uint, FasterDictionary <RefWrapper <Type>, ITypeSafeDictionary> >();
            _groupsPerEntity    = new FasterDictionary <RefWrapper <Type>, FasterDictionary <uint, ITypeSafeDictionary> >();
            _groupedEntityToAdd = new DoubleBufferedEntitiesToAdd();

            _entitiesStream = new EntitiesStream();
            _entitiesDB     = new EntitiesDB(_groupEntityComponentsDB, _groupsPerEntity, _entitiesStream);

            scheduler        = entitiesComponentScheduler;
            scheduler.onTick = new EntitiesSubmitter(this);
#if UNITY_BURST
            AllocateNativeOperations();
#endif
        }
        /// <summary>
        /// Engines root contextualize your engines and entities. You don't need to limit yourself to one EngineRoot
        /// as multiple engines root could promote separation of scopes. The EntitySubmissionScheduler checks
        /// periodically if new entity must be submitted to the database and the engines. It's an external
        /// dependencies to be independent by the running platform as the user can define it.
        /// The EntitySubmissionScheduler cannot hold an EnginesRoot reference, that's why
        /// it must receive a weak reference of the EnginesRoot callback.
        /// </summary>
        public EnginesRoot(EntitySubmissionScheduler entityViewScheduler)
        {
            _entityEngines = new Dictionary <Type, FasterList <IHandleEntityViewEngineAbstracted> >();
            _otherEngines  = new FasterList <IEngine>();

            _groupEntityDB      = new Dictionary <int, Dictionary <Type, ITypeSafeDictionary> >();
            _groupedGroups      = new Dictionary <Type, FasterDictionary <int, ITypeSafeDictionary> >();
            _groupedEntityToAdd = new DoubleBufferedEntitiesToAdd <Dictionary <int, Dictionary <Type, ITypeSafeDictionary> > >();

            _DB = new EntitiesDB(_groupEntityDB, _groupedGroups);

            _scheduler = entityViewScheduler;
            _scheduler.Schedule(new WeakAction(SubmitEntityViews));
        }
Exemple #3
0
        /// <summary>
        /// Engines root contextualize your engines and entities. You don't need to limit yourself to one EngineRoot
        /// as multiple engines root could promote separation of scopes. The EntitySubmissionScheduler checks
        /// periodically if new entity must be submitted to the database and the engines. It's an external
        /// dependencies to be independent by the running platform as the user can define it.
        /// The EntitySubmissionScheduler cannot hold an EnginesRoot reference, that's why
        /// it must receive a weak reference of the EnginesRoot callback.
        /// </summary>
        public EnginesRoot(IEntitySubmissionScheduler entityViewScheduler)
        {
            _entitiesOperations       = new FasterDictionary <ulong, EntitySubmitOperation>();
            _reactiveEnginesAddRemove = new Dictionary <Type, FasterList <IEngine> >();
            _reactiveEnginesSwap      = new Dictionary <Type, FasterList <IEngine> >();
            _enginesSet                  = new HashSet <IEngine>();
            _disposableEngines           = new FasterList <IDisposable>();
            _transientEntitiesOperations = new FasterList <EntitySubmitOperation>();

            _groupEntityDB      = new FasterDictionary <uint, Dictionary <Type, ITypeSafeDictionary> >();
            _groupsPerEntity    = new Dictionary <Type, FasterDictionary <uint, ITypeSafeDictionary> >();
            _groupedEntityToAdd = new DoubleBufferedEntitiesToAdd();

            _entitiesStream = new EntitiesStream();
            _entitiesDB     = new EntitiesDB(_groupEntityDB, _groupsPerEntity, _entitiesStream);

            _scheduler        = entityViewScheduler;
            _scheduler.onTick = new WeakAction(SubmitEntityViews);
        }
        /// <summary>
        /// Engines root contextualize your engines and entities. You don't need to limit yourself to one EngineRoot
        /// as multiple engines root could promote separation of scopes. The EntitySubmissionScheduler checks
        /// periodically if new entity must be submitted to the database and the engines. It's an external
        /// dependencies to be independent by the running platform as the user can define it.
        /// The EntitySubmissionScheduler cannot hold an EnginesRoot reference, that's why
        /// it must receive a weak reference of the EnginesRoot callback.
        /// </summary>
        public EnginesRoot(IEntitySubmissionScheduler entityViewScheduler)
        {
#if DEBUG && !PROFILER
            _entitiesOperationsDebug = new FasterDictionary <long, EntitySubmitOperationType>();
#endif
            _entitiesOperations          = new FasterList <EntitySubmitOperation>();
            _entityEngines               = new Dictionary <Type, FasterList <IHandleEntityViewEngineAbstracted> >();
            _enginesSet                  = new HashSet <IEngine>();
            _disposableEngines           = new FasterList <IDisposable>();
            _transientEntitiesOperations = new FasterList <EntitySubmitOperation>();

            _groupEntityDB      = new FasterDictionary <int, Dictionary <Type, ITypeSafeDictionary> >();
            _groupsPerEntity    = new Dictionary <Type, FasterDictionary <int, ITypeSafeDictionary> >();
            _groupedEntityToAdd = new DoubleBufferedEntitiesToAdd <FasterDictionary <int, Dictionary <Type, ITypeSafeDictionary> > >();

            _entitiesDB     = new EntitiesDB(_groupEntityDB, _groupsPerEntity);
            _entitiesStream = new EntitiesStream(_entitiesDB);

            _scheduler        = entityViewScheduler;
            _scheduler.onTick = new WeakAction(SubmitEntityViews);
        }
        /// <summary>
        ///     Engines root contextualize your engines and entities. You don't need to limit yourself to one EngineRoot
        ///     as multiple engines root could promote separation of scopes. The EntitySubmissionScheduler checks
        ///     periodically if new entity must be submitted to the database and the engines. It's an external
        ///     dependencies to be independent by the running platform as the user can define it.
        ///     The EntitySubmissionScheduler cannot hold an EnginesRoot reference, that's why
        ///     it must receive a weak reference of the EnginesRoot callback.
        /// </summary>
        public EnginesRoot(EntitiesSubmissionScheduler entitiesComponentScheduler)
        {
            _entitiesOperations = new FasterDictionary <ulong, EntitySubmitOperation>();
            _idChecker          = new FasterDictionary <ExclusiveGroupStruct, HashSet <uint> >();
            _multipleOperationOnSameEGIDChecker = new FasterDictionary <EGID, uint>();
#if UNITY_NATIVE //because of the thread count, ATM this is only for unity
            _nativeSwapOperationQueue   = new DataStructures.AtomicNativeBags(Allocator.Persistent);
            _nativeRemoveOperationQueue = new DataStructures.AtomicNativeBags(Allocator.Persistent);
            _nativeAddOperationQueue    = new DataStructures.AtomicNativeBags(Allocator.Persistent);
#endif
            _serializationDescriptorMap        = new SerializationDescriptorMap();
            _maxNumberOfOperationsPerFrame     = uint.MaxValue;
            _reactiveEnginesAddRemove          = new FasterDictionary <RefWrapperType, FasterList <ReactEngineContainer> >();
            _reactiveEnginesAddRemoveOnDispose =
                new FasterDictionary <RefWrapperType, FasterList <ReactEngineContainer> >();
            _reactiveEnginesSwap       = new FasterDictionary <RefWrapperType, FasterList <ReactEngineContainer> >();
            _reactiveEnginesSubmission = new FasterList <IReactOnSubmission>();
            _enginesSet                  = new FasterList <IEngine>();
            _enginesTypeSet              = new HashSet <Type>();
            _disposableEngines           = new FasterList <IDisposable>();
            _transientEntitiesOperations = new FasterList <EntitySubmitOperation>();

            _groupEntityComponentsDB =
                new FasterDictionary <ExclusiveGroupStruct, FasterDictionary <RefWrapperType, ITypeSafeDictionary> >();
            _groupsPerEntity =
                new FasterDictionary <RefWrapperType, FasterDictionary <ExclusiveGroupStruct, ITypeSafeDictionary> >();
            _groupedEntityToAdd = new DoubleBufferedEntitiesToAdd();
            _entityStreams      = EntitiesStreams.Create();
            _groupFilters       =
                new FasterDictionary <RefWrapperType, FasterDictionary <ExclusiveGroupStruct, GroupFilters> >();
            _entityLocator.InitEntityReferenceMap();
            _entitiesDB = new EntitiesDB(this, _entityLocator);

            scheduler        = entitiesComponentScheduler;
            scheduler.onTick = new EntitiesSubmitter(this);
#if UNITY_NATIVE
            AllocateNativeOperations();
#endif
        }