/// <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>(); serializationDescriptorMap = new SerializationDescriptorMap(); _reactiveEnginesAddRemove = new FasterDictionary <RefWrapperType, FasterList <IReactEngine> >(); _reactiveEnginesAddRemoveOnDispose = new FasterDictionary <RefWrapperType, FasterList <IReactEngine> >(); _reactiveEnginesSwap = new FasterDictionary <RefWrapperType, FasterList <IReactEngine> >(); _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> >(); _entitiesDB = new EntitiesDB(this); _scheduler = entitiesComponentScheduler; _scheduler.onTick = new EntitiesSubmitter(this); #if UNITY_NATIVE 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(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(EntitiesSubmissionScheduler entitiesComponentScheduler) { _entitiesOperations = new EntitiesOperations(); _idChecker = new FasterDictionary <ExclusiveGroupStruct, HashSet <uint> >(); _cachedRangeOfSubmittedIndices = new FasterList <(uint, uint)>(); _cachedIndicesToSwapBeforeSubmissionForFilters = new FasterDictionary <uint, uint>(); _multipleOperationOnSameEGIDChecker = new FasterDictionary <EGID, uint>(); #if UNITY_NATIVE //because of the thread count, ATM this is only for unity _nativeSwapOperationQueue = new Svelto.ECS.DataStructures.AtomicNativeBags(Allocator.Persistent); _nativeRemoveOperationQueue = new Svelto.ECS.DataStructures.AtomicNativeBags(Allocator.Persistent); _nativeAddOperationQueue = new Svelto.ECS.DataStructures.AtomicNativeBags(Allocator.Persistent); #endif _serializationDescriptorMap = new SerializationDescriptorMap(); _reactiveEnginesAdd = new FasterDictionary <RefWrapperType, FasterList <ReactEngineContainer <IReactOnAdd> > >(); _reactiveEnginesAddEx = new FasterDictionary <RefWrapperType, FasterList <ReactEngineContainer <IReactOnAddEx> > >(); _reactiveEnginesRemove = new FasterDictionary <RefWrapperType, FasterList <ReactEngineContainer <IReactOnRemove> > >(); _reactiveEnginesRemoveEx = new FasterDictionary <RefWrapperType, FasterList <ReactEngineContainer <IReactOnRemoveEx> > >(); _reactiveEnginesSwap = new FasterDictionary <RefWrapperType, FasterList <ReactEngineContainer <IReactOnSwap> > >(); _reactiveEnginesSwapEx = new FasterDictionary <RefWrapperType, FasterList <ReactEngineContainer <IReactOnSwapEx> > >(); _reactiveEnginesDispose = new FasterDictionary <RefWrapperType, FasterList <ReactEngineContainer <IReactOnDispose> > >(); _reactiveEnginesSubmission = new FasterList <IReactOnSubmission>(); _enginesSet = new FasterList <IEngine>(); _enginesTypeSet = new HashSet <Type>(); _disposableEngines = new FasterList <IDisposable>(); _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, LegacyGroupFilters> >(); _entityLocator.InitEntityReferenceMap(); _entitiesDB = new EntitiesDB(this, _entityLocator); InitFilters(); scheduler = entitiesComponentScheduler; scheduler.onTick = new EntitiesSubmitter(this); #if UNITY_NATIVE AllocateNativeOperations(); #endif }
static EnginesRoot() { GroupHashMap.Init(); SharedDictonary.Init(); SerializationDescriptorMap.Init(); _swapEntities = SwapEntities; _removeEntities = RemoveEntities; _removeGroup = RemoveGroup; _swapGroup = SwapGroup; }
/// <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 }
static EnginesRoot() { GroupHashMap.Init(); SerializationDescriptorMap.Init(); }