示例#1
0
        public void RemovesEntityFromSystem()
        {
            var oneComponentSystem = new OneComponentSystem();

            var manager = new RuntimeSystemManager(new ISystem[] {oneComponentSystem}, Mock.Of<ILogger>());

            var oneComponentEntity = new EngineEntity(0, new IComponent[] {new SimpleComponent()},
                Mock.Of<IEventDispatcher>());

            manager.AddEntities(new[] {oneComponentEntity});
            manager.RemoveEntities(new[] {oneComponentEntity});

            manager.Systems.Single().Entities.ShouldNotContain(oneComponentEntity);
        }
示例#2
0
        public void CorrectlyFilterEntitiesIntoSystemInstances()
        {
            var oneComponentSystem = new OneComponentSystem();
            var twoComponentSystem = new TwoComponentSystem();

            var manager = new RuntimeSystemManager(new ISystem[] {oneComponentSystem, twoComponentSystem}, Mock.Of<ILogger>());

            var oneComponentEntity = new EngineEntity(0, new IComponent[] {new SimpleComponent()},
                Mock.Of<IEventDispatcher>());

            var twoComponentEntity = new EngineEntity(0,
                new IComponent[] {new SimpleComponent(), new OtherSimpleComponent(),},
                Mock.Of<IEventDispatcher>());

            manager.AddEntities(new[] {oneComponentEntity, twoComponentEntity});

            manager.Systems.Single(p => p.System == oneComponentSystem).Entities.ShouldContain(oneComponentEntity);
            manager.Systems.Single(p => p.System == oneComponentSystem).Entities.ShouldContain(twoComponentEntity);

            manager.Systems.Single(p => p.System == twoComponentSystem).Entities.ShouldContain(twoComponentEntity);
            manager.Systems.Single(p => p.System == twoComponentSystem).Entities.ShouldNotContain(oneComponentEntity);
        }