protected override void ApplicationStarted()
        {
            _componentTypeLookup          = Container.Resolve <IComponentTypeLookup>();
            _componentDatabase            = Container.Resolve <IComponentDatabase>();
            _batchBuilderFactory          = Container.Resolve <IBatchBuilderFactory>();
            _referenceBatchBuilderFactory = Container.Resolve <IReferenceBatchBuilderFactory>();
            _collection = EntityCollectionManager.GetCollection();

            ClassComponent1TypeId  = _componentTypeLookup.GetComponentType(typeof(ClassComponent));
            ClassComponent2TypeId  = _componentTypeLookup.GetComponentType(typeof(ClassComponent2));
            StructComponent1TypeId = _componentTypeLookup.GetComponentType(typeof(StructComponent));
            StructComponent2TypeId = _componentTypeLookup.GetComponentType(typeof(StructComponent2));

            var name = GetType().Name;

            Console.WriteLine($"{name} - {Description}");
            var timer = Stopwatch.StartNew();

            SetupEntities();
            timer.Stop();
            Console.WriteLine($"{name} - Setting up {EntityCount} entities in {timer.ElapsedMilliseconds}ms");

            timer.Reset();
            timer.Start();
            for (var update = 0; update < SimulatedUpdates; update++)
            {
                RunProcess();
            }
            timer.Stop();
            var totalProcessTime = TimeSpan.FromMilliseconds(timer.ElapsedMilliseconds);

            Console.WriteLine($"{name} - Simulating {SimulatedUpdates} updates - Processing {EntityCount} entities in {totalProcessTime.TotalMilliseconds}ms");
            Console.WriteLine();
        }
 protected ManualBatchedSystem(IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup, IThreadHandler threadHandler, IObservableGroupManager observableGroupManager)
 {
     ComponentDatabase      = componentDatabase;
     ComponentTypeLookup    = componentTypeLookup;
     ThreadHandler          = threadHandler;
     ObservableGroupManager = observableGroupManager;
 }
Exemple #3
0
        public static EntitasGameEntity <TEntity> Allocate(TEntity entity, IComponentTypeLookup lookup)
        {
            var rc = ObjectAllocatorHolder <EntitasGameEntity <TEntity> > .Allocate();

            rc.Init(entity, lookup);
            return(rc);
        }
        public ObservableGroupManager(IObservableGroupFactory observableGroupFactory, IEntityDatabase entityDatabase, IComponentTypeLookup componentTypeLookup)
        {
            ObservableGroupFactory = observableGroupFactory;
            EntityDatabase         = entityDatabase;
            ComponentTypeLookup    = componentTypeLookup;

            _observableGroups = new ObservableGroupLookup();
        }
Exemple #5
0
 public BatchManager(IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup, IBatchBuilderFactory batchBuilderFactory, IReferenceBatchBuilderFactory referenceBatchBuilderFactory, IObservableGroupManager observableGroupManager)
 {
     ComponentDatabase            = componentDatabase;
     ComponentTypeLookup          = componentTypeLookup;
     BatchBuilderFactory          = batchBuilderFactory;
     ObservableGroupManager       = observableGroupManager;
     ReferenceBatchBuilderFactory = referenceBatchBuilderFactory;
 }
 public void Init(TEntity entity, IComponentTypeLookup lookup)
 {
     this.entity = entity;
     this.lookup = lookup;
     entity.AddOnComponentAdded(entityOnOnComponentAddedCache);
     entity.AddOnComponentRemoved(entityOnOnComponentRemovedCache);
     entity.AddOnComponentReplaced(entityOnOnComponentReplacedCache);
     entity.AddOnDestroyEntity(entityOnOnDestroyEntityCache);
 }
Exemple #7
0
        protected BatchAccessor(IObservableGroup observableGroup, IComponentDatabase componentDatabase, IBatchBuilder batchBuilder, IComponentTypeLookup componentTypeLookup)
        {
            ObservableGroup     = observableGroup;
            ComponentDatabase   = componentDatabase;
            BatchBuilder        = batchBuilder;
            ComponentTypeLookup = componentTypeLookup;

            SetupAccessor();
        }
