Esempio n. 1
0
        public void EntityCreationOfMultipleEntities()
        {
            ECSManager manager = ECSManagerFactory.CreateECSManager();

            List <Entity> entities = new List <Entity>(128);

            for (int i = 0; i < 128; i++)
            {
                Entity newEntity = manager.CreateEntity();
                entities.Add(newEntity);
            }

            manager.Update(new GameTime());

            for (int i = 0; i < 128; i++)
            {
                Entity newEntity = manager.CreateEntity();
                entities.Add(newEntity);

                Entity entityForDestroy = entities[0];
                entities.RemoveAt(0);
                entityForDestroy.Destroy();

                manager.Update(new GameTime());
            }
        }
Esempio n. 2
0
        public void EntityCreationAndRetrievingBasicComponent()
        {
            ECSManager manager = ECSManagerFactory.CreateECSManager();

            Entity newEntity = manager.CreateEntity();

            Assert.IsNotNull(newEntity.GetComponentOrDefault <Transform2DComponent>());
            Assert.IsNotNull(newEntity.Transform);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            // fisrt of all, perform scanning of assemblies for factory
            ECSManagerFactory.ScanAssemblies(AppDomain.CurrentDomain.GetAssemblies());

            // after that, we can create ECS Manager
            ECSManager manager = ECSManagerFactory.CreateECSManager();

            // let's create first entity!
            Entity firstEntity = manager.CreateEntity();

            // now let's get transform component and move entity a little bit
            Transform2DComponent component = firstEntity.GetComponentOrDefault <Transform2DComponent>();

            component.Position += new Vector2(10, 10);

            // attach a new component and change its values
            TestComponent newComponent = firstEntity.AttachComponent <TestComponent>();

            newComponent.Variable1 += 10;

            GameTime testGameTime = new GameTime(TimeSpan.FromMilliseconds(100), TimeSpan.FromMilliseconds(100));

            // here is the call of Update()
            // All routine, connected to creation of entities, attaching of components and etc. is performed within Update()
            manager.Update(testGameTime);

            // it is better to call Draw, isn't it?
            manager.Draw(testGameTime);

            // here is the one more call of Update()
            // Now all components are registered and can be processed in Systems
            manager.Update(testGameTime);

            // Now it is time to shutdown ECS manager - lets perform unloading of content
            manager.UnloadContent();
        }
Esempio n. 4
0
 public EntityFlowUnitTests()
 {
     ECSManagerFactory.ScanAssemblies(AppDomain.CurrentDomain.GetAssemblies());
 }