当前位置: 首页>>代码示例>>C#>>正文


C# EntityWorld.LoopStart方法代码示例

本文整理汇总了C#中Artemis.EntityWorld.LoopStart方法的典型用法代码示例。如果您正苦于以下问题:C# EntityWorld.LoopStart方法的具体用法?C# EntityWorld.LoopStart怎么用?C# EntityWorld.LoopStart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Artemis.EntityWorld的用法示例。


在下文中一共展示了EntityWorld.LoopStart方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HybridQueueSystemTeste

        public static void HybridQueueSystemTeste()
        {
            EntityWorld world = new EntityWorld();
            SystemManager systemManager = world.SystemManager;
            HybridQueueSystemTest HybridQueueSystemTest = new ArtemisTest.HybridQueueSystemTest();
            EntitySystem hs = systemManager.SetSystem(HybridQueueSystemTest, 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);
            }

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

            int j = 0;
            while (HybridQueueSystemTest.QueueCount > 0)
            {
                j++;
                DateTime dt = DateTime.Now;
                world.LoopStart();
                systemManager.UpdateSynchronous(ExecutionType.Update);
                Console.WriteLine((DateTime.Now - dt).TotalMilliseconds);
            }

            for (int i = 0; i < 100; i++)
            {
                Debug.Assert(l[i].GetComponent<Health>().HP == 100 - (10 * j));
            }

            for (int i = 100; i < 200; i++)
            {
                Debug.Assert(l[i].GetComponent<Health>().HP == 90);
            }
        }
开发者ID:migueldeicaza,项目名称:artemis_CSharp,代码行数:47,代码来源:Test.cs

示例2: multi

        static void multi()
        {
            healthBag.Add(new Health());
            healthBag.Add(new Health());
            componentPool.Add(typeof(Health), healthBag);

            Bag<Component> tempBag;
            EntityWorld world = new EntityWorld();
            SystemManager systemManager = world.GetSystemManager();
            world.GetEntityManager().RemovedComponentEvent += new RemovedComponentHandler(RemovedComponent);
            world.GetEntityManager().RemovedEntityEvent += new RemovedEntityHandler(RemovedEntity);

            EntitySystem hs = systemManager.SetSystem(new MultHealthBarRenderSystem(),ExecutionType.Update);
            //EntitySystem hs = systemManager.SetSystem(new SingleHEAVYHealthBarRenderSystem(),ExecutionType.Update);
            systemManager.InitializeAll();

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

            for (int i = 0; i < 100; i++)
            {
                DateTime dt = DateTime.Now;
                world.LoopStart();                
                systemManager.UpdateSynchronous(ExecutionType.Update);
                Console.WriteLine((DateTime.Now - dt).TotalMilliseconds);
            }            

            int df = 0;
            foreach (var item in l)
            {
                if (item.GetComponent<Health>().GetHealth() == 90)
                {
                    df++;
                }
            }

 
            Console.ReadLine();
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:46,代码来源:Test.cs

示例3: DummyTests

        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);
        }
开发者ID:hidra1,项目名称:artemis_CSharp,代码行数:36,代码来源:Test.cs

示例4: SystemComunicationTeste

        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);
            }
        }
开发者ID:migueldeicaza,项目名称:artemis_CSharp,代码行数:41,代码来源:Test.cs

示例5: QueueSystemTeste

        public static void QueueSystemTeste()
        {
            EntityWorld world = new EntityWorld();
            SystemManager systemManager = world.SystemManager;
            QueueSystemTest QueueSystemTest = new ArtemisTest.QueueSystemTest();
            QueueSystemTest QueueSystemTest2 = new ArtemisTest.QueueSystemTest();
            systemManager.SetSystem(QueueSystemTest, ExecutionType.Update);
            systemManager.SetSystem(QueueSystemTest2, ExecutionType.Update);

            systemManager.InitializeAll();

            QueueSystemTest.SetQueueProcessingLimit(20, QueueSystemTest.Id);
            Debug.Assert(QueueSystemTest.GetQueueProcessingLimit(QueueSystemTest.Id) == QueueSystemTest.GetQueueProcessingLimit(QueueSystemTest2.Id));

            QueueSystemTest2 QueueSystemTestteste = new ArtemisTest.QueueSystemTest2();
            Debug.Assert(QueueSystemTest.GetQueueProcessingLimit(QueueSystemTestteste.Id) != QueueSystemTest.GetQueueProcessingLimit(QueueSystemTest2.Id));

            QueueSystemTest.SetQueueProcessingLimit(1000, QueueSystemTest.Id);

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

            Console.WriteLine("Start");
            while (QueueSystemTest.QueueCount(QueueSystemTest.Id) > 0 && QueueSystemTest.QueueCount(QueueSystemTest2.Id) > 0)
            {
                DateTime dt = DateTime.Now;
                world.LoopStart();
                systemManager.UpdateAsynchronous(ExecutionType.Update);
                Console.WriteLine("Count: " + QueueSystemTest.QueueCount(QueueSystemTest.Id));
                Console.WriteLine("Time: " + (DateTime.Now - dt).TotalMilliseconds);

            }
            Console.WriteLine("End");

            foreach (var item in l)
            {
                Debug.Assert(item.GetComponent<Health>().HP == 90);
            }
        }
开发者ID:migueldeicaza,项目名称:artemis_CSharp,代码行数:46,代码来源:Test.cs

示例6: multsystem

        public static void multsystem()
        {
            healthBag.Clear();
            componentPool.Clear();

            healthBag.Add(new Health());
            healthBag.Add(new Health());
            componentPool.Add(typeof(Health), healthBag);

            Bag<Component> tempBag;
            EntityWorld world = new EntityWorld();
            SystemManager systemManager = world.SystemManager;
            world.EntityManager.RemovedComponentEvent += new RemovedComponentHandler(RemovedComponent);
            world.EntityManager.RemovedEntityEvent += new RemovedEntityHandler(RemovedEntity);
            EntitySystem hs = systemManager.SetSystem(new SingleHealthBarRenderSystem(),ExecutionType.Update);
            hs = systemManager.SetSystem(new DummySystem(),ExecutionType.Update);
            hs = systemManager.SetSystem(new DummySystem2(),ExecutionType.Update);
            hs = systemManager.SetSystem(new DummySystem3(),ExecutionType.Update);
            systemManager.InitializeAll();

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

            for (int i = 0; i < 100; i++)
            {
                DateTime dt = DateTime.Now;
                world.LoopStart();
                systemManager.UpdateAsynchronous(ExecutionType.Update);
                //systemManager.UpdateSynchronous(ExecutionType.Update);
                Console.WriteLine((DateTime.Now - dt).TotalMilliseconds);
            }

            //int df = 0;
            //foreach (var item in l)
            //{
            //    if (item.GetComponent<Health>().GetHealth() == 90)
            //    {
            //        df++;
            //    }
            //    else
            //    {
            //        Console.WriteLine("errro");
            //    }
            //}
        }
开发者ID:migueldeicaza,项目名称:artemis_CSharp,代码行数:52,代码来源:Test.cs


注:本文中的Artemis.EntityWorld.LoopStart方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。