Example #1
0
        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;
 }
Example #3
0
 public BatchManager(IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup, IBatchBuilderFactory batchBuilderFactory, IReferenceBatchBuilderFactory referenceBatchBuilderFactory, IObservableGroupManager observableGroupManager)
 {
     ComponentDatabase            = componentDatabase;
     ComponentTypeLookup          = componentTypeLookup;
     BatchBuilderFactory          = batchBuilderFactory;
     ObservableGroupManager       = observableGroupManager;
     ReferenceBatchBuilderFactory = referenceBatchBuilderFactory;
 }
Example #4
0
        protected BatchAccessor(IObservableGroup observableGroup, IComponentDatabase componentDatabase, IBatchBuilder batchBuilder, IComponentTypeLookup componentTypeLookup)
        {
            ObservableGroup     = observableGroup;
            ComponentDatabase   = componentDatabase;
            BatchBuilder        = batchBuilder;
            ComponentTypeLookup = componentTypeLookup;

            SetupAccessor();
        }
Example #5
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();
        }
Example #6
0
 protected BatchedSystem(IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup,
                         IBatchBuilderFactory batchBuilderFactory, IThreadHandler threadHandler) : base(componentDatabase,
                                                                                                        componentTypeLookup, threadHandler)
 {
     _batchBuilder = batchBuilderFactory.Create <T1, T2>();
 }
 public ExampleBatchedSystem(IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup,
                             IReferenceBatchBuilderFactory batchBuilderFactory, IThreadHandler threadHandler, IObservableGroupManager observableGroupManager)
     : base(componentDatabase, componentTypeLookup, batchBuilderFactory, threadHandler, observableGroupManager)
 {
 }
Example #8
0
 public ExampleBatchedGroupSystem(IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup, IReferenceBatchBuilderFactory batchBuilderFactory, IThreadHandler threadHandler) : base(componentDatabase, componentTypeLookup, batchBuilderFactory, threadHandler)
 {
 }
Example #9
0
 public BatchedMovementSystem(IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup, IBatchBuilderFactory batchBuilderFactory, IThreadHandler threadHandler) : base(componentDatabase, componentTypeLookup, batchBuilderFactory, threadHandler)
 {
 }
Example #10
0
 public DefaultEntityFactory(IIdPool idPool, IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup)
 {
     IdPool              = idPool;
     ComponentDatabase   = componentDatabase;
     ComponentTypeLookup = componentTypeLookup;
 }
Example #11
0
 protected ReferenceBatchedSystem(IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup,
                                  IReferenceBatchBuilderFactory batchBuilderFactory, IThreadHandler threadHandler, IObservableGroupManager observableGroupManager) : base(componentDatabase,
                                                                                                                                                                          componentTypeLookup, threadHandler, observableGroupManager)
 {
     _batchBuilder = batchBuilderFactory.Create <T1, T2>();
 }
Example #12
0
 protected ManualBatchedSystem(IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup, IThreadHandler threadHandler)
 {
     ComponentDatabase   = componentDatabase;
     ComponentTypeLookup = componentTypeLookup;
     ThreadHandler       = threadHandler;
 }
Example #13
0
 public BatchBuilderFactory(IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup)
 {
     ComponentDatabase   = componentDatabase;
     ComponentTypeLookup = componentTypeLookup;
 }
 public ComponentRepository(IComponentTypeLookup componentLookup, IComponentDatabase database, int defaultExpansionSize = 100)
 {
     ComponentLookup      = componentLookup;
     DefaultExpansionSize = defaultExpansionSize;
     Database             = database;
 }
Example #15
0
 public static IComponent Get(this IComponentDatabase componentDatabase, int allocationIndex, int componentTypeId)
 {
     return(componentDatabase.Get <IComponent>(componentTypeId, allocationIndex));
 }
Example #16
0
 public ReferenceBatchAccessor(IObservableGroup observableGroup, IComponentDatabase componentDatabase, IBatchBuilder batchBuilder, IComponentTypeLookup componentTypeLookup) : base(observableGroup, componentDatabase, batchBuilder, componentTypeLookup)
 {
 }
Example #17
0
 public BatchBuilder(IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup)
 {
     ComponentDatabase = componentDatabase;
     _componentTypeId1 = componentTypeLookup.GetComponentType(typeof(T1));
     _componentTypeId2 = componentTypeLookup.GetComponentType(typeof(T2));
 }
Example #18
0
 public BatchedMovementSystem(IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup, IBatchBuilderFactory batchBuilderFactory, IThreadHandler threadHandler, IObservableGroupManager observableGroupManager)
     : base(componentDatabase, componentTypeLookup, batchBuilderFactory, threadHandler, observableGroupManager)
 {
 }