Example #1
0
        public void SystemWithoutComponent()
        {
            var componentContainers = new Dictionary <Type, PlainDictionary>();
            var bindings            = SystemBinder.BindSystem(new SoloSystem(), componentContainers);

            Assert.That(bindings.Count, Is.EqualTo(1));
            Assert.That(bindings[0], Is.TypeOf <SystemBindingWithoutComponents>());
        }
Example #2
0
        public void SystemWithOneComponent()
        {
            var componentContainers = new Dictionary <Type, PlainDictionary>
            {
                { typeof(ComponentA), new Dictionary <int, ComponentA>() }
            };

            var bindings = SystemBinder.BindSystem(new MonoSystem(), componentContainers);

            Assert.That(bindings.Count, Is.EqualTo(1));
            Assert.That(bindings[0], Is.TypeOf <SystemBindingWithOneComponent>());
        }
        public ParallelPipeline Build(ServiceContainer serviceContainer)
        {
            var ordered = CoffmanGrahamOrderer.Order(this.SystemSpecs);
            var stages  = CoffmanGrahamOrderer.DivideIntoStages(ordered);

            var pipelineStages = new List <PipelineStage>();

            for (var i = 0; i < stages.Count; i++)
            {
                var systemBindings = new List <ISystemBinding>();
                var stage          = stages[i];
                for (var j = 0; j < stage.Count; j++)
                {
                    var systemSpec = stage[j];
                    var system     = (ISystem)serviceContainer.GetInstance(systemSpec.SystemType);
                    systemBindings.AddRange(SystemBinder.BindSystem(system, this.ComponentContainers));
                }

                pipelineStages.Add(new PipelineStage(systemBindings));
            }

            return(new ParallelPipeline(pipelineStages));
        }