Пример #1
0
        public void FTestQueueSystems()
        {
            Debug.WriteLine("Initialize EntityWorld: ");
            EntityWorld entityWorld = new EntityWorld();

#if !PORTABLE
            TestQueueSystemCopy2 testQueueSystem1 = entityWorld.SystemManager.SetSystem(new TestQueueSystemCopy2(10), GameLoopType.Update, 0, ExecutionType.Asynchronous);
#else
            TestQueueSystemCopy2 testQueueSystem1 = entityWorld.SystemManager.SetSystem(new TestQueueSystemCopy2(10), GameLoopType.Update);
#endif
            entityWorld.InitializeAll();
            Debug.WriteLine("OK");

            QueueSystemProcessingThreadSafe <DummyPlaceHolder> .SetQueueProcessingLimit(20, testQueueSystem1.Id);

            Debug.WriteLine("Fill EntityWorld with first  chunk of " + Load + " entities: ");
            List <DummyPlaceHolder> entities1 = new List <DummyPlaceHolder>();
            for (int index = Load; index >= 0; --index)
            {
                DummyPlaceHolder dph = new DummyPlaceHolder {
                    Component = new TestHealthComponent(100)
                };
                QueueSystemProcessingThreadSafe <DummyPlaceHolder> .AddToQueue(dph, testQueueSystem1.Id);

                entities1.Add(dph);
            }

            Debug.WriteLine("OK");
            Debug.WriteLine("Begin down tearing of queues...");
            Stopwatch stopwatch = Stopwatch.StartNew();
            int       loopCount = 0;
            while (QueueSystemProcessingThreadSafe <DummyPlaceHolder> .QueueCount(testQueueSystem1.Id) > 0 || QueueSystemProcessingThreadSafe <DummyPlaceHolder> .QueueCount(testQueueSystem1.Id) > 0)
            {
                entityWorld.Update();
                entityWorld.Draw();
                ++loopCount;
#if DEBUG
                Debug.WriteLine("Queue size thread A: {0} ", QueueSystemProcessingThreadSafe <DummyPlaceHolder> .QueueCount(testQueueSystem1.Id));
#endif
            }

            stopwatch.Stop();
            Debug.WriteLine("End OK. Loops: {0} Time: {1}", loopCount, FastDateTime.ToString(stopwatch.Elapsed));

            Debug.WriteLine("Test entities 1: ");
            const float Expected1 = 90.0f;
            foreach (DummyPlaceHolder entity in entities1)
            {
                TestHealthComponent testHealthComponent = entity.Component as TestHealthComponent;
                if (testHealthComponent != null)
                {
                    Assert.AreEqual(Expected1, testHealthComponent.Points);
                }
            }

            Debug.WriteLine("OK");
        }
Пример #2
0
        /// <summary>The process.</summary>
        /// <param name="entity">The entity.</param>
        public override void Process(DummyPlaceHolder entity)
        {
            TestHealthComponent testHealthComponent = entity.Component as TestHealthComponent;

            if (testHealthComponent != null)
            {
                testHealthComponent.AddDamage(this.damage);
            }
        }
Пример #3
0
        public void BeforeTest()
        {
            _actionStateMachineComponent = new GameObject().AddComponent <MockActionStateMachineComponent>();

            _dispatcherComponent = _actionStateMachineComponent.gameObject
                                   .AddComponent <TestUnityMessageEventDispatcherComponent>();
            _dispatcherComponent.TestAwake();

            _healthComponent = _actionStateMachineComponent.gameObject.AddComponent <TestHealthComponent>();
        }
        /// <summary>The process.</summary>
        /// <param name="entity">The entity.</param>
        public override void Process(Entity entity)
        {
            TestHealthComponent testHealth = entity.GetComponent <TestHealthComponent>();

            if (testHealth != null)
            {
                testHealth.AddDamage(10);
            }

            TestPowerComponent testPower = entity.GetComponent <TestPowerComponent>();

            if (testPower != null)
            {
                testPower.Power -= 10;
            }
        }
Пример #5
0
 public void AfterTest()
 {
     _dispatcherComponent         = null;
     _actionStateMachineComponent = null;
     _healthComponent             = null;
 }