Exemple #8
0
 public void Init(TEntity entity, IComponentTypeLookup lookup)
 {
     _entity = entity;
     _lookup = lookup;
     _entity.AddOnComponentAdded(_entityOnOnComponentAddedCache);
     _entity.AddOnComponentRemoved(_entityOnOnComponentRemovedCache);
     _entity.AddOnComponentReplaced(_entityOnOnComponentReplacedCache);
     _entity.AddOnDestroyEntity(_entityOnOnDestroyEntityCache);
 }
Exemple #9
0
        public Entity(int id, IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup)
        {
            Id = id;
            ComponentDatabase   = componentDatabase;
            ComponentTypeLookup = componentTypeLookup;

            var totalComponentCount = componentTypeLookup.AllComponentTypeIds.Length;

            InternalComponentAllocations = new int[totalComponentCount];

            _onComponentsAdded    = new Subject <int[]>();
            _onComponentsRemoving = new Subject <int[]>();
            _onComponentsRemoved  = new Subject <int[]>();

            EmptyAllAllocations();
        }
Exemple #10
0
        public EntityCollectionManager(IEntityCollectionFactory entityCollectionFactory, IObservableGroupFactory observableGroupFactory, IComponentTypeLookup componentTypeLookup)
        {
            EntityCollectionFactory = entityCollectionFactory;
            ObservableGroupFactory  = observableGroupFactory;
            ComponentTypeLookup     = componentTypeLookup;

            _observableGroups           = new ObservableGroupLookup();
            _collections                = new CollectionLookup();
            _collectionSubscriptions    = new Dictionary <int, IDisposable>();
            _onCollectionAdded          = new Subject <IEntityCollection>();
            _onCollectionRemoved        = new Subject <IEntityCollection>();
            _onEntityAdded              = new Subject <CollectionEntityEvent>();
            _onEntityRemoved            = new Subject <CollectionEntityEvent>();
            _onEntityComponentsAdded    = new Subject <ComponentsChangedEvent>();
            _onEntityComponentsRemoving = new Subject <ComponentsChangedEvent>();
            _onEntityComponentsRemoved  = new Subject <ComponentsChangedEvent>();


            CreateCollection(PoolLookups.DefaultPoolId);
        }
Exemple #11
0
        public EntityCollectionManager(IEntityCollectionFactory collectionFactory, IObservableGroupFactory groupFactory,
                                       IComponentTypeLookup componentTypeLookup)
        {
            CollectionFactory   = collectionFactory;
            GroupFactory        = groupFactory;
            ComponentTypeLookup = componentTypeLookup;

            observableGroups         = new Dictionary <ObservableGroupToken, IObservableGroup>();
            collections              = new Dictionary <string, IEntityCollection>();
            subscriptions            = new Dictionary <string, IDisposable>();
            entityAdded              = new Subject <CollectionEntityEvent>();
            entityRemoved            = new Subject <CollectionEntityEvent>();
            entityComponentsAdded    = new Subject <ComponentsChangedEvent>();
            entityComponentsRemoving = new Subject <ComponentsChangedEvent>();
            entityComponentsRemoved  = new Subject <ComponentsChangedEvent>();
            collectionAdded          = new Subject <IEntityCollection>();
            collectionRemoved        = new Subject <IEntityCollection>();

            CreateCollection(DefaultPoolName);
        }
 public DefaultEntityFactory(IIdPool idPool, IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup)
 {
     IdPool              = idPool;
     ComponentDatabase   = componentDatabase;
     ComponentTypeLookup = componentTypeLookup;
 }
Exemple #13
0
 public ExampleBatchedGroupSystem(IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup, IReferenceBatchBuilderFactory batchBuilderFactory, IThreadHandler threadHandler) : base(componentDatabase, componentTypeLookup, batchBuilderFactory, threadHandler)
 {
 }
