示例#1
0
        public static void SystemComunicationTeste()
        {
            EntitySystem.BlackBoard.SetEntry <int>("Damage", 5);

            EntityWorld              world                    = new EntityWorld();
            SystemManager            systemManager            = world.SystemManager;
            DummyCommunicationSystem DummyCommunicationSystem = new DummyCommunicationSystem();

            systemManager.SetSystem(DummyCommunicationSystem, ExecutionType.Update);
            systemManager.InitializeAll();

            List <Entity> l = new List <Entity>();

            for (int i = 0; i < 100; i++)
            {
                Entity et = world.CreateEntity();
                et.AddComponent(new Health());
                et.GetComponent <Health>().HP += 100;
                et.Refresh();
                l.Add(et);
            }

            {
                DateTime dt = DateTime.Now;
                world.LoopStart();
                systemManager.UpdateSynchronous(ExecutionType.Update);
                Console.WriteLine((DateTime.Now - dt).TotalMilliseconds);
            }

            EntitySystem.BlackBoard.SetEntry <int>("Damage", 10);

            {
                DateTime dt = DateTime.Now;
                world.LoopStart();
                systemManager.UpdateSynchronous(ExecutionType.Update);
                Console.WriteLine((DateTime.Now - dt).TotalMilliseconds);
            }

            foreach (var item in l)
            {
                Debug.Assert(item.GetComponent <Health>().HP == 85);
            }
        }
示例#2
0
        public static void DummyTests()
        {
            EntityWorld              world                    = new EntityWorld();
            SystemManager            systemManager            = world.SystemManager;
            DummyCommunicationSystem DummyCommunicationSystem = new DummyCommunicationSystem();

            systemManager.SetSystem(DummyCommunicationSystem, ExecutionType.Update);
            systemManager.InitializeAll();

            for (int i = 0; i < 100; i++)
            {
                Entity et = world.CreateEntity();
                et.AddComponent(new Health());
                et.GetComponent <Health>().HP += 100;
                et.Group = "teste";
                et.Refresh();
            }

            {
                Entity et = world.CreateEntity("tag");
                et.AddComponent(new Health());
                et.GetComponent <Health>().HP += 100;
                et.Refresh();
            }

            {
                DateTime dt = DateTime.Now;
                world.LoopStart();
                systemManager.UpdateSynchronous(ExecutionType.Update);
                Console.WriteLine((DateTime.Now - dt).TotalMilliseconds);
            }

            Debug.Assert(world.TagManager.GetEntity("tag") != null);
            Debug.Assert(world.GroupManager.GetEntities("teste").Size == 100);
            Debug.Assert(world.EntityManager.ActiveEntitiesCount == 101);
            Debug.Assert(world.SystemManager.Systems.Size == 1);
        }
        public void DummyTests()
        {
            EntityWorld world = new EntityWorld();
            SystemManager systemManager = world.SystemManager;
            DummyCommunicationSystem DummyCommunicationSystem = new DummyCommunicationSystem();
            systemManager.SetSystem(DummyCommunicationSystem, ExecutionType.UpdateSynchronous);
            world.InitializeAll(false);

            for (int i = 0; i < 100; i++)
            {
                Entity et = world.CreateEntity();
                et.AddComponent(new Health());
                et.GetComponent<Health>().HP += 100;
                et.Group = "teste";
                et.Refresh();
            }

            {
                Entity et = world.CreateEntity();
                et.Tag = "tag";
                et.AddComponent(new Health());
                et.GetComponent<Health>().HP += 100;
                et.Refresh();
            }

            {
                DateTime dt = DateTime.Now;
                world.Update(0);
                Console.WriteLine((DateTime.Now - dt).TotalMilliseconds);
            }

            Debug.Assert(world.TagManager.GetEntity("tag") != null);
            Debug.Assert(world.GroupManager.GetEntities("teste").Size == 100);
            Debug.Assert(world.EntityManager.ActiveEntitiesCount == 101);
            Debug.Assert(world.SystemManager.Systems.Size == 1);
        }
示例#4
0
        public static void SystemComunicationTeste()
        {
            EntitySystem.BlackBoard.SetEntry<int>("Damage", 5);

            EntityWorld world = new EntityWorld();
            SystemManager systemManager = world.SystemManager;
            DummyCommunicationSystem DummyCommunicationSystem = new DummyCommunicationSystem();
            systemManager.SetSystem(DummyCommunicationSystem, ExecutionType.Update);
            systemManager.InitializeAll();

            List<Entity> l = new List<Entity>();
            for (int i = 0; i < 100; i++)
            {
                Entity et = world.CreateEntity();
                et.AddComponent(new Health());
                et.GetComponent<Health>().HP += 100;
                et.Refresh();
                l.Add(et);
            }

            {
                DateTime dt = DateTime.Now;
                world.LoopStart();
                systemManager.UpdateSynchronous(ExecutionType.Update);
                Console.WriteLine((DateTime.Now - dt).TotalMilliseconds);
            }

            EntitySystem.BlackBoard.SetEntry<int>("Damage", 10);

            {
                DateTime dt = DateTime.Now;
                world.LoopStart();
                systemManager.UpdateSynchronous(ExecutionType.Update);
                Console.WriteLine((DateTime.Now - dt).TotalMilliseconds);
            }

            foreach (var item in l)
            {
                Debug.Assert(item.GetComponent<Health>().HP == 85);
            }
        }