Пример #1
0
        public void Publish()
        {
            ActiveCollisionsContainer.EventData eventData = new ActiveCollisionsContainer.EventData();
            GameObject oneContainer;

            CollisionNotifier.EventData oneData     = CollisionNotifierHelper.GetEventData(out oneContainer);
            ActiveCollisionConsumerMock oneConsumer = oneContainer.AddComponent <ActiveCollisionConsumerMock>();
            GameObject twoContainer;

            CollisionNotifier.EventData twoData     = CollisionNotifierHelper.GetEventData(out twoContainer);
            ActiveCollisionConsumerMock twoConsumer = twoContainer.AddComponent <ActiveCollisionConsumerMock>();

            eventData.ActiveCollisions.Add(oneData);
            eventData.ActiveCollisions.Add(twoData);
            subject.SetActiveCollisions(eventData);

            Assert.IsFalse(oneConsumer.received);
            Assert.IsFalse(twoConsumer.received);

            subject.Publish();

            Assert.IsTrue(oneConsumer.received);
            Assert.IsTrue(twoConsumer.received);

            Object.DestroyImmediate(oneContainer);
            Object.DestroyImmediate(twoContainer);
        }
        public void Publish()
        {
            ActiveCollisionsContainer.EventData eventData = new ActiveCollisionsContainer.EventData();
            GameObject oneContainer;

            CollisionNotifier.EventData oneData     = CollisionNotifierHelper.GetEventData(out oneContainer);
            ActiveCollisionConsumerMock oneConsumer = oneContainer.AddComponent <ActiveCollisionConsumerMock>();
            GameObject twoContainer;

            CollisionNotifier.EventData twoData     = CollisionNotifierHelper.GetEventData(out twoContainer);
            ActiveCollisionConsumerMock twoConsumer = twoContainer.AddComponent <ActiveCollisionConsumerMock>();

            eventData.ActiveCollisions.Add(oneData);
            eventData.ActiveCollisions.Add(twoData);
            subject.SetActiveCollisions(eventData);

            Assert.IsFalse(oneConsumer.received);
            Assert.IsFalse(twoConsumer.received);

            subject.Publish();

            Assert.IsTrue(oneConsumer.received);
            Assert.IsTrue(twoConsumer.received);
            Assert.AreEqual("{ SourceContainer = [null] | PublisherContainer = New Game Object (UnityEngine.GameObject) }", subject.Payload.ToString());

            Object.DestroyImmediate(oneContainer);
            Object.DestroyImmediate(twoContainer);
        }
 protected virtual void ProcessGrabAction(ActiveCollisionPublisher publisher, bool actionState)
 {
     if (grabAction?.Value != actionState)
     {
         grabAction?.Receive(actionState);
     }
     else
     {
         publisher?.Publish();
     }
 }
 protected virtual void ProcessGrabAction(ActiveCollisionPublisher publisher, bool actionState)
 {
     precognitionTimer.enabled = false;
     if (grabAction.Value != actionState)
     {
         grabAction.Receive(actionState);
     }
     if (grabAction.Value)
     {
         publisher.Publish();
     }
     precognitionTimer.enabled = true;
 }
Пример #5
0
 /// <summary>
 /// Processes the given collision data into a grab action based on the given state.
 /// </summary>
 /// <param name="publisher">The collision data to process.</param>
 /// <param name="actionState">The grab state to check against.</param>
 protected virtual void ProcessGrabAction(ActiveCollisionPublisher publisher, bool actionState)
 {
     InstantGrabProcessor.SetActive(false);
     PrecognitionGrabProcessor.SetActive(false);
     if (GrabAction.Value != actionState)
     {
         GrabAction.Receive(actionState);
     }
     if (GrabAction.Value)
     {
         publisher.Publish();
     }
     ChooseGrabProcessor();
 }