Exemple #14
0
 public ComponentDatabase(IComponentTypeLookup componentTypeLookup, int defaultExpansionSize = 100)
 {
     ComponentTypeLookup    = componentTypeLookup;
     DefaultExpansionAmount = defaultExpansionSize;
     Initialize();
 }
Exemple #15
0
 public ComponentRepository(IComponentTypeLookup lookup, IComponentStore store, int expansionSize = 1024)
 {
     Lookup = lookup;
     Store  = store;
 }
Exemple #16
0
 protected BatchedSystem(IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup,
                         IBatchBuilderFactory batchBuilderFactory, IThreadHandler threadHandler) : base(componentDatabase,
                                                                                                        componentTypeLookup, threadHandler)
 {
     _batchBuilder = batchBuilderFactory.Create <T1, T2>();
 }
 public ComponentRepository(IComponentTypeLookup componentLookup, IComponentDatabase database, int defaultExpansionSize = 100)
 {
     ComponentLookup      = componentLookup;
     DefaultExpansionSize = defaultExpansionSize;
     Database             = database;
 }
 public ExampleBatchedSystem(IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup,
                             IReferenceBatchBuilderFactory batchBuilderFactory, IThreadHandler threadHandler, IObservableGroupManager observableGroupManager)
     : base(componentDatabase, componentTypeLookup, batchBuilderFactory, threadHandler, observableGroupManager)
 {
 }
 public ReferenceBatchAccessor(IObservableGroup observableGroup, IComponentDatabase componentDatabase, IBatchBuilder batchBuilder, IComponentTypeLookup componentTypeLookup) : base(observableGroup, componentDatabase, batchBuilder, componentTypeLookup)
 {
 }
 public ComponentDatabase(IComponentTypeLookup componentTypeLookup, int entitySetupSize = 500)
 {
     ComponentTypeLookup = componentTypeLookup;
     Initialize(entitySetupSize);
 }
 public BatchBuilderFactory(IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup)
 {
     ComponentDatabase   = componentDatabase;
     ComponentTypeLookup = componentTypeLookup;
 }
Exemple #22
0
 protected ManualBatchedSystem(IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup, IThreadHandler threadHandler)
 {
     ComponentDatabase   = componentDatabase;
     ComponentTypeLookup = componentTypeLookup;
     ThreadHandler       = threadHandler;
 }
Exemple #23
0
 protected ReferenceBatchedSystem(IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup,
                                  IReferenceBatchBuilderFactory batchBuilderFactory, IThreadHandler threadHandler, IObservableGroupManager observableGroupManager) : base(componentDatabase,
                                                                                                                                                                          componentTypeLookup, threadHandler, observableGroupManager)
 {
     _batchBuilder = batchBuilderFactory.Create <T1, T2>();
 }
Exemple #24
0
 public ComponentStore(IComponentTypeLookup componentTypeLookup, int entityCapacity = 1024)
 {
     ComponentTypeLookup = componentTypeLookup;
     Initialize(entityCapacity);
 }
 public BatchedMovementSystem(IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup, IBatchBuilderFactory batchBuilderFactory, IThreadHandler threadHandler) : base(componentDatabase, componentTypeLookup, batchBuilderFactory, threadHandler)
 {
 }
Exemple #26
0
 public BatchBuilder(IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup)
 {
     ComponentDatabase = componentDatabase;
     _componentTypeId1 = componentTypeLookup.GetComponentType(typeof(T1));
     _componentTypeId2 = componentTypeLookup.GetComponentType(typeof(T2));
 }
Exemple #27
0
 public BatchedMovementSystem(IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup, IBatchBuilderFactory batchBuilderFactory, IThreadHandler threadHandler, IObservableGroupManager observableGroupManager)
     : base(componentDatabase, componentTypeLookup, batchBuilderFactory, threadHandler, observableGroupManager)
 {
 }