protected override void ApplicationStarted()
        {
            _availableComponents = _groupFactory.GetComponentTypes
                                   .Select(x => Activator.CreateInstance(x) as IComponent)
                                   .ToArray();

            _availableComponentTypeIds = Enumerable.Range(0, _availableComponents.Length - 1).ToArray();

            var groups           = _groupFactory.CreateTestGroups(10).ToArray();
            var observableGroups = new List <IObservableGroup>();

            foreach (var group in groups)
            {
                var newGroup = ObservableGroupManager.GetObservableGroup(group);
                observableGroups.Add(newGroup);
            }

            var firstRun  = ProcessEntities(ProcessCount);
            var secondRun = ProcessEntities(ProcessCount);
            var thirdRun  = ProcessEntities(ProcessCount);

            Console.WriteLine($"Processing with {_availableComponents.Length} components and {observableGroups.Count} Observable groups");
            Console.WriteLine($"Finished In: {(firstRun + secondRun + thirdRun).TotalSeconds}s");
            Console.WriteLine($"First Took: {firstRun.TotalSeconds}s");
            Console.WriteLine($"Second Took: {secondRun.TotalSeconds}s");
            Console.WriteLine($"Third Took: {thirdRun.TotalSeconds}s");
        }
Beispiel #2
0
        protected override void ApplicationStarted()
        {
            var collection = EntityDatabase.GetCollection();

            for (var i = 0; i < _cubeCount; i++)
            {
                var viewEntity = collection.CreateEntity();
                viewEntity.AddComponents(new ViewComponent(), new RandomColorComponent());
            }

            var group = ObservableGroupManager.GetObservableGroup(new Group(typeof(ViewComponent), typeof(RandomColorComponent)));

            Debug.Log($"There are {group.Count} entities out of {collection.Count} matching");
        }
        public virtual void StartSystem()
        {
            ObservableGroup   = ObservableGroupManager.GetObservableGroup(Group);
            ShouldParallelize = this.ShouldMutliThread();

            var subscriptions = new CompositeDisposable();

            ProcessGroupSubscription(ObservableGroup.OnEntityAdded)
            .Subscribe(_ => RebuildBatch())
            .AddTo(subscriptions);

            ProcessGroupSubscription(ObservableGroup.OnEntityRemoved)
            .Subscribe(_ => RebuildBatch())
            .AddTo(subscriptions);

            RebuildBatch();
            ReactWhen().Subscribe(_ => RunBatch()).AddTo(subscriptions);

            Subscriptions = subscriptions;
        }
Beispiel #4
0
        protected override void ApplicationStarted()
        {
            _availableComponents = _groupFactory.GetComponentTypes
                                   .Select(x => Activator.CreateInstance(x) as IComponent)
                                   .ToArray();

            var groups = _groupFactory.CreateTestGroups().ToArray();

            foreach (var group in groups)
            {
                ObservableGroupManager.GetObservableGroup(group);
            }

            var firstRun  = ProcessEntities(10000);
            var secondRun = ProcessEntities(10000);
            var thirdRun  = ProcessEntities(10000);

            Console.WriteLine($"Finished In: {(firstRun + secondRun + thirdRun).TotalSeconds}s");
            Console.WriteLine($"First Took: {firstRun.TotalSeconds}s");
            Console.WriteLine($"Second Took: {secondRun.TotalSeconds}s");
            Console.WriteLine($"Third Took: {thirdRun.TotalSeconds}s");
